Cloning a disk in Solaris.

# SH 2004: This script must be run in single user mode!

# copy table of contents (partition information) from disk0 to disk1!!!
prtvtoc -h /dev/rdsk/c1t0d0s2 | fmthard -s – /dev/rdsk/c1t1d0s2

# install boot block on disk1 – don’t forget `uname -i` !!!
/usr/sbin/installboot /usr/platform/SUNW,Sun-Fire-V240/lib/fs/ufs/bootblk /dev/rdsk/c1t1d0s0

# iterate over all slices (except swap & backup) dumping them from disk0 to disk1

SLICES=”0 5 6 7″

for slice in $SLICES

# create new filesystem for current slice
newfs -v ${new_raw}

# make sure filesystem is fine
# fsck -y ${new_raw}

# create a directory for the mount point of the current slice
mkdir ${new_mnt}

# mount current slice
mount ${new_d} ${new_mnt}

# dump filesystem of current slice from disk0 to disk1
ufsdump 0f – ${old_raw} | (cd ${new_mnt}; ufsrestore xf -)

# if slice 0 the system files then change vfstab entries from disk0 to disk1
# if [ $slice -eq 0 ]
# then
# perl -pi -e ‘s/c1t0d0/c0t1d0/g’ ${new_mnt}/etc/vfstab
# fi

# unmount current slice
umount ${new_mnt}

# make sure slice is valid
# fsck -y ${new_raw}

# cleanup directory
rmdir ${new_mnt}


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s