[clug] Struggling to change boot drive and root partition

Tony Lewis tony at lewistribe.com
Mon Mar 25 04:09:20 UTC 2024


Hi all,

I'm changing out some hard disks, and as part of that, I need to move 
the root partition.  I am struggling to get it to boot into the right 
partition.

What I've done (numerous times back and forth):

  * installed GRUB on all disks, both existing and new (grub-install
    /dev/sdX)
  * created the new root partition on LVM (lvcreate) and mounted it
    (mount /dev/mapper/... /mnt/root)
  * rsynced the root partition to the new partition (rsync -x) (only
    done once, otherwise I wipe over the new /etc/fstab(
  * mounted /proc, /sys and /dev into the new partition using --rbind
    for sys and --bind for proc and dev
  * created a new /boot LVM partition (lvcreate) and copied the existing
    /boot contents to it (except /boot/efi)
  * created small EFI partitions on each of the new disks, and copied
    the contents of /boot/efi there
  * chrooted to /mnt/root
  * edited /etc/fstab with new /boot and /boot/efi locations
  * run update-initramfs -k all -u
  * run update-grub
  * verified that the '--fs-uuid'-ish parts of /boot/grub/grub.cfg point
    to the new location (matching UUIDs)
  * unchrooted, unmounted everyting
  * rebooted

When I reboot, I use the BOIS boot menu to select one of the new disks.  
It has GRUB.  But when it boots, it uses the grub.cfg from the old 
disks, and so boots into the old instance.

Where have I gone wrong?

My only other thing I can try is to try booting with the old disks 
disconnected.  This might help if GRUB is opportunistic and finds the 
first /boot partition it can.  But doing that involves screwdrivers and 
getting on hands and knees, and I also think it shouldn't need to be.  I 
think I'm missing something that tells GRUB which /boot partition I want 
it to boot from.

Actually, thinking on the fly, does it matter if I grub-install from 
within the chrooted environment or not?  I assumed it didn't and that 
the GRUB bootloader installed was the same regardless of where I ran it 
from, but maybe not?

Any clues, please?

Thanks,

Tony



More information about the linux mailing list