• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

Script to label multiple disks in Solaris

by admin

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@w20230080e517e28c,1f (ssd2): 

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 ......

Filed Under: Solaris

Some more articles you might also be interested in …

  1. How to configure passwordless ssh in Solaris
  2. Performing Network Diagnostics in Solaris 11 with “network-monitor”
  3. How To Determine Approximate Solaris Crash Dump File Size Requirements
  4. How to Kill Zombie (Defunct) Process in Solaris
  5. M4000 / M5000 : How to assign IP address to XSCFU
  6. Howto Verify If a Bootblk is Installed on the Boot Disk (SPARC)
  7. Script to reset the iostat errors counters (hard/soft/trn) without reboot
  8. How to add swap file in Solaris
  9. How to replace a disk under ZFS in Solaris
  10. Beginners Guide to Solaris 11 Image Packaging System (IPS)

You May Also Like

Primary Sidebar

Recent Posts

  • qm Command Examples in Linux
  • qm wait Command Examples in Linux
  • qm start Command Examples in Linux
  • qm snapshot Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright