Saturday, March 21, 2009

Reviving the grub in the rsync's Backup Disk

Incremental backup with rsync is very effective for daily backup.
However, it cannot be used to boot the system after failure.

This is because the disk is just simply a storage without capability to boot the Linux.
In order to make it bootable, the boot loader has to be installed back.

Assuming the grub should be installed into MBR, the steps would be:

1. Boot the system with rescue CD

2. Invoke the following command:

# mount /dev/sda1 /mnt/ # Assuming the main disk resides on single partition
# mount –t proc none /mnt/proc
# mount –o bind /dev /mnt/dev
# chroot /mnt/ /bin/bash
# grub
At grub:
grub> root (hd0,1)
grub> setup (hd0)
grub> quit

3. Check (and adjust if necessary) the config files like menu.lst, device.map, fstab, and mtab.

4. If needed, run: "grub-install --recheck --root-directory=/mnt /dev/sda"

Still cannot boot?
Well, be happy with dd and just troubleshoot the MBR of your disk:
# dd if=/dev/sda count=1 bs=512 | xxd