I am dual-booting Windows 7 and Ubuntu 12.04. I reduced my Windows 7 partition and increased my Ubuntu partition using gparted from a 12.04 live CD. Everything was fine for about a week. Then the other day I booted and was met with "grub rescue." I purged and re-installed both grub and then grub2 as per the many tutorials on line, but all efforts have met with the same results: It seems that os-prober sees my 2 Windows 7 (actual and restore) partitions, as well as the Ubuntu 12.04 LTS partition; but when I run any variant of update-grub or update-grub2, it only detects the 2 Windows 7 partitions. As a result I cannot boot into Ubuntu (which is where 99% of my work is). Here is the output of bootinfoscript:
Boot Info Script 0.61 [1 April 2012]
============================= Boot Info Summary: ===============================
=> Grub2 (v1.99) is installed in the MBR of /dev/sda and looks at sector 1 of
the same hard drive for core.img. core.img is at this location and looks
for (,msdos5)/boot/grub on this drive.
sda1: __________________________________________________________________________
File system: ntfs
Boot sector type: Windows Vista/7: NTFS
Boot sector info: No errors found in the Boot Parameter Block.
Operating System:
Boot files: /bootmgr /Boot/BCD
sda2: __________________________________________________________________________
File system: ntfs
Boot sector type: Windows Vista/7: NTFS
Boot sector info: No errors found in the Boot Parameter Block.
Operating System: Windows 7
Boot files: /bootmgr /Boot/BCD /Windows/System32/winload.exe
sda3: __________________________________________________________________________
File system: ntfs
Boot sector type: Windows Vista/7: NTFS
Boot sector info: No errors found in the Boot Parameter Block.
Operating System:
Boot files:
sda4: __________________________________________________________________________
File system: Extended Partition
Boot sector type: -
Boot sector info:
sda5: __________________________________________________________________________
File system: ext4
Boot sector type: Grub2 (v1.99)
Boot sector info: Grub2 (v1.99) is installed in the boot sector of sda5
and looks at sector 525161552 of the same hard drive
for core.img. core.img is at this location and looks
for (,msdos5)/boot/grub on this drive.
Operating System: Ubuntu 12.04 LTS
Boot files: /boot/grub/grub.cfg /etc/fstab /boot/grub/core.img
sda6: __________________________________________________________________________
File system:
Boot sector type: -
Boot sector info:
Mounting failed: mount: unknown filesystem type ''
============================ Drive/Partition Info: =============================
Drive: sda _____________________________________________________________________
Disk /dev/sda: 320.1 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders, total 625142448 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
Partition Boot Start Sector End Sector # of Sectors Id System
/dev/sda1 2,048 206,847 204,800 7 NTFS / exFAT / HPFS
/dev/sda2 206,848 504,360,959 504,154,112 7 NTFS / exFAT / HPFS
/dev/sda3 591,218,688 625,137,663 33,918,976 7 NTFS / exFAT / HPFS
/dev/sda4 504,360,960 591,218,687 86,857,728 5 Extended
/dev/sda5 * 504,363,008 583,360,511 78,997,504 83 Linux
/dev/sda6 583,362,560 591,218,687 7,856,128 82 Linux swap / Solaris
"blkid" output: ________________________________________________________________
Device UUID TYPE LABEL
/dev/loop0 squashfs
/dev/sda1 DA669D8C669D69D1 ntfs System Reserved
/dev/sda2 BAAAA703AAA6BAF1 ntfs
/dev/sda3 8E22D1E022D1CCF9 ntfs OS Recovery
/dev/sda5 c35e7a0a-408c-4586-8a18-b3faa368ef3f ext4
/dev/sr0 iso9660 Ubuntu 12.04 LTS amd64
================================ Mount points: =================================
Device Mount_Point Type Options
/dev/loop0 /rofs squashfs (ro,noatime)
/dev /mnt/dev none (rw,bind)
/dev/pts /mnt/dev/pts none (rw,bind)
/dev/sda2 /media/BAAAA703AAA6BAF1 fuseblk (rw,nosuid,nodev,allow_other,default_permissions,blksize=4096)
/dev/sda5 /media/c35e7a0a-408c-4586-8a18-b3faa368ef3f ext4 (rw,nosuid,nodev,uhelper=udisks)
/dev/sda5 /mnt ext4 (rw)
/dev/sr0 /cdrom iso9660 (ro,noatime)
=========================== sda5/boot/grub/grub.cfg: ===========================
--------------------------------------------------------------------------------
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#
### BEGIN /etc/grub.d/00_header ###
if [ -s $prefix/grubenv ]; then
set have_grubenv=true
load_env
fi
set default="0"
if [ "${prev_saved_entry}" ]; then
set saved_entry="${prev_saved_entry}"
save_env saved_entry
set prev_saved_entry=
save_env prev_saved_entry
set boot_once=true
fi
function savedefault {
if [ -z "${boot_once}" ]; then
saved_entry="${chosen}"
save_env saved_entry
fi
}
function recordfail {
set recordfail=1
if [ -n "${have_grubenv}" ]; then if [ -z "${boot_once}" ]; then save_env recordfail; fi; fi
}
function load_video {
insmod vbe
insmod vga
insmod video_bochs
insmod video_cirrus
}
insmod part_msdos
insmod ext2
set root='(hd0,msdos5)'
search --no-floppy --fs-uuid --set=root c35e7a0a-408c-4586-8a18-b3faa368ef3f
if loadfont /usr/share/grub/unicode.pf2 ; then
set gfxmode=auto
load_video
insmod gfxterm
insmod part_msdos
insmod ext2
set root='(hd0,msdos5)'
search --no-floppy --fs-uuid --set=root c35e7a0a-408c-4586-8a18-b3faa368ef3f
set locale_dir=($root)/boot/grub/locale
set lang=en_US
insmod gettext
fi
terminal_output gfxterm
if [ "${recordfail}" = 1 ]; then
set timeout=-1
else
set timeout=10
fi
### END /etc/grub.d/00_header ###
### BEGIN /etc/grub.d/05_debian_theme ###
set menu_color_normal=white/black
set menu_color_highlight=black/light-gray
if background_color 44,0,30; then
clear
fi
### END /etc/grub.d/05_debian_theme ###
### BEGIN /etc/grub.d/10_linux ###
function gfxmode {
set gfxpayload="${1}"
if [ "${1}" = "keep" ]; then
set vt_handoff=vt.handoff=7
else
set vt_handoff=
fi
}
if [ "${recordfail}" != 1 ]; then
if [ -e ${prefix}/gfxblacklist.txt ]; then
if hwmatch ${prefix}/gfxblacklist.txt 3; then
if [ ${match} = 0 ]; then
set linux_gfx_mode=keep
else
set linux_gfx_mode=text
fi
else
set linux_gfx_mode=text
fi
else
set linux_gfx_mode=keep
fi
else
set linux_gfx_mode=text
fi
export linux_gfx_mode
if [ "${linux_gfx_mode}" != "text" ]; then load_video; fi
### END /etc/grub.d/10_linux ###
### BEGIN /etc/grub.d/20_linux_xen ###
### END /etc/grub.d/20_linux_xen ###
### BEGIN /etc/grub.d/30_os-prober ###
menuentry "Windows 7 (loader) (on /dev/sda1)" --class windows --class os {
insmod part_msdos
insmod ntfs
set root='(hd0,msdos1)'
search --no-floppy --fs-uuid --set=root DA669D8C669D69D1
chainloader +1
}
### END /etc/grub.d/30_os-prober ###
### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###
### BEGIN /etc/grub.d/41_custom ###
if [ -f $prefix/custom.cfg ]; then
source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###
--------------------------------------------------------------------------------
=============================== sda5/etc/fstab: ================================
--------------------------------------------------------------------------------
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc nodev,noexec,nosuid 0 0
# / was on /dev/sda5 during installation
UUID=c35e7a0a-408c-4586-8a18-b3faa368ef3f / ext4 errors=remount-ro 0 1
# swap was on /dev/sda6 during installation
#UUID=a4d335d5-6a81-4af8-a1c7-3beeee8699a1 none swap sw 0 0
/dev/mapper/cryptswap1 none swap sw 0 0
--------------------------------------------------------------------------------
=================== sda5: Location of files loaded by Grub: ====================
GiB - GB File Fragment(s)
= boot/grub/core.img 1
= boot/grub/grub.cfg 1
========= Devices which don't seem to have a corresponding hard drive: =========
sdb
=============================== StdErr Messages: ===============================
xz: (stdin): Compressed data is corrupt
xz: (stdin): Compressed data is corrupt
awk: cmd. line:36: Math support is not compiled in
awk: cmd. line:36: Math support is not compiled in
And of sudo os-prober from 12.04 LiveCD:
/dev/sda1:Windows 7 (loader):Windows:chain
/dev/sda2:Windows 7 (loader):Windows1:chain
/dev/sda5:Ubuntu 12.04 LTS (12.04):Ubuntu:linux
I have read pretty much every guide, tutorial and question that exists out there for updating any version of grub, but nothing has worked. But what is most confusing is that os-prober sees the installation; I would very much appreciate any assistance in this matter.
Have you tried adding a "custom"
menuentry
to boot Ubuntu by editinggrub.cfg
?I decided I might as well suggest this since even if it does not work perhaps it will result in a more useful error message.
Boot your system using your 12.04 LiveCD.
Mount the
sda5
partition Ubuntu is installed on. In this example I will assumesda5
was mounted at/mnt
using, for example,sudo mount -t ext4 /dev/sda5 /mnt
.Determine which kernel(s) you have installed by listing the contents of the
/mnt/boot
directory. You will need this information to complete step (5) below.Note: The command below is one way you could do this.
Use
sudo
to edit the file/mnt/boot/grub/grub.cfg
(i.e. thegrub.cfg
file on yoursda5
Ubuntu partition).Find the the lines below in the file. They should be ~10 lines before the end of the file.
Replace the above with the GRUB commands for the
menuentry
below.Important: In the example below you must replace
?.?.?-??
in thelinux
andinitrd
lines with the version number (from step (3)) of the kernel you wish to boot.Reboot and see if this custom entry allows you to boot Ubuntu from
/dev/sda5
.If the suggestion above worked, then I would suggest trying the following.
Use
sudo
to edit the file/etc/grub.d/40_cutom
and append the menuentry commands from step (5) to the end of the file. This way the menu entry will not be lost if you runupdate-grub
.Warning: Do not delete the two lines below! They need to be at the beginning of the file
40_custom
forupdate-grub
to work properly.Try reinstalling GRUB yet one more time using the command below. (Why not?)
Update responding to comment that kernel files are missing from
/boot
I've never run into a situation where the kernel files were missing from
/boot
. My first concern would be that if your kernel files are missing, then something else could be seriously wrong with the Ubuntu installed onsda5
.I suggest that you update your question and its title to reflect that there are no kernel files in
/boot
. Doing this increases your chances of getting a better answer from someone else.I searched AskUnbuntu for a similar question, but all I found was the one linked below.
How to restore a system after accidentally removing all kernels?
The best answer to that question was to
chroot
and then try re-installing the kernel which you say you've already tried. The only change I could suggest is you try again using these commands. (Note:sudo
was not used below because if youchroot
you already areroot
.)grub-install --recheck /dev/sda
The manpage for update-initramfs may also help provide some context about what happens when a kernel is "installed".
In hindsight I should have realized something was wrong from reading your BootInfo summary. It ends with the excerpt below.
But instead of the errors above I should have expected to see something like the excerpt below from a BootInfo summary I created as an example.
Run Boot-Repair's "Recommended repair". This will reinstall GRUB and reinstall a kernel if needed. If any problem indicate the URL that will appear.