Ubuntu doesn't boot anymore - GRUB error

I got into trouble when I changed my old 160 GB ata drive to a brand new 1 TB sata drive. I simply used GParted to copy the partitions over from the old disk to the new.

When booting on the new disk, I got a screen filled with GRUB GRUB GRUB and so on - and no, it's not a virus. ;-)

Several things I forgot about:

  • When duplicating the partitions, you can either create new GUIDs, or keep the existing ones.
    • I didn't intend to keep the old disk, so I should have chosen to keep the existing GUIDs
    • However, if you want to keep the old and new disks side by side, it's better to create new GUIDs to prevent any conflict.
  • The MBR is not copied over. Of course, since I just copied the partitions!

Ubuntu was not bootable anymore because of the new GUIDs and the fact the MBR was missing. Using a Live CD (in my case, RIPLinuX, but it's also doable with the Ubuntu live disk), I could boot my Ubuntu system. Using RIPLinuX:

  1. Choose Boot Linux Partition
  2. Press TAB
  3. Change /dev/XXXX to /dev/sda3 (or /dev/yourLinuxPartition, I assume you know what I'm talking about)
  4. Press Enter twice

You should be able to log in your Ubuntu system. Then, in a terminal:

gksudo gedit /boot/grub/menu.lst

I then looked for the uuid entries to fix the GUIDs. A GRUB entry looks like this:

title		Ubuntu 9.04, kernel 2.6.28-13-generic
uuid		977b7629-714a-48e1-be06-0dc95df1dfa5
kernel		/boot/vmlinuz-2.6.28-13-generic root=UUID=977b7629-714a-48e1-be06-0dc95df1dfa5 ro xforcevesa quiet splash 
initrd		/boot/initrd.img-2.6.28-13-generic
quiet

The UUID is the GUID of your partition. I could fix GRUB by changing the GUIDs accordingly. If you don't know what the GUID of your partition is, you can use GParted to find it. It could be that instead of uuid, you have root (hdX,Y) instead. I would recommend you change root to uuid, which I think is more clean and robust.

Additionally, I also had to fix the fstab (file systems table) with the new GUIDs. A fstab entry would look like this:

UUID=177b7629-714a-41e1-be07-0de95df1dfa5 / ext3 relatime,errors=remount-ro 0 1

In the old days, fstab was using /dev/sdX0 to identify a file system. Again, it is much better to use a GUID instead.

We can finally restore GRUB (the Linux loader):

  1. Start a terminal, then:
sudo grub
find /boot/grub/stage1
  1. It will give you something like (hdX,Y), then type
root (hdX,Y)
setup (hdX)
quit

Done!

source 1 source 2 source 3

Page top