How do I "migrate" grub to a new hard disk?
I have a hard disk with a few partitions: /boot is mounted on sda1 and / is mounted on sda3. The sda2 partition is currently not used.
Now I have a new hard disk with a considerably different layout. Among other things, / will be mounted on sda2. The new disk is installed as slave while I copy a lot of things over. After all the copying is finished, I predict the following conundrum: If I don't install grub on the new disk, it won't boot. If I install grub on it, grub will not only create a wrong entry (from assuming / on sda3), but probably also detect the two Linux installations and configure itself with both entries based on that. In good old grub, that would be fantastically straightforward. In stupid new grub, that is fantastically convoluted. Short of burning a rescue CD or pen drive that has the new grub, how can I accomplish that last step of the migration? |
Quote:
From Debian: Code:
# grub-install /dev/sda If you have problems, use the SuperGRUB2 rescue CD: http://www.supergrubdisk.org/ EDIT: Sorry, I hadn't thought that through properly -- syg00 is right. |
Simply chroot into the new disk when all the copying is done, then "grub-install /dev/sdb". Reboot, select the new disk in BIOS.
Edit: maybe we're both half right - I forgot the update-grub .... :shrug: |
I am finally ready for the move and... it didn't work.
root@luc:/# grub-install /dev/sdb sh: 1: /etc/default/grub: cannot create /dev/null: Permission denied Installing for i386-pc platform. /proc/devices: No entry for device-mapper found device node not found device node not found /proc/devices: No entry for device-mapper found device node not found grub-install: error: cannot find a GRUB drive for /dev/sdb2. Check your device.map. I ignored it, swapped the disks and rebooted, and got a "System missing" error message. Any other idea, please? Note: sdb1 = /boot sdb2 = / Although there is a full copy of /boot inside / |
Before you chroot into the new installation to install Grub, bind-mount /dev, /sys and /proc into it. Grub will have a hard time to install to /dev/sdb when there is no /dev/sdb in the chroot.
|
How do I bind-mount?
|
|
In your case:
Code:
mount /dev/sda2 /mnt Code:
umount /mnt/{dev,proc,sys} |
All times are GMT -5. The time now is 07:50 AM. |