LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 05-15-2010, 05:03 PM   #1
gandrusz
LQ Newbie
 
Registered: Apr 2010
Posts: 23

Rep: Reputation: 0
Unhappy How to fix grub after moving root partition?


Hi,

Because I am using one of the new WD disks I am trying to aling my root partition with the real sectors, as described here:

http://community.wdc.com/t5/Desktop/...m-p/10920#M631

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?
 
Old 05-15-2010, 05:16 PM   #2
brucehinrichs
Member
 
Registered: Mar 2008
Location: US
Distribution: Debian Sid; Sabayon, UbuntuStudio, Slackware-multilib 13.1, Peppermint Ice, CentOS
Posts: 575

Rep: Reputation: 69
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.
 
Old 05-15-2010, 05:22 PM   #3
zuzoa
Member
 
Registered: Nov 2008
Location: USA
Distribution: Arch 64-bit
Posts: 159

Rep: Reputation: 36
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'.
 
Old 05-15-2010, 05:22 PM   #4
gandrusz
LQ Newbie
 
Registered: Apr 2010
Posts: 23

Original Poster
Rep: Reputation: 0
Hi,

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).
 
Old 05-15-2010, 05:26 PM   #5
brucehinrichs
Member
 
Registered: Mar 2008
Location: US
Distribution: Debian Sid; Sabayon, UbuntuStudio, Slackware-multilib 13.1, Peppermint Ice, CentOS
Posts: 575

Rep: Reputation: 69
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
 
1 members found this post helpful.
Old 05-15-2010, 05:27 PM   #6
gandrusz
LQ Newbie
 
Registered: Apr 2010
Posts: 23

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by zuzoa View Post
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
 
Old 05-15-2010, 05:36 PM   #7
zuzoa
Member
 
Registered: Nov 2008
Location: USA
Distribution: Arch 64-bit
Posts: 159

Rep: Reputation: 36
Well it looks like your linux partition is still /dev/sda3. Can you post the contents of your /boot/grub/menu.lst (or grub.conf) file?
 
Old 05-15-2010, 05:46 PM   #8
gandrusz
LQ Newbie
 
Registered: Apr 2010
Posts: 23

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by brucehinrichs View Post
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 ###
 
Old 05-15-2010, 05:54 PM   #9
zuzoa
Member
 
Registered: Nov 2008
Location: USA
Distribution: Arch 64-bit
Posts: 159

Rep: Reputation: 36
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"
 
Old 05-15-2010, 05:57 PM   #10
brucehinrichs
Member
 
Registered: Mar 2008
Location: US
Distribution: Debian Sid; Sabayon, UbuntuStudio, Slackware-multilib 13.1, Peppermint Ice, CentOS
Posts: 575

Rep: Reputation: 69
I hope this isn't it , but the filesystem may have been corrupted. From the liveCD terminal try:
Code:
e2fsck -fyv /dev/sda3
to check the filesystem.
 
Old 05-15-2010, 06:02 PM   #11
brucehinrichs
Member
 
Registered: Mar 2008
Location: US
Distribution: Debian Sid; Sabayon, UbuntuStudio, Slackware-multilib 13.1, Peppermint Ice, CentOS
Posts: 575

Rep: Reputation: 69
@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.
 
Old 05-15-2010, 06:07 PM   #12
zuzoa
Member
 
Registered: Nov 2008
Location: USA
Distribution: Arch 64-bit
Posts: 159

Rep: Reputation: 36
Quote:
Originally Posted by brucehinrichs View Post
@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.

Last edited by zuzoa; 05-15-2010 at 06:15 PM.
 
Old 05-15-2010, 06:14 PM   #13
brucehinrichs
Member
 
Registered: Mar 2008
Location: US
Distribution: Debian Sid; Sabayon, UbuntuStudio, Slackware-multilib 13.1, Peppermint Ice, CentOS
Posts: 575

Rep: Reputation: 69
From this link:
Quote:
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"
 
Old 05-16-2010, 01:20 AM   #14
gandrusz
LQ Newbie
 
Registered: Apr 2010
Posts: 23

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by zuzoa View Post
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)
 
Old 05-16-2010, 01:22 AM   #15
gandrusz
LQ Newbie
 
Registered: Apr 2010
Posts: 23

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by brucehinrichs View Post
I hope this isn't it , but the filesystem may have been corrupted. From the liveCD terminal try:
Code:
e2fsck -fyv /dev/sda3
to check the filesystem.
The filesystem looks alright:
Code:
root@Microknoppix:/home/knoppix# e2fsck -fyv /dev/sda3
e2fsck 1.41.9 (22-Aug-2009)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information

  307025 inodes used (5.03%)
      56 non-contiguous files (0.0%)
     240 non-contiguous directories (0.1%)
         # of inodes with ind/dind/tind blocks: 16891/186/0
 2494089 blocks used (10.22%)
       0 bad blocks
       1 large file

  239379 regular files
   25314 directories
       0 character device files
       0 block device files
       0 fifos
     411 links
   42323 symbolic links (36640 fast symbolic links)
       0 sockets
--------
  307427 files
 
  


Reply

Tags
grub



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
moving /home /root & /var to new partition CrashedAgain Linux - General 8 11-24-2005 10:44 AM
Moving grub.conf to another partition oO0agentcow0Oo Linux - Newbie 5 07-27-2005 02:05 PM
moving root / partition on Slack 10.0 mrhide Slackware 3 04-06-2005 11:21 AM
How to fix grub after removing linux partition cantonboy Linux - Newbie 3 11-19-2004 05:09 PM
Moving grub to another partition salinger Linux - Software 3 03-15-2003 07:26 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:04 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration