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

The Geek Diary

CONCEPTS | BASICS | HOWTO

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • Linux Services
    • VCS
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Interview Questions
  • 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 dynamically replace CPU/memory board (dynamic reconfiguration) on SunFire s6800/e12K/e15K/e25K
  2. Solaris : How to scan new storage LUNs (scsi/iscsi/fc/sas)
  3. How to configure Solaris 10 Link Based IPMP
  4. Solaris : How to run savecore manually while booted in single user from CDROM
  5. Solaris 11 : How to Verify Kernel Zone Support on a Host
  6. Solaris Zones : How To Change The Number Of CPUs Using Dynamic Resource Pools
  7. Managing boot environments in Solaris 11
  8. LDOMs troubleshooting : guest and control domains can not talk to each other but can talk with anyone else on the network
  9. Beginners Guide to Solaris 11 Image Packaging System (IPS)
  10. How to replace a disk under ZFS in Solaris

You May Also Like

Primary Sidebar

Recent Posts

  • How to set the default character set in MySQL and how to propagate it in a master-master replication scenario
  • “Connection reset by peer” – error while ssh into a CentOS/RHEL system with a specific user only
  • MySQL: how to figure out which session holds which table level or global read locks
  • Recommended Configuration of the MySQL Performance Schema
  • Archives
  • Contact Us
  • Copyright

© 2021 · The Geek Diary