[SOLVED] How to fix grub after moving root partition?
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
So I copied all files to a temp location, deleted my partition (/dev/sda3), recreated it a few cylinders later (same name) and copied the files to the newly created partition. But now when I try to boot, I get my old grub menu but after selecting my kernel version it hangs... Any idea how I can fix it?
Use a LiveCD to boot, open a terminal and type: sudo grub-install. Select where you want grub installed (probably to the MBR, but if you are dual-booting maybe to /), and reboot. If that doesn't work, post back, as there are alternative solutions.
Are you sure the partition was recreated as /dev/sda3? If it changed, you'll have to edit your /boot/grub/grub.conf or /boot/grub/menu.lst with the new info. Please post the contents of this file and the output of 'fdisk -l'.
Yes, I have grub installed in MBR (because of dual boot as you suggested). I did actually run grub-install from Knoppix (sorry, should have mentioned in the initial post) and grub itself IS running fine, its just hanging after I select my configuration from the list (I haven't tried booting to Windows yet).
The command blkid (as root) will give you the current UUID number for that (actually all) partition. Check that number against the UUID in your /boot/grub/menu.lst file. If the numbers don't match, change the value in /boot/grub/menu.lst to the value blkid returned, then try booting again.
EDIT: If you're certain it is /dev/sda3, you can use blkid /dev/sda3 to get the UUID for that partition only.
Last edited by brucehinrichs; 05-15-2010 at 05:32 PM.
Reason: added: as root
Are you sure the partition was recreated as /dev/sda3? If it changed, you'll have to edit your /boot/grub/grub.conf or /boot/grub/menu.lst with the new info. Please post the contents of this file and the output of 'fdisk -l'.
knoppix@Microknoppix:~$ fdisk -l
Disk /dev/sda: 1500.3 GB, 1500301910016 bytes
255 heads, 63 sectors/track, 182401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x24b4d5f6
Device Boot Start End Blocks Id System
/dev/sda1 1 13 102400 7 HPFS/NTFS
Partition 1 does not end on cylinder boundary.
/dev/sda2 13 25497 204696576 7 HPFS/NTFS
/dev/sda3 * 25498 37654 97642496 83 Linux
/dev/sda4 37655 182401 1162680277+ 5 Extended
/dev/sda5 37655 38870 9767488+ 82 Linux swap / Solaris
/dev/sda6 38871 182401 1152912726 83 Linux
The command blkid (as root) will give you the current UUID number for that (actually all) partition. Check that number against the UUID in your /boot/grub/menu.lst file. If the numbers don't match, change the value in /boot/grub/menu.lst to the value blkid returned, then try booting again.
EDIT: If you're certain it is /dev/sda3, you can use blkid /dev/sda3 to get the UUID for that partition only.
The UUIDs were different indeed (I didn't find menu.lst, updated grub.cfg instead). Currently I get the following error messages:
Code:
mount: mounting /dev on /root/dev failed: No such file or directory
mount: mounting /sys on /root/sys failed: No such file or directory
mount: mounting /proc on /root/proc failed: No such file or directory
/init: line 253: can't open /root/dev/console: no such file
... Kernel Panic....
My current grub.cfg:
Code:
knoppix@Microknoppix:~$ cat /media/sda3/boot/grub/grub.cfg
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by /usr/sbin/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
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
}
insmod ext2
set root='(hd0,3)'
search --no-floppy --fs-uuid --set c2612767-032d-43a2-b414-aac0a0f7d5f5
if loadfont /usr/share/grub/unicode.pf2 ; then
set gfxmode=640x480
insmod gfxterm
insmod vbe
if terminal_output gfxterm ; then true ; else
# For backward compatibility with versions of terminal.mod that don't
# understand terminal_output
terminal gfxterm
fi
fi
insmod ext2
set root='(hd0,3)'
search --no-floppy --fs-uuid --set c2612767-032d-43a2-b414-aac0a0f7d5f5
set locale_dir=($root)/boot/grub/locale
set lang=en
insmod gettext
set timeout=5
### END /etc/grub.d/00_header ###
### BEGIN /etc/grub.d/05_debian_theme ###
insmod ext2
set root='(hd0,3)'
search --no-floppy --fs-uuid --set c2612767-032d-43a2-b414-aac0a0f7d5f5
insmod png
if background_image /boot/grub/moreblue-orbit-grub.png ; then
set color_normal=black/black
set color_highlight=magenta/black
else
set menu_color_normal=cyan/blue
set menu_color_highlight=white/blue
fi
### END /etc/grub.d/05_debian_theme ###
### BEGIN /etc/grub.d/10_linux ###
menuentry "Debian GNU/Linux, with Linux 2.6.32-trunk-686" --class debian --class gnu-linux --class gnu --class os {
insmod ext2
set root='(hd0,3)'
search --no-floppy --fs-uuid --set c2612767-032d-43a2-b414-aac0a0f7d5f5
echo Loading Linux 2.6.32-trunk-686 ...
linux /boot/vmlinuz-2.6.32-trunk-686 root=UUID=c2612767-032d-43a2-b414-aac0a0f7d5f5 ro quiet
echo Loading initial ramdisk ...
initrd /boot/initrd.img-2.6.32-trunk-686
}
menuentry "Debian GNU/Linux, with Linux 2.6.32-trunk-686 (recovery mode)" --class debian --class gnu-linux --class gnu --class os {
insmod ext2
set root='(hd0,3)'
search --no-floppy --fs-uuid --set c2612767-032d-43a2-b414-aac0a0f7d5f5
echo Loading Linux 2.6.32-trunk-686 ...
linux /boot/vmlinuz-2.6.32-trunk-686 root=UUID=c2612767-032d-43a2-b414-aac0a0f7d5f5 ro single
echo Loading initial ramdisk ...
initrd /boot/initrd.img-2.6.32-trunk-686
}
menuentry "Debian GNU/Linux, with Linux 2.6.32-3-686" --class debian --class gnu-linux --class gnu --class os {
insmod ext2
set root='(hd0,3)'
search --no-floppy --fs-uuid --set c2612767-032d-43a2-b414-aac0a0f7d5f5
echo Loading Linux 2.6.32-3-686 ...
linux /boot/vmlinuz-2.6.32-3-686 root=UUID=c2612767-032d-43a2-b414-aac0a0f7d5f5 ro quiet
echo Loading initial ramdisk ...
initrd /boot/initrd.img-2.6.32-3-686
}
menuentry "Debian GNU/Linux, with Linux 2.6.32-3-686 (recovery mode)" --class debian --class gnu-linux --class gnu --class os {
insmod ext2
set root='(hd0,3)'
search --no-floppy --fs-uuid --set c2612767-032d-43a2-b414-aac0a0f7d5f5
echo Loading Linux 2.6.32-3-686 ...
linux /boot/vmlinuz-2.6.32-3-686 root=UUID=c2612767-032d-43a2-b414-aac0a0f7d5f5 ro single
echo Loading initial ramdisk ...
initrd /boot/initrd.img-2.6.32-3-686
}
### END /etc/grub.d/10_linux ###
### BEGIN /etc/grub.d/11_Windows ###
menuentry ���Windows 7��� {
insmod ntfs
set root=(hd0,2)
search --no-floppy --fs-uuid --set 5e5001485001287b
chainloader +1
}
### END /etc/grub.d/11_Windows ###
### BEGIN /etc/grub.d/30_os-prober ###
menuentry "Windows 7 (loader) (on /dev/sda1)" {
insmod ntfs
set root='(hd0,1)'
search --no-floppy --fs-uuid --set 5e5001485001287b
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 ###
Sometimes it helps to add the partition, (hd0,2), before the paths like /boot/vmlinuz and /boot/initrd, so they become "(hd0,2)/boot/vmlinuz-2.6.32-trunk-686 root=UUID=c2612767-032d-43a2-b414-aac0a0f7d5f5 ro quiet"
@zuzoa: Does grub2 use the same naming scheme as grub legacy (/dev/sda3 = (hd0,2)) or did they change it to correspond to the /dev scheme (/dev/sda3 = (hd0,3))? I honestly don't remember, as I still use legacy.
EDIT: The reason I ask is OPs grub.cfg file says "set root='(hd0,3)'"
Last edited by brucehinrichs; 05-15-2010 at 06:04 PM.
@zuzoa: Does grub2 use the same naming scheme as grub legacy (/dev/sda3 = (hd0,2)) or did they change it to correspond to the /dev scheme (/dev/sda3 = (hd0,3))? I honestly don't remember, as I still use legacy.
EDIT: The reason I ask is OPs grub.cfg file says "set root='(hd0,3)'"
Honestly, I'm not sure. I still use legacy as well. If one doesn't work, try the other :P I would guess it's probably the same convention to avoid confusion, but I don't know.
Edit: I just realised that this might be the cause of the problems. OP, Please change the line to "set root='(hd0,2)'" and try booting.
In other words, devices are still numbered from 0, but partitions start with 1. For example, this means that sda1 is now (hd0,1) and NOT (hd0,0) as before!
So, /dev/sda3 = (hd0,3), and zuzoa's (good) suggestion amended:
Quote:
Sometimes it helps to add the partition, (hd0,3), before the paths like /boot/vmlinuz and /boot/initrd, so they become "(hd0,3)/boot/vmlinuz-2.6.32-trunk-686 root=UUID=c2612767-032d-43a2-b414-aac0a0f7d5f5 ro quiet"
Honestly, I'm not sure. I still use legacy as well. If one doesn't work, try the other :P I would guess it's probably the same convention to avoid confusion, but I don't know.
Edit: I just realised that this might be the cause of the problems. OP, Please change the line to "set root='(hd0,2)'" and try booting.
Tried that and it completely doesn't work now (so I think they must have changed the convention)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.