rsync & grub - clarification

Lennart Sorensen lsorense-1wCw9BSqJbv44Nm34jS7GywD8/FfD2ys at public.gmane.org
Mon Apr 25 16:16:55 UTC 2005


On Sun, Apr 24, 2005 at 06:24:17PM -0400, Fraser Campbell wrote:
> On April 13, 2005 07:15 am, Alan Cohen wrote:
> 
> > Clarification:
> > If I ever DO have to use the backup (because the "main" IDE goes bad),
> > the IDE disk in the USB enclosure (/dev/sda while in the USB enclosure)
> > will be removed and placed in the main box thus becoming /dev/hda !  So,
> > what I need to do is to insure that it will be bootable as a regular IDE
> > disk when that happens.
> 
> I expect (especially since you use grub) that you might be able to just 
> duplicate the MBR. Wild guess:
> 
>   dd bs=512 count=1 < /dev/hda > /dev/sda

Only valid if you also cloned the partitions from one to the other (bit
for bit), since grub does hardcode the location of stage2 when
installing stage1.  use grub-install /dev/sda --root-directory
/mnt/to/sda/root/partition

> To make it clear that this is a wild guess let me mention some concerns ;-)
> 
> - no idea if 512 bytes is correct size
> - due to above, could destroy data on removable IDE
> - removable drive geometry may have to be the same (or similar) to fixed drive

If grub is installed with the right --root-directory and possibly a
device.map file that tells it the disk it is installing on is going to
be disk0 when used it is fine.

For example:
echo "Installing grub to sda1.."
chroot /mnt bash -c "echo '/dev/sda1 / ext3 rw 0 0' >> /etc/mtab"
chroot /mnt bash -c "echo '(hd0)        /dev/sda' > /boot/grub/device.map"
chroot /mnt bash -c "grub-install /dev/sda"
chroot /mnt bash -c "echo '(hd0)        /dev/hda' > /boot/grub/device.map"

This assumes the new drive is mounted as /mnt and is partition 1.

It works by faking the mount so inside chroot grub things /dev/sda1 is
mounted as /
It thinks sda is hd0
It installs to the MBR of sda
It is then updated to know hda is hd0 (as it will be on the system if it
is booted as an ide disk).

Lennart Sorensen
--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list