[SOLVED] How do I "migrate" grub to a new hard disk?
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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.
I think you will be fine as long as the grub.cfg is updated as well.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.