Script to label multiple disks in Solaris

Many a times when storage team allocates storage from a EMC storage box, the disks are not labeled. Due to this you would see errors in the /var/adm/messages file like:
Jan 31 16:50:48 geeklab Corrupt label; wrong magic number
Jan 31 16:50:48 geeklab scsi: [ID 583861 kern.info] ssd12 at fp5: unit-address w20220080e517e28c,1: e8
Jan 31 16:50:48 geeklab genunix: [ID 936769 kern.info] ssd12 is /pci@12,600000/SUNW,qlc@0/fp@0,0/ssd@w20220080e517e28c,1
Jan 31 16:50:49 geeklab scsi: [ID 583861 kern.info] ssd8 at fp5: unit-address w20220080e517e28c,0: e8
Jan 31 16:50:49 geeklab genunix: [ID 936769 kern.info] ssd8 is /pci@12,600000/SUNW,qlc@0/fp@0,0/ssd@w20220080e517e28c,0
Jan 31 16:50:49 geeklab scsi: [ID 583861 kern.info] ssd2 at fp6: unit-address w20230080e517e28c,1f: e0
Jan 31 16:50:49 geeklab genunix: [ID 936769 kern.info] ssd2 is /pci@13,700000/SUNW,qlc@0/fp@0,0/ssd@w20230080e517e28c,1f
Jan 31 16:50:50 geeklab scsi: [ID 107833 kern.warning] WARNING: /pci@13,700000/SUNW,qlc@0/fp@0,0/ssd@w20230080e5
 
 
Now the easiest solution to this is to labels the disk in format command :
# format --> Select disk -> select partition table (p) --> label the disk (l)
Easy right ! But imagine a case when you have hundreds of disks to be labeled. In that case, we have a pretty neat script that can label all the disks in a go.

The script consists of :
1. a file containing format subcommands : label and quit
2. a file having all the disks you want to label.
3. the script itself
1. The format sub commands should be written in a separate file :
# cat /tmp/format.cmd
label

quit
2. Create a file listing all the disks you want to format.
# cat /tmp/disk_list
c8t2d0
c8t3d0
c8t4d0
3. Now finally the main script itself : /tmp/disk_label.sh . The script loops through all the disks in /tmp/disk_list and labels them one by one.
# cat disk_label.sh
for disk in `cat /tmp/disk_list` 

do
  
 format -s -f /tmp/format.cmd $disk
  
 echo "labeled $disk ....."

done

Running the script

Running the script is pretty easy. Just run the script without passing any arguments and all the disks will get labeled in no time.
# chmod +x /tmp/disk_label.sh
# ./disk_label.sh
Labeled c8t2d0 ......
Labeled c8t3d0 ......
Labeled c8t4d0 ......

 

Comments

Popular posts from this blog

Understanding How ZFS Calculates Used Space

Restart autosys agent

How To Verify Remote System Controller (RSC) is Configured and Current on Sun Fire[TM] 280R/V480/V490/V880/V890 servers