Last active
December 7, 2016 12:17
-
-
Save prestelpirate/622961ee119a8bd0dc7b58c8d2544054 to your computer and use it in GitHub Desktop.
While IRIX comes with the XLV volume manager, the license to mirror (plex) your volumes is an expensive extra. This script allows you to clone the root disk, creating a bootable spare which is not normally mounted, allowing easy root disk recovery.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/ksh | |
# | |
# See http://www.gaeltd.com/scripts-and-tools/ for more details | |
# | |
# 2004-09-15 Tom Kranz <tom@siliconbunny.com> | |
# | |
# Script to clone root disk | |
# Run this from cron nightly when things are quiet to keep so you have a | |
# reasonably up to date bootable clone of your root partition | |
# | |
# Assumptions: | |
# - root is dks0d1s0 | |
# - cloner is dks0d2s0 | |
# - cloner's s0 is *at least* as big as root's | |
# | |
# DON'T JUST RELY ON THIS SCRIPT TO WORK! TEST BOOTING FROM YOUR CLONED | |
# ROOT DRIVE ON A REGULAR BASIS! | |
# Some vars | |
# Change as appropriate if your disk paths etc. are different | |
SOURCE=dks0d1s0 | |
DEST=dks0d2s0 | |
DISKTREE=/dev/dsk | |
MNTPOINT=/clone | |
SOURCEVH=/dev/rdsk/dks0d1vh | |
DESTVH=/dev/rdsk/dks0d2vh | |
# Just in case any cruft survives, we will make a new fs on the clone | |
# each time | |
echo "Making new fs on ${DEST}" | |
mkfs -b size=4096 ${DISKTREE}/${DEST} | |
# We need somewhere to mount it | |
if [ ! -d ${MNTPOINT} ] | |
then | |
echo "" | |
echo "Making mount dir for clone disk" | |
mkdir ${MNTPOINT} && echo "Created ${MNTPOINT}" | |
fi | |
# Now we mount | |
mount ${DISKTREE}/${DEST} ${MNTPOINT} && echo "Successfully mounted ${DEST}" | |
# Start our xfsdump/xfsrestore joy | |
cd ${MNTPOINT} | |
echo "Starting clone operation" | |
xfsdump -l 0 -p 5 - / | xfsrestore - . | |
# Umount our clone | |
cd / | |
umount ${MNTPOINT} && echo "Unmounted ${DEST}" | |
# Copying volume headers | |
cd /stand | |
dvhtool -v get sash sash ${SOURCEVH} | |
dvhtool -v get ide ide ${SOURCEVH} | |
dvhtool -v creat sash sash ${DESTVH} | |
dvhtool -v creat ide ide ${DESTVH} | |
dvhtool -v get symmon symmon ${SOURCEVH} | |
dvhtool -v create symmon symmon ${DESTVH} | |
# Done | |
echo "Clone operation finished" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment