Guide to cloning a SUN Blade 1000 drive running Solaris 8 on a second drive
1. Introduction
2. Script to backup a drive '0' to to a second identical drive '1' using ufsdump
3. Checking that the cloned disk can boot the computer
4. Mirroring a boot disk to a second disk
1. Introduction
Copying (cloning) one disk to another is discussed at SUN Docs, in the System Administration manual Volume 1. If you use 'dd' on the whole disk, then the boot blocks which are on it will be copied. You don't need to installboot as a separate step later. If you go the somewhat safer method of repartitioning/ufsdump/ufsrestore, then the boot blocks (which are not a part of the filesystem) must be reinstalled on the new disk.
-
'dd' is the easiest way but it only works if you do not have any read errors on the original disk and the disk is not being used for any other purpose and is in single-user mode. Also, if the new disk is larger than the old the extra capacity will be wasted. Install the new disk for example as SCSI id 2. Then assuming the original disk is SCSI id 0 do dd if=/dev/rdsk/c0t0d0s2 of=/dev/rdsk/c0t2d0s2 bs=2048k (Maybe there should be a space between bs and =2048k). Remove the old disk set the SCSI id of the new one to that of the old one (0) and boot. This procedure will create a exact copy including boot blocks of the old one. or Yes, exactly. I did this a year before. Easiest with dd if you have another disk with the same geometry, or with dump/restore or tar or whatever you like. If the disks are of the same type (and size), the easiest way to clone them is to get into single user mode, and with the new disk unmounted key in: dd if=/dev/dsk/c0t0d0s2 of=/dev/dsk/c0t1d0s2 bs=1024k where c0t0d0s2 is your input disk and c0t1d0s2 is your output disk. Note that we're using slice 2 (whole disk) and will copy vtoc also. After all is done you will probably need to fsck /dev/dsk/c0t1d0s2, this is normal, will only need to be done once, and goes very quickly. However, the dd method will copy over the Solaris label which contains a list bad blocks. By eliminating the correct list from your target disk, you could introduce problems. > Does this process work for Root disks that have been encapsulated by > Veritas? If not how would that be done? Depends on what you mean by "works". Yes it will copy the disk, but it will copy the veritas private region too. That's not recommended because it contains a "serial number" to tell veritas which disk it is. When that is duplicated, Veritas doesn't know which disk is which. If you use the 'dd' method, then I would recommend a post-process step of deleting the veritas private region. Either dd over the data in the slice, or use prtvtoc/fmthard on the disk and remove the veritas public and private region slices. If you've already encapsulated root with veritas, then a root mirror is trivial.
-
Snapshot You can use the 'fssnap' command to create a read-only snapshot of a file system in Solaris 8. A snapshot is a file system's temporary image that is intended for backup operations.
-
flarcreate in Solaris 8 can make a 'Web Start Flash Archive', which is an exact image of a disk with all of its partitions including boot sectors etc., so that it can be restored later to a new disk in case of failure, or clone to another identical computer.
-
Use software from a third party
-
Amanda uses a variety of methods, which can be configured to backup your system, and which supports networked backups as well. There is useful advice on setting it up.
-
Legato Networker.
-
Tivoli Storage Manager.
-
Veritas Netbackup
-
-
ufsdump | ufsrestore is probably the best way to create an identical copy of a disk.
I used the following steps to backup one drive to a second identical one (going from memory)
1) use prtvtoc and fmthard to partition the second disk
2) newfs the slices on the second disk
3) mount up the root slice of the second disk under /mnt
4) cd /mnt;ufsdump of - / | ufsrestore rf -
5) sed < /mnt/etc/vfstab -e s/c0t3d0/c0t1d0/g > /tmp/vfstab.new
6) mv /tmp/vfstab.new /mnt/etc/vfstab
7) cd /;umount /mnt
8) continue to mount up each remaining slice and copy the data to it.
9) I would also fsck each slice on the new disk just to make sure everything is ok.
10) run installboot on the new disk to create the boot blocks
Once you've done this you can do a "boot disk1" from the ok prompt. This method saved my "tech lead's" butt once. Boot off of the second internal (cold backup) disk and the server was back up again. Dupe the disk1 back to disk3 and reboot later in the evening. I am never going to let him live down that mistake!
2. Script to backup a drive '0' to to a second identical drive '1' using ufsdump
There are two scripts to chose from:
(a)
!/bin/sh
# Original Script written by Constantin Ionescu Modified by Carlo Cosolo
# Modified by Peter Baer Galvin Modified by John West Use and distribute
# freely Define variables for use in the script
# ! Important, these must be set correctly !
# The root disk to duplicate (leave off slice numbers and path)
SRC=c0t0d0
# The empty disk to duplicate it to (leave off slice numbers and path)
DEST=c0t1d0
#The directory to mount destination partitions on while duplicating
MOUNTDIR=/dup_0
#The file name of this script, to rename it on the destination to avoid
execution SCRIPT=/opt/local/etc/rootcopy
# The slices that should be copied
SLICES="s0 s3 s4 s6 s7"
echo ==================================== echo Disk Copy script started
`date` echo
#Make sure the mount point for duplicate partitions exists if [ ! -d
$MOUNTDIR ]; then mkdir $MOUNTDIR chmod 700 $MOUNTDIR fi
# Partition the duplicate disk, make filesystems, make it bootable
prtvtoc /dev/rdsk/${SRC}s2 > /tmp/vtoc fmthard -s /tmp/vtoc
/dev/rdsk/${DEST}s2 installboot /usr/platform/`uname
-i`/lib/fs/ufs/bootblk /dev/rdsk/${DEST}s0
# Modify the following loop to handle any special cases
for fs in $SLICES do newfs /dev/dsk/${DEST}${fs} < /dev/null mount
/dev/dsk/${DEST}${fs} ${MOUNTDIR}; ufsdump 0f - /dev/dsk/${SRC}${fs}|(cd
${MOUNTDIR} ;ufsrestore rf -); if [ $fs = "s0" ]; then sed
's/${SRC}/${DEST}/g' /etc/vfstab > ${MOUNTDIR}/etc/vfstab; mv
${MOUNTDIR}/${SCRIPT} ${MOUNTDIR}/${SCRIPT}.DONTRUN; fi
umount ${MOUNTDIR} done
echo echo Disk Copy script ended `date` echo
==================================== echo
(b)
#!/bin/sh
# this script must be run in single user mode
# copy table of contents (partition information) from disk0 to disk1
prtvtoc /dev/dsk/c0t0d0s2 | fmthard -s - /dev/rdsk/c0t1d0s2
# install boot block on disk1 - With other computers alter 'sun4u' accordingly
/usr/sbin/installboot /usr/platform/sun4u/lib/fs/ufs/boot/bootblk /dev/rdsk/c0t1d0s0
# iterate over all slices (except swap & backup) dumping them from disk0
# to disk1
for slice in 0 3 5 6; do
new_raw=/dev/rdsk/c0t1d0s${slice};
new_d=/dev/dsk/c0t1d0s${slice}
new_mnt=/tmp/slice${slice}
old_raw=/dev/rdsk/c0t0d0s${slice}
# create new filesystem for current slice
newfs -v ${new_raw}
# make sure filesystem is fine
fsck ${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 (system files) then changed vfstab entries from disk0
# to disk1
if [ $slice -eq 0 ]
then
perl -pi -e 's/c0t0d0/c0t1d0/g' ${new_mnt}/etc/vfstab
fi
# unmount current slice
umount ${new_mnt}
# make sure slice is valid
fsck ${new_raw}
# cleanup directory
rmdir ${new_mnt}
done
Once this script is run and all has been copied to the other drive, you can boot the other drive via Openboot. No need to swap the drive to T0.
3. Checking that the cloned disk can boot the computer
You can choose which disc to boot from when two discs are installed.
It is done from the 'Open Boot Prompt' (OBP) which is kind of equivalent to BIOS on a pc (the code that's in nvram that does power on
self tests and loads the OS). See the OBP manuals that are part of the docset (available online at docs.sun.com). You can change open boot variables (such as whether to boot automatically and what disk to boot from) at the OBP or using "eeprom" in solaris (man eeprom for details).
Reboot the system and while the banner is printing before it loads the operating system hold the stop key while pressing 'a' (or if connected via some terminal to the console send a 'break'). Alternately you could use the "eeprom" command above to set "auto-boot?" to false and then reboot. You will have to be connected to the console (serial console or graphics console). Use "probe-scsi-all" to see what all the long paths are to the two disks and then use "devalias" to see/set an alias name (like "disk1" or "diska") to that device, then set "boot-device" to that alias.
4. Mirroring a boot disk to a second disk
'Mirroring' a boot disk to a second disk, is an excellent way to deal rapidly with a failed system disk. It can be combined with a remote backup resource, to provide a good quality backup and recovery process. Disk mirroring is best done with Solstice DiskSuite (SDS) v 4.2.1, which is a part of Solaris 8. In Solaris 9, it is called 'Volume Manager' (login and password: '4u2test'). There is a well written paper at Slacksite, giving details of how to mirror two drives with DiskSuite.
After installing SDS, apply the latest (March 2002) SDS patch (108693-08.zip) from SunSolve. A guide to setting it up is available. See also the 'DiskSuite' information at Sun: 'Solstice DiskSuite 4.2.1 Installation and Product Notes', 'Solstice DiskSuite User's Guide' and 'Solstice DiskSuite Reference'. Robert Banniza has a script to help with setting it up, that can also be found under Sun's 'BigAdmin Scripts' section.
Veritas' 'Volume Replicator' can also be purchased and used to mirror disks to identical or heterogeneous drives. 'Volume Replicator' is usually used on large disks and arrays, rather than the boot disk.
Disk mirroring
See the Sun Blueprint for mirroring and cloning root disks with
Veritas. To see if drives are mirrored run '/usr/sbin/metastat'.
To backup a drive install DiskSuite and mirror the drives. Once all synced,
unmirror.
Mirror a system disk to a second identical one Instead, mirror the disks with Solstice 'Disk Suite', which is included in Solaris 8. Wth the full 'OEM' install, it should be there. Try running 'solstice' from a root prompt. DiskSuite is designed to automatically maintain mirrored drives all the time, so a disk can fail and you
will not lose any work. In addition, disk reads will be faster because two disks are feeding the system in tandem.
You can also mirror a disk using DiskSuite, Veritas or a Hardware RAID controller.
Replacing a mirrored disk that has failed.
Be sure to have 2 or more metadb replicas on both disks (e.g. on c0t0d0s4 c0t0d0s5 c0t1d0s4 c0t1d0s5). Lets say, the second disk fails. Then reboot (you must go to single-user mode, because not more than 50% of your metadb replicas is online) Remove bad metadb replicas by typing: metadb -df c0t1d0s4 c0t1d0s5. 100% of your replica's is online again, you can reboot again for a normal-functioning system. Replace disk and add metadb replicas again.
> My guess is that I have to boot Solaris from a cd-rom, mount the disk and
> remove the mirror (on the drive that is working of course) and finally boot
> from the original mirror disk.
Good guess. You essentially have to break the mirror by getting the boot disk out of
DiskSuite. Detailed help can be found on http://sun.docs.com where you should search using keywords
"disksuite mirror failure". Also, here's a nugget of info from the following page
http://www.ebsinc.com/solaris/disksuit.html which is entitled "Ten common Solstice Disksuite questions" -
6. How do I remove the boot disk from DiskSuite control?
ok boot cdrom
# fsck /dev/rdsk/c0....
# mount /dev/dsk/c0t3d0s0 /a
Note: this assumes that your boot device is target three on
controller zero.
# vi /a/etc/system
comment [*] out entries pertaining to / being a metadevice
(rootdev:pseudo/md:0,blk)
# vi /a/etc/vfstab
change metadevice name to physical disk partition for all
file systems associated with booting
# mv /a/etc/opt/SUNWmd/etc/mddb.cf /a/etc/opt/SUNWmd/prob.mddb.cf
# umount /a
# fsck /dev/rdsk/c0t3d0s0
# reboot
Make certain that you're booting off c0t3d0s0 (i.e., the side you modified above), and not the other side of the mirror!
Upgrading Solaris with mirrored drives
Solaris CDs will not be able to upgrade mirrored drives running DiskSuite until the mirror has been uninstalled.
Return to the 'home page'
Return to the `Computing index page'
Return to the 'Blade 1000 administration index'