[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Wheezy: making a bootable HD with Grub



Quoting Ldten K (ldtenk@yahoo.com):
> Need some help making bootable HD with Grub.
> 
> I have two HDs of the same size:
> 1. /dev/sda - my old and working HD which has grub properly installed,
> the system boots and works properly. /dev/sda has the following partitions:
>    /dev/sda1  /boot
>    /dev/sda2  /
>    /dev/sda3  swap
> 
> 2. /dev/sdb, my new HD, it has the same structure as /dev/sda:
> sdb1 (/boot), sdb2 (/) and sdb3 (swap), though the size of the
> partitions is slightly different. I want to transfer my data from
> sda to sdb (that part was done) and make sdb bootable. sdb will
> then be the only drive in the system.

> I ran "grub-install /dev/sdb" and it said that it completed without
> errors. The PC however fails to boot from the new drive, which was the
> only HD in the system at that time. After some delay the boot process
> drops me not even into the Grub CLI but into some "grub rescue>" CLI
> where even "help" command does not work. "ls" does work though.

> Any ideas as to what needs to be done to make sdb bootable just like
> sda is?

I used to do this many years ago when I was on dial-up to save
downloading stuff again.

(O) is the old system (still running), and (N) is the new.
After copying all the files (I used cpio), I would run
grub-mkconfig to update /boot/grub/grub.cfg (O) by probing for
the new system, and then grub-install /dev/sdX (O). The latter
shouldn't be necessary as the old disk will already have the MBR
pointing at /boot/grub/grub.cfg (O).

A possible next step is to check the LABELs or UUIDs of the new
partitions' filesystems depending on how you copied the old ones.
If you cloned them (eg, with dd), they need updating to make them
different.

Then I would mount the new root partition on, say, /mnt and edit
/mnt/etc/fstab for the future scenario, with the new LABELs or
UUIDs. (I was probably juggling /dev/sdXs back then.)

Next I would reboot into the new root partition. (This reboot
uses the old disk's MBR, of course, and also the old system's
updated /boot/grub/grub.cfg (O).)

Now I would run grub-mkconfig which rebuilds /boot/grub/grub.cfg (N)
making the new system the default, and probing the old one.
Then grub-install /dev/sdY (N) will make the MBR on the new disk
point to /boot/grub/grub.cfg (N).

The new disk should now be bootable. I would close down and put it in
its new box before booting it. Finally, I would reboot the old box,
and then rerun grub-mkconfig on both systems to make them each forget
the other one's disk that's just been removed.

Cheers,
David.


Reply to: