Tar Backup/Restore Grub Boot Issues

We have two machines with identical hardware. The second machine is a backup to the first machine to be used if any issues arise with the primary machine/service.
So we created a tar backup of the primary machine using:

#!/bin/bash
/bin/nice /bin/tar czpf /www/archive/backup/system/system_full.tar.gz \
–same-owner  \
–exclude=/proc/* –exclude=/media/* \
–exclude=/dev/* –exclude=/mnt/* –exclude=/sys/* –exclude=/tmp/* \
–exclude=/home/* –exclude=/var/backups/* –exclude=/var/lib/mysql/* \
–exclude=/var/www/* –exclude=/www/* / \
2>/var/log/system_backup_error.log

We could consid also exclude the /boot directory so as not to run in to boot problems on the second machine.
When we extracted this tar file onto the second machine and rebooted we encountered two issues which would need to be resolved  before the secondary backup machine could be used for the primary service:
1. Grub did not boot with the following error message
2. The network interfaces would not come up as the mac addresses were obviously different

GRUB PROBLEM
The error message we received when booting was:

filesystem type unknown partition type 0x8e

Type 0x8e represents an LVM partition but we need 0x83 ext2 filesystem.
Examining the /boot/grub/menu.lst config file we can see that Grub was trying to boot the following:

title CentOS (2.6.18-128.2.1.el5)
        root (hd0,1)
        kernel /vmlinuz-2.6.18-128.2.1.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
        initrd /initrd-2.6.18-128.2.1.el5.img

The problem was the “root (hd0,1)” line which should be “root (hd0,0)” on the secondary machine. On the first primary machine /dev/sda2 was mounted to /boot but on the secondary machine /dev/sda1 was mounted to /boot. So I am putting this issue down to slightly different partitioning during initial setup (even though we tried to get them completely mirrored I think there was some Sun FAT partitions left on the primary machine as /dev/sda1).

To resolve the issue temporarily from within Grub:

  • Go to the command line by typing ‘c’
  • Set the root device:
    root (hd0,0)
  • Boot
    boot

It is also possible to set the kernel and ramdisk as explained in this post:

  • Set the kernel
    kernel /vmlinuz[tab to find available kernels]
  • Set the ram disk
    initrd /initrd[tab to find available ram disks]
  • Boot
    boot

To resolve the boot issue permanently: 
After booting edit the menu.lst file:

vi /boot/grub/menu.lst

Replace root (hd0,1) with root (hd0,0)

NETWORK INTERFACES
When the secondary machine booted the interface configuration files in /etc/sysconfig/network-scripts contained the MAC addresses for the primary machine which did obviously not exist on the secondary machine. Red Hat/Centos thankfully backed up the existing config files with a .bak extension and created new ones with the correct mac addresses. So To keep the secondary machine as a potential backup to the primary machine I will create 2 sets of network config files with the relevant IP addresses and mac addresses.