Hi guys!
As I sometimes need to clone a root disk for backup purpose, I've read all your posts concerning this subject (e.g. viewtopic.php?t=8619 ) and tried to write my own script. The previous disk of the Indigo2 I'm using at work crashed, the only backup (bru) was done some 2 years ago and the file was corrupted. I had to reinstall everything from scratch: Irix, additional hardware, special software,...
The problem is that I don't know enough about shell scripts... . So, I've used foetz's one and modified it to include some options one could find usefull and - that's the most important part in my point of view - many comments to help beginners understand faster what the script does and geeks remember how to do it. I hope we'll all find here a reference for performing this cloning procedure.
Please feel free to use and modify it as your convenience. If you think some modifications would be usefull for many people, you can send me your script and I will try to include your improvements.
The following code will be updated with latest revisions when available (I hope so...).
last revision: 2006.09.09
foetz, thanks a lot for your help!
Raphaël[/b]
As I sometimes need to clone a root disk for backup purpose, I've read all your posts concerning this subject (e.g. viewtopic.php?t=8619 ) and tried to write my own script. The previous disk of the Indigo2 I'm using at work crashed, the only backup (bru) was done some 2 years ago and the file was corrupted. I had to reinstall everything from scratch: Irix, additional hardware, special software,...
The problem is that I don't know enough about shell scripts... . So, I've used foetz's one and modified it to include some options one could find usefull and - that's the most important part in my point of view - many comments to help beginners understand faster what the script does and geeks remember how to do it. I hope we'll all find here a reference for performing this cloning procedure.
Please feel free to use and modify it as your convenience. If you think some modifications would be usefull for many people, you can send me your script and I will try to include your improvements.
The following code will be updated with latest revisions when available (I hope so...).
last revision: 2006.09.09
Code: Select all
#!/sbin/ksh
#
# auto xfs root disk duplicating
# IRIX 6.2 or higher
# 26.04.2000 by R-A-C
#
# modified by BetXen 2006.09.09
#
# for more informations, see http://forums.nekochan.net/viewtopic.php?p=87120
#
#
# LAST REVISION: 2006.09.09
#
#
# ************************
# * GENERAL INFORMATION: *
# ************************
#
# This script duplicates any xfs root disk onto another one using the
# xfsdump/xfsrestore method. The target disk doesn't need to be greater or
# equal in size than the source one. The free space should simply be big
# enough to contain all the data of the first disk.
#
# USAGE: scriptname (orig. disk cntrl) (orig. disk id) (target disk cntrl)...
# (target disk id)
# e.g. sgi_clone_root_disk 0 1 1 3 (will duplicate disk on scsi controller 0,
# device id1 onto target disk on scsi controller 1 (i.e. external disk),
# device id3)
#
# If you copy/paste this text in a text editor, don't forget to chmod the
# saved file to make it executable. Moreover, as it's a
# system task, it should only be executed by root:
# su
# chown root:0 ./<name_of_your_script>
# chmod a-x ./<name_of_your_script>
# chmod u+x ./<name_of_your_script>
#
# In order to be executed without the intervention of the user, the script
# doesn't ask you for choices (e.g. spacecheck or not). If you want to
# enable/disable it, please edit the script and uncomment/comment the
# dedicated lines.
#
# DON'T FORGET to partition the target disk as root drive at least once
# before running the script. If you don't know how to perform this, please
# follow these steps in your prefered shell:
# fx
# (enter)
# <your_disk_controller_number>
# <your_disk_drive_number>
# (enter)
# r
# ro
# (enter)
# yes
# ..
# l
# s
# a
# ..
# ..
# exi
#
export orig_cntrl=$1
export orig_drv=$2
export target_cntrl=$3
export target_drv=$4
clear
if [[ $# != 4 ]]; then
print "STOP! Bad number of arguments"
print "usage: scriptname (orig. disk cntrl) (orig. disk id) (target disk cntrl) (target disk id)"
print ""
print "example: sgi_clone_root_disk 0 1 1 3"
print ""
exit 1
elif [[ ${target_cntrl} = 0 && ${target_drv} = 1 ]]; then
print ""
print "STOP! Target drive is dks0d1..."
print "Isn't it your root drive?"
print "If you really want to do this, please edit the script..."
print ""
exit 1
elif [[ ${orig_cntrl} = ${target_cntrl} && ${orig_drv} = ${target_drv} ]]; then
print ""
print "STOP! Original disk same as target disk..."
print ""
exit 1
else
print ""
print "***************************"
print "* ... formatting disk ... *"
print "***************************"
print ""
mkfs /dev/rdsk/dks${target_cntrl}d${target_drv}s0
print ""
print "*************************"
print "* ... mounting disk ... *"
print "*************************"
print ""
mkdir /sgi_clone_dsk_tmp
mount /dev/dsk/dks${target_cntrl}d${target_drv}s0 /sgi_clone_dsk_tmp
# Uncomment the next lines if you want the script to inform you about available
# space on the destination disk. Would take time, but could be usefull if you
# have a smaller disk.
#
# print ""
# print "***********************************************************"
# print "* ... giving size infos (in terms of 1024-byte blocks)... *"
# print "***********************************************************"
# print ""
# print "Disk usage of /:"
# du -k -s /
# print ""
# print "Free space on target disk:"
# df -k /dev/dsk/dks${target_cntrl}d${target_drv}s0
# print ""
# print " PLEASE CHECK SPACE!"
# print " Sleeping 15 seconds to let you abort script..."
# sleep 15
print ""
print "************************************"
print "* ... duplicating data content ... *"
print "************************************"
print ""
print "Informations will be given every 30 seconds."
print ""
cd /sgi_clone_dsk_tmp
# If you don't want infos during the process, remove "-p 30" in the next line.
timex xfsdump -l 0 -p 30 - / | xfsrestore - .
print ""
print "*****************************"
print "* ... making boot stuff ... *"
print "*****************************"
print ""
cd /stand
dvhtool -v get sash sash /dev/rdsk/dks${orig_cntrl}d${orig_drv}vh
dvhtool -v get ide ide /dev/rdsk/dks${orig_cntrl}d${orig_drv}vh
dvhtool -v creat sash sash /dev/rdsk/dks${target_cntrl}d${target_drv}vh
dvhtool -v creat ide ide /dev/rdsk/dks${target_cntrl}d${target_drv}vh
# Uncomment the next lines if you plan to use this script as a backup one and
# to write a file containing the date and time on your disks' root folder.
# print ""
# print "***************************************************"
# print "* ... writing /_LAST_CLONE_.txt on both disks ... *"
# print "***************************************************"
# print ""
# echo "Last clone using sgi_clone_disk script made on " > /_LAST_CLONE_.txt
# date >> /_LAST_CLONE_.txt
# more /_LAST_CLONE_.txt > /sgi_clone_dsk_tmp/_LAST_CLONE_.txt
print ""
print "**********************"
print "* ... unmounting ... *"
print "**********************"
print ""
cd /
umount /sgi_clone_dsk_tmp
sleep 1
rm -rf /sgi_clone_dsk_tmp
print ""
print "****************"
print "* ... done ... *"
print "****************"
print ""
fi
exit 0
foetz, thanks a lot for your help!
Raphaël[/b]
: oxygen (4xR12k400) /
: neon (16xI2 1.6, 9MB L2) /
: beryllium (4xR12k270)
: nitrogen (R16k800) / : carbon (2xR14k600) / : lithium (R10k400) / : fluorine (2xR12k300) / spare 2xR12k360
: hydrogen (R10k195) / : sodium (R5k180) / : R5k180->200 MB and PM only
: helium (R10k195, HighImpact) / : boron (R4k250)/ : magnesium (R4k100) / : aluminium (R5k180)
4D70GT : my very first one (now property of musée bolo and the foundation mémoires informatiques )
See the hinv/gfxinfo posts here .
: nitrogen (R16k800) / : carbon (2xR14k600) / : lithium (R10k400) / : fluorine (2xR12k300) / spare 2xR12k360
: hydrogen (R10k195) / : sodium (R5k180) / : R5k180->200 MB and PM only
: helium (R10k195, HighImpact) / : boron (R4k250)/ : magnesium (R4k100) / : aluminium (R5k180)
4D70GT : my very first one (now property of musée bolo and the foundation mémoires informatiques )
See the hinv/gfxinfo posts here .