Note: This is not fully polished, but I think it has some useful tips when you’re trying to wrangle a mess of SAN disks. 

1. Discover the disks
# touch /reconfigure && reboot
# echo | format | awk ‘{ print $2 }’ | sort | grep c[56]t > SANDISKS
2. Label the disks
for DISK in `cat SANDISKS`; do
printf “label\nyes\nquit\n” | format -d $DISK
done

3. Figure out the size of the disks

We’ll grabbing slice 2 from the partition table. By convention in Solaris, partition2 holds the entire disk.
But be careful, it IS possible to over-write this information and you lose the true disk config.
Before running this command, it would be smart to run prtvtoc on all disks and check the bytes/sector.
Any disk where this is not the standard 512bytes/sector, will show the wrong size (adjust the 2048/1024 section). 
Typically this happens on the larger disks. 

The darker purple just prints the disk name and the partition table, then selects the disk size and disk geometry.
In the section in light purple, I group all the data onto one line and print only:
     * The disk name ($DISK) [field 1]
     * The tag  (tags show the partition “name” – unassigned/root/swap/var etc) [field 4]
     * The flag (0x00=RW, 0x01=non-mount, 0x10=RO) [field 5]
     * The SectorCount (which I convert to GB. Maybe you prefer to work with 10-digit numbers. The registers in my brain are too small). 

for DISK in `cat SANDISKS`; do
echo -n “$DISK:: \t “
prtvtoc /dev/rdsk/${DISK}s2 | egrep ” bytes|^[(space)|(tab)]*2″
done | paste – – – | sort -k 10 | \
awk ‘{ print $1, “\t”, “$4, $5, “Sector: ” $6 “\t”, $NF/2048/1024, “GB” }’ > PARTITIONS

4. Fix the partition table
When the disks are presented from the SAN array, they already have a sample partition table. And it is NOT the one I want. Blech. That just makes extra work for me since I want all my space in one slice – slice 0. So I have to figure out an automated way to put all space in slice 0 and also wipe all other slices (except for slice 2). 
Since slice2 shows the full disk, I’ll copy that to slice0. Then I’ll zero out all of the other slices.
Remember – It IS possible to overwrite the data in slice 0. This is NOT recommended, so do not include partition 2 in the list of partitions below.   

for DISK in `cat SANDISKS`; do 
  prtvtoc -s /dev/rdsk/${DISK}s2 | grep “^[(space)(tab)]*2″ | sed ‘s/2/0/1’  > DISK.prt 
  for SLICE in 1 3 4 5 6 7; do
      echo “$SLICE  0  00  0 0 0” >> DISK.prt 
  done 
cat DISK.prt  |  fmthard -s – /dev/rdsk/${DISK}s2
prtvtoc  -s  /dev/rdsk/${DISK}s2

done

This line  grabs slice 2, copies the values  to slice 0. Do replace (space) and (tab) with an actual space character and tab character. The sed line there replaces 2 (slice 2) with slice 0, but only the first time we see a ‘2’. 
This line  creates blank values for the other slices.
This line  writes the new partition table to the disk.
This line prints off the final partition table for the disk. 


Summary

The story so far …
* We have a list of disks in a file called SANDISKS and a list of partitions in a file PARTITIONS.
* We have labelled the disks (ie. created a partition table), put all space in slice 0 and wiped other partitions.

The next Step is plan how you’ll allocate the disks to the LDOMs and to format the partitions. 
If you’re not using LDOMs, you can tweak this step to just loop through the PARTITION file doing the newfs line.
Otherwise, edit the PARTITION file into a file with three columns: disk, partition name and OS mountpoint. 

# DISK                        Partition-Label     Mountpoint
c5t2342EAF23422d2    node1-root    /
c5t2342EAF23422d0    node1-data   /database
c5t2342EAF23422d1    node1-redo   /database/redo

while read DISK LABEL MOUNTPOINT; do
   echo -e “/dev/dsk/${DISK} /dev/rdsk/${DISK} $MOUNTPOINT \t ufs 2 nologging” >> /etc/vfstab
   echo y | newfs /dev/rdsk/${DISK}s0
  # Lots more needed here – creating the 

done < PARTITION

 

Advertisements