Linux - Software This 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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
|
05-25-2015, 07:17 AM
|
#1
|
Senior Member
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,537
Rep:
|
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?
|
|
|
05-25-2015, 07:59 AM
|
#2
|
Senior Member
Registered: Dec 2014
Location: London, England
Distribution: Debian stable (and OpenBSD-current)
Posts: 1,187
|
Quote:
Originally Posted by lucmove
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.
From Debian:
Code:
# grub-install /dev/sda
# update-grub
This is presuming you are using a non-EFI system.
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.
Last edited by Head_on_a_Stick; 05-25-2015 at 08:17 AM.
|
|
|
05-25-2015, 08:01 AM
|
#3
|
LQ Veteran
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,286
|
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:
Last edited by syg00; 05-25-2015 at 08:41 AM.
|
|
2 members found this post helpful.
|
06-04-2015, 08:41 AM
|
#4
|
Senior Member
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,537
Original Poster
Rep:
|
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 /
Last edited by lucmove; 06-04-2015 at 08:42 AM.
|
|
|
06-04-2015, 08:47 AM
|
#5
|
Moderator
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
|
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.
|
|
1 members found this post helpful.
|
06-04-2015, 08:56 AM
|
#6
|
Senior Member
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,537
Original Poster
Rep:
|
How do I bind-mount?
|
|
|
06-04-2015, 10:06 AM
|
#7
|
LQ Guru
Registered: Sep 2011
Location: Upper Hale, Surrey/Hants Border, UK
Distribution: One main distro, & some smaller ones casually.
Posts: 5,709
Rep:
|
|
|
|
06-04-2015, 10:06 AM
|
#8
|
Moderator
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
|
In your case:
Code:
mount /dev/sda2 /mnt
mount --bind /dev /mnt/dev
mount --bind /sys /mnt/sys
mount --bind /proc /mnt/proc
Then chroot into the new system, do your Grub stuff, exit the chroot and do it in reverse to unmount all that:
Code:
umount /mnt/{dev,proc,sys}
umount /mnt
|
|
1 members found this post helpful.
|
All times are GMT -5. The time now is 09:17 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|