Friday, July 24, 2009

fmthard command

Labeling Multiple Disks for Use With Volume Manager Software

Donald S. Ragbirsingh, April 2007


Introduction

Typically, an admin has to add many disks to production systems. This tip provides a time-saving procedure for labeling multiple disks for use with volume manager software. If you do the procedure appropriately, you can cut down disaster recovery times. The procedure works with all versions of the Solaris Operating System that use VERITAS Volume Manager (VxVM) software as the main disk management utility.

Caution: Be sure you use this procedure appropriately or you might cause undesirable consequences. For example, if your boot disk is c1t2d0 and it has no mirroring, and you mistakenly include the boot disk when performing step 3, the server crashes. You must know which of your disks are expendable disks before performing this procedure.

I usually work with EMC, CLARiiON and STK type disks, but this procedure works with any type of disk. Most EMC/CLARiiON and STK disks need to be labeled before use. (Editor's note: STK is short for StorageTek, now part of Sun Microsystems.)


Step 1

Create a command file (for example, format.cmd) for the format utility, and add the following content to the file:

label
quit

At the command line, write a label on the disk using the format.cmd file, for example:

# format -s -f format.cmd c3t21d14

Repeat this step, as required, using a script if necessary:

for i in 15 16 17 18 19 20
do
format -s -f format.cmd c3t21d$i
echo "labeled c3t21d$i ..."
done

Step 2

Use one of the new disks to create a prepared disk for VxVM, that is, zero out all the partitions except slice 2. Note: This means you have to manually do one disk, for example, c3t21d5.

Save the Volume Table of Contents (VTOC) of this disk (in this example, c3t21d5) as a file:

# prtvtoc /dev/rdsk/c3t21d5s2 > master_vtoc

Step 3

Copy the VTOC to a destination disk, for example, c3t21d6.

# fmthard -s /tmp/master_vtoc /dev/rdsk/c3t21d6s2
fmthard: New volume table of contents now in place.

Repeat this step, as required, using a script if necessary:

for i in 14 15 16 17 18 19 20 21
do
fmthard -s /tmp/master_vtoc /dev/rdsk/c3t21d$i
echo "Re-partitioned c3t21d$i ..."
done

Try to avoid recalling backup tapes, that is, do not make mistakes!

As an offshoot of this procedure, you can issue the following devastatingly simple, one-line command instead of using the VTOC file. However, the choice is up to you.

prtvtoc /dev/rdsk/c3t21d5s2 | fmthard -s - /dev/rdsk/c3t21d13s2

Conclusion

The uses of this procedure are myriad. For example, if you wanted to add an SVM mirror, you could take the boot device (c1t0d0 mirrored to c1t1d0) and copy the boot VTOC to the target c1t1d0 as follows:

prtvtoc /dev/rdsk/c1t0d0s2 | fmthard -s - /dev/rdsk/c1t1d0s2

Then it's trivial to start the mirroring process.

You can add also spares, but I'd like to save that process for another tip.


About the Author

Donald Ragbirsingh works for his own company, Opentech Systems Inc. He has been involved in IT in the banking, insurance, and telecommunications industries for over 10 years in Canada.

SunSolve Solution 202396 : How to use fmthard to duplicate the "vtoc" of a hard disk