Debian/Grub2: Moving root partition to new drive?

Mount basic filesystems and copy/modify files while chrooting like:

  • /dev (mount -o bind /dev/ /path/to/chroot/dev)
  • /proc (mount -t proc none /path/to/chroot/proc)
  • /sys (mount -t sysfs none /path/to/chroot/sys)

IIRC that worked for me while installing Grub 2 in arch and numerous times on Gentoo. Then after chroot to /path/to/chroot command was simply:

grub-install /dev/<boot_disk>

As of lvm2 (and I belive madm but I haven't used it) the configuration is stored on disk. There is configuration what should be read to discover devices. Assuming your devices are in standard locations (/dev/sd* or /dev/hd*) there should be no problem.


PS. I would not trust simple cp of live system as there are several places where it can go wrong:

  • Forgot to change /etc/fstab and other useful files
  • Files changed during access
  • Coping garbage (/tmp etc.)

you can install grub from live distro without chrooting:

grub-install /dev/hda --root-directory=/mnt/guest/

Tags:

Debian

Grub2