Hi
There are some decisions in our company to replace some old production Sprac machines with new Linux fast machines.
This action makes us to think how to recreate the script we have in Solaris that makes system disk duplication, an alt_disk backup of the system.
In case some patch or software configuration had gone bad we always switch to the backup disk that is either connected to the machine so we will not have down time.
I did with help of college write the following script.
#!/bin/bash
#Netanel Attali - EDS Tnuva 2008.
#ALT_DISK is the disk to which Grub will install the MBR. In other words, the disk from which the system will boot. (Not to be confused with the /boot partition)
ALT_DISK=/dev/sdd
ALT_BOOT=/dev/sdd1
ALT_ROOT=/dev/sdd2
ALT_SWAP=/dev/sdd3
ORG_BOOT=`awk '{print $1,$2}' /etc/fstab | grep /boot$ | awk '{print $1}'`
ORG_ROOT=`awk '{print $1,$2}' /etc/fstab | grep /$ | awk '{print $1}'`
ORG_SWAP=`awk '{print $1,$2}' /etc/fstab | grep swap$ | awk '{print $1}'`
umount /alt/{root,boot,tmp}
for I in $ALT_BOOT $ALT_ROOT ;do echo formatting $I ; mke2fs -j $I;done
mkswap $ALT_SWAP
mkdir -p /alt/{root,boot,tmp}
mount $ALT_ROOT /alt/root
mount $ALT_BOOT /alt/boot
mount
cd /alt/root ; dump -f - / | restore -r -f -
cd /alt/boot ; dump -f - /boot | restore -r -f -
grub-install --recheck --root-directory=/alt $ALT_DISK
sed "s:$ORG_BOOT:$ALT_BOOT:" /alt/root/etc/fstab > /alt/root/etc/fstab.tmp;mv -f /alt/root/etc/fstab.tmp /alt/root/etc/fstab
sed "s:$ORG_ROOT:$ALT_ROOT:" /alt/root/etc/fstab > /alt/root/etc/fstab.tmp;mv -f /alt/root/etc/fstab.tmp /alt/root/etc/fstab
sed "s:$ORG_SWAP:$ALT_SWAP:" /alt/root/etc/fstab > /alt/root/etc/fstab.tmp;mv -f /alt/root/etc/fstab.tmp /alt/root/etc/fstab
sed "s:$ORG_ROOT:$ALT_ROOT:" /alt/boot/grub/grub.conf > /alt/boot/grub/grub.conf.tmp;mv -f /alt/boot/grub/grub.conf.tmp /alt/boot/grub/grub.conf
mkinitrd -f --fstab=/alt/root/etc/fstab /alt/boot/initrd-`uname -r`.img `uname -r`
sync;sync;sync
cd;umount /alt/{root,boot}
Can anybody help us to debug the script and bring it to production?
My Linux machine is based on vmware and the problem with the script is seems to be with the mkinitrd line!
Any suggestion will be appreciated!
Thanks in advance
Herzel
There are some decisions in our company to replace some old production Sprac machines with new Linux fast machines.
This action makes us to think how to recreate the script we have in Solaris that makes system disk duplication, an alt_disk backup of the system.
In case some patch or software configuration had gone bad we always switch to the backup disk that is either connected to the machine so we will not have down time.
I did with help of college write the following script.
#!/bin/bash
#Netanel Attali - EDS Tnuva 2008.
#ALT_DISK is the disk to which Grub will install the MBR. In other words, the disk from which the system will boot. (Not to be confused with the /boot partition)
ALT_DISK=/dev/sdd
ALT_BOOT=/dev/sdd1
ALT_ROOT=/dev/sdd2
ALT_SWAP=/dev/sdd3
ORG_BOOT=`awk '{print $1,$2}' /etc/fstab | grep /boot$ | awk '{print $1}'`
ORG_ROOT=`awk '{print $1,$2}' /etc/fstab | grep /$ | awk '{print $1}'`
ORG_SWAP=`awk '{print $1,$2}' /etc/fstab | grep swap$ | awk '{print $1}'`
umount /alt/{root,boot,tmp}
for I in $ALT_BOOT $ALT_ROOT ;do echo formatting $I ; mke2fs -j $I;done
mkswap $ALT_SWAP
mkdir -p /alt/{root,boot,tmp}
mount $ALT_ROOT /alt/root
mount $ALT_BOOT /alt/boot
mount
cd /alt/root ; dump -f - / | restore -r -f -
cd /alt/boot ; dump -f - /boot | restore -r -f -
grub-install --recheck --root-directory=/alt $ALT_DISK
sed "s:$ORG_BOOT:$ALT_BOOT:" /alt/root/etc/fstab > /alt/root/etc/fstab.tmp;mv -f /alt/root/etc/fstab.tmp /alt/root/etc/fstab
sed "s:$ORG_ROOT:$ALT_ROOT:" /alt/root/etc/fstab > /alt/root/etc/fstab.tmp;mv -f /alt/root/etc/fstab.tmp /alt/root/etc/fstab
sed "s:$ORG_SWAP:$ALT_SWAP:" /alt/root/etc/fstab > /alt/root/etc/fstab.tmp;mv -f /alt/root/etc/fstab.tmp /alt/root/etc/fstab
sed "s:$ORG_ROOT:$ALT_ROOT:" /alt/boot/grub/grub.conf > /alt/boot/grub/grub.conf.tmp;mv -f /alt/boot/grub/grub.conf.tmp /alt/boot/grub/grub.conf
mkinitrd -f --fstab=/alt/root/etc/fstab /alt/boot/initrd-`uname -r`.img `uname -r`
sync;sync;sync
cd;umount /alt/{root,boot}
Can anybody help us to debug the script and bring it to production?
My Linux machine is based on vmware and the problem with the script is seems to be with the mkinitrd line!
Any suggestion will be appreciated!
Thanks in advance
Herzel