Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to make alternate system disk in linux 1

Status
Not open for further replies.

herzel

IS-IT--Management
Mar 5, 2003
73
IL
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
 
herzel said:
My Linux machine is based on vmware and the problem with the script is seems to be with the mkinitrd line!

How do you know that? Is there an error message? If so, what is it?

Annihilannic.
 
Thank you very much annihilannic for just asking the question.
I did duplicate the vm machine made some checks not sure what solved the problem but now the script is working.

Regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top