I've been running Ubuntu 10.04 and just installed Linux Mint 13. I may go with Linux Mint full-time, but for now I wanted to install it to the first partition, but keep Ubuntu bootable.
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 58593279 29295616 83 Linux
/dev/sda2 58595326 976768064 459086369+ 5 Extended
/dev/sda5 959980140 976768064 8393962+ 82 Linux swap / Solaris
/dev/sda6 58595328 898696186 420050429+ 83 Linux
/dev/sda7 898697216 959963135 30632960 83 Linux
sda6 is a data partition with all my documents. sda7 was added new to create the dual boot setup. I cloned sda1 to sda7 with
dd if=/dev/sda1 of=/dev/sda7
Of course this also cloned the UUID, so I created a new UUID for sda7 with
tune2fs /dev/sda7 -U random
When I list UUIDs with blkid
it has indeed changed. I then installed Linux Mint to sda1. I also have fstab setup to mount sda7 so I can copy configuration files to the new OS. I boot into Linux Mint fine, but when I try to boot into Ubuntu, I get a message (from memory, may be incomplete) that the loader can't find /dev/disk/by-uuid/<old UUID>
.
At this point I looked in grub.cfg, and sure enough, the old UUID is listed, along with the new one:
### BEGIN /etc/grub.d/30_os-prober ###
menuentry "Ubuntu, with Linux 2.6.32-41-generic (on /dev/sda7)" --class gnu-linux --class gnu --class os {
insmod part_msdos
insmod ext2
set root='(hd0,msdos7)'
search --no-floppy --fs-uuid --set=root 3869f8c2-dcf8-4522-bc8b-91b0ce0040fa #This is the new UUID
linux /boot/vmlinuz-2.6.32-41-generic root=UUID=72a5e117-9a39-4de1-9d28-53791d055ff5 ro quiet splash #This is the old UUID
initrd /boot/initrd.img-2.6.32-41-generic
}
I then tried to fix this with sudo update-grub
, but I still get the same entry with the mix of new and old UUIDs. I also tried manually editing grub.cfg to replace the old with the new UUID, but I still get the same message, that the loader can't find a device with the old UUID.
So, where is update-grub
reading the old UUID from? And how do I fix grub so that it can boot the cloned partition?
Best Answer
My guess is that you are not viewing/editing the same grub.cfg that the bootloader is looking at. Remember, you have two different
/boot/grub
directories now, and the bootloader needs to know which one to look for.update-grub
is updating the grub.cfg in the currently mounted/boot/grub/grub.cfg
. I'm guessing that the bootloader is looking on the other partition. After I finish my first cup of coffee, I may be able to confirm this by following through your post and perhaps making notes, but right now it's got to be an educated guess.I believe what you need to do is to run
sudo grub-install --root-directory=/ /dev/sda
. I'm giving the full version for extra information - the--root-directory
parameter defaults to/
.This command will reinstall the boot loader on /dev/sda, telling it to look in the "root-directory" parameter (/boot/grub) for grub.cfg. If you wanted your grub.cfg to be in a different distro, you can mount it and specify a different "root-directory", such as, for example,
/mnt/my_other_distro/
if it were mounted in/mnt/my_other_distro
.Let me know if you have problems while I drink my coffee. :)
Edit: (after coffee) I see now one important problem... you should have changed the UUID for sda1, not sda7. Then, when you installed Mint onto sda1, it would change it anyway if you reformat, but if you didn't change it, it might get confused. By changing the UUID for the old Ubuntu installation, you invalidated all the mount settings in its /etc/fstab, along with the GRUB menu. I assume Mint doesn't regenerate the menu, but only copies the entries, so it doesn't care whether it's correct or not.
Running update-grub corrects grub.cfg, but not the grub code in the MBR; this is changed only using grub-install.
And Linux Mint doesn't know what the entries in grub.cfg actually mean, as it may refer to a drive that isn't even present right then. It simply adds the new entry to the top of the existing ones, I think.