5

I run Debian Wheezy alone on my PC and I recently copied the root partition to another with rsync as I found that worked well (I also know about dd and ddrescue but they leave unusable space on the new partition). I generated a new random UUID for the new partition with sudo tune2fs -U random /dev/hda9 and also updated fstab / and /home entries.

Then as I know so little about GRUB I used a gui (GRUB Customizer) to probe for the new OS and add an entry to GRUB and the MBR -it makes an /etc/grub.d entry then updates GRUB.

On startup, the GRUB list contains the new OS (on sda9) but it boots the first OS (which I copied from -sda5).

/boot/grub/grub.cfg contains the new debian OS but it looks like this

set root='(hd0,msdos9)'  
search --no-floppy --fs-uuid --set=root 64662470-0e58-4dfd-90ac-43227d773556  
linux /boot/vmlinuz-3.2.0-2-amd64 root=UUID=cc3bca0d-aee4-4b9c-95c2-57212cc36d4d ro quiet  
initrd /boot/initrd.img-3.2.0-2-amd64

the 1st uuid is of sda9, but the 2nd uuid there is of sda5. I can change the 2nd uuid at startup (with E) and it boots sda9.
So how can I get grub.cfg corrected so that the sda9 GRUB list entry boots from sda9 permanently?

4

Just edit /boot/grub/grub.cfg/ and replace sda5's UUID with sda9's:

search --no-floppy --fs-uuid --set=root 64662470-0e58-4dfd-90ac-43227d773556  
linux /boot/vmlinuz-3.2.0-2-amd64 root=UUID=64662470-0e58-4dfd-90ac-43227d773556 

To avoid this type of error in the future run update-grub from the system you want to be using. If you run it from the old OS, it will pick up the current root partition and set grub.cfg to boot from that.

  • and if I edit grub.cfg what will stop the 2nd uuid reverting to what it was before when a GRUB update is made? (as I know it will, I tried that) – mozerella Oct 10 '12 at 9:57
  • @mozerella, Did you run update-grub from the sda9 system or the sda5? – terdon Oct 10 '12 at 10:03
  • from sda5, actually – mozerella Oct 10 '12 at 10:54
  • @mozerella, try running it again but when you have booted into the sda9 OS. – terdon Oct 10 '12 at 11:16
  • I've just realised! the OS on sda9 has its own grub.cfg file, so I needed to run update-grub from the OS on sda9. so thanks for pointing that out, shall I answer the Q? – mozerella Oct 10 '12 at 11:17
1

When you run update-grub from sda5 it reads the /boot/grub/grub.cfg from sda9 which was copied from sda5. First boot into sda5 which is your primary OS. Then use these commands to fix:

SourceUUID=cc3bca0d-aee4-4b9c-95c2-57212cc36d4d
TargetUUID=64662470-0e58-4dfd-90ac-43227d773556
sudo mkdir /mnt/clone
sudo mount -t auto -v /dev/sda9 /mnt/clone
sudo sed -i "s/$SourceUUID/$TargetUUID/g" /mnt/clone/boot/grub/grub.cfg
sudo update-grub
sudo umount /mnt/clone -l

I based this answer on a Ubuntu 16.04 LTS clone to new partition script.

0

I had to remove /boot/grub/menu.lst (you should cp a backup first) and then update-grub saying yes to generating a new one. It then detected the correct partition UUID to boot from.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.