Setting the vtoc on multiple disks in Solaris

You know how it is, you get a rack of storage which you’ve turned into multiple identical  LUNs. Then you need to feed these to  ASM, which requires you to start your partitions at cylinder > 0

Firstly you need to make sure all of your disks have a valid label. You can do this either by manually selecting each disk you need to label in format and answering ‘yes’ when prompted, or you could create a command file to feed into format.

The file should list the disk number (from format) and issue the command to label the disk

disk 12
disk 14
disk 72

I have a simple script to generate this file, but it does assume you have something distinctive about the disks so you can grep them out of the format output. In this case it is all the devices on c26, but it could be something like the cylinder count or disk manufacturer.

# Generate disk list and label command for format
# creates a file called mylabel.cmd
# Assumes that you have something distinctive about the disks to be labelled
# e.g controller number (c26)
# feed the output file from this (after review) to format
# format -f mylabel.cmd
for i in `echo "quit" |format 2>&1 | grep c26 | awk -f. '{print $1}'|sed 's/\(.*\)./\1/'`
        echo "disk $i" >> mylabel.cmd
        echo "label" >> mylabel.cmd

You then take this file (after reviewing it – don’t go labelling the wrong disks!)  and feed it into format

# format -f mylabel.cmd

Use format to partition your first disk (in this example /dev/rdsk/c0t0d0s2) and then use fmthard to put this partition onto another disk.

# prtvtoc /dev/rdsk/c0t0d0s2 | fmthard -s - /dev/rdsk/c0t1d0s2

Wrap it up in while loop and you can have your entire rack setup with the correct vtoc in seconds.


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