Sponsored Content
Full Discussion: Automatic disk labeling
Operating Systems Solaris Automatic disk labeling Post 302090410 by kwachtler on Monday 25th of September 2006 12:17:12 PM
Old 09-25-2006
Automatic disk labeling

First post Smilie ...
Here is a script for automatic labeling of previously unlabeled disks.
Other methods exist (format -f cmd_file), but I like this because it's all in one place.
Code:
#!/bin/ksh
#----------------------
# format_label
# Automatic labeling of previously unlabeled disks
# 2006.08.31 ken.wachtler
#----------------------
 
# Enter a list of disks, as format's banner would report them
Disks="
c4t50060482CCAB2987d27
c4t50060482CCAB2987d28
c4t50060482CCAB2987d29
c4t50060482CCAB2987d30
c4t50060482CCAB2987d31
c4t50060482CCAB2987d32
c4t50060482CCAB2987d33
c4t50060482CCAB2987d34
c4t50060482CCAB2987d35
c4t50060482CCAB2987d36
c4t50060482CCAB2987d37
c4t50060482CCAB2987d38
c4t50060482CCAB2987d39
c4t50060482CCAB2987d40
c4t50060482CCAB2987d41
c4t50060482CCAB2987d42
c4t50060482CCAB2987d43
c4t50060482CCAB2987d44
c4t50060482CCAB2987d45
c4t50060482CCAB2987d46
c4t50060482CCAB2987d47
c4t50060482CCAB2987d48
c4t50060482CCAB2987d49
c4t50060482CCAB2987d50
c4t50060482CCAB2987d51
c4t50060482CCAB2987d52
c4t50060482CCAB2987d53
c4t50060482CCAB2987d54
c4t50060482CCAB2987d55
c4t50060482CCAB2987d56
c4t50060482CCAB2987d57
c4t50060482CCAB2987d58
c4t50060482CCAB2987d59
c4t50060482CCAB2987d60
c4t50060482CCAB2987d61
c4t50060482CCAB2987d62
"
 
for d in $Disks ; do
 
  # write label
  printf "label\nyes\nquit\n" | format -d $d
 
  # check label
  printf "\n\n${d}\n\n"
  prtvtoc /dev/dsk/${d}s0 | egrep '^P  |^  '
  echo "<cr> to cont: "
  read a
 
done


Last edited by blowtorch; 09-25-2006 at 11:19 PM.. Reason: to add code tags
 

6 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Automatic monitor disk-space

Hello, I am trying to find a shell script to monitor diskspace. When the script encounteres a disk which above the treashold, I want an email notification. My system runs on a Sun Solaris. Is there anybode around who can help me with such a script? Norbert (3 Replies)
Discussion started by: nfbeerse
3 Replies

2. Filesystems, Disks and Memory

Automatic monitor disk-space

Hello, I am trying to find a shell script to monitor diskspace of all the directories in the server. When the script encounteres a disk which above the treashold, I want an email notification. My system runs on AIX. Is there anybody around who can help me with such a script? ... (3 Replies)
Discussion started by: anuradha
3 Replies

3. UNIX for Dummies Questions & Answers

Numerical Labeling using sed

Hi, I have been working on this problem, but could only get so far. I have a file that looks like this (cat,chimp,(((dog,cat,cow),orangutan),((horse,((cat,dog),(cow,pig))),cat,mouse,rat))); I would like after each instance of the word 'cat' to have an incrementing numerical label. I... (5 Replies)
Discussion started by: cavanac2
5 Replies

4. Solaris

Labeling VTOC

How to relabeling the disk VTOC if i relabel the disk the previous data is available or not (5 Replies)
Discussion started by: chandu.bezawada
5 Replies

5. Shell Programming and Scripting

PHP Labeling/Punctuation Syntax Question

Greetings! My first PHP question; and, no doubt, a "no-brainer" for the initiated :) The question centers around the proper syntax for input field labeling. The snippet which puzzles me (and the candidate which I wish to modify) goes like this:<?php _e('Hello World'); ?>:<br />What I'd like... (0 Replies)
Discussion started by: LinQ
0 Replies

6. Solaris

EFI disk labeling / understand the parition table / sectors not continue

Hi all, I have a EFI disk and it is use in zfs pool. partition> p Volume: rpool Current partition table (original): Total disk sectors available: 1172107117 + 16384 (reserved sectors) Part Tag Flag First Sector Size Last Sector 0 usr wm ... (8 Replies)
Discussion started by: javanoob
8 Replies
read_vtoc(3EXT) 					    Extended Library Functions						   read_vtoc(3EXT)

NAME
read_vtoc, write_vtoc - read and write a disk's VTOC SYNOPSIS
cc [ flag ... ] file ... -ladm [ library ... ] #include <sys/vtoc.h> int read_vtoc(int fd, struct vtoc *vtoc); int write_vtoc(int fd, struct vtoc *vtoc); int read_extvtoc(int fd, struct extvtoc *extvtoc); int write_extvtoc(int fd, struct extvtoc *extvtoc); DESCRIPTION
The read_vtoc() and read_extvtoc() functions return the VTOC (volume table of contents) structure that is stored on the disk associ- ated with the open file descriptor fd. On disks larger than 1 TB read_extvtoc() must be used. The write_vtoc() and write_extvtoc() function stores the VTOC structure on the disk associated with the open file descriptor fd. On disks larger then 1TB write_extvtoc() function must be used. The fd argument refers to any slice on a raw disk. RETURN VALUES
Upon successful completion, read_vtoc() and read_extvtoc() return a positive integer indicating the slice index associated with the open file descriptor. Otherwise, they return a negative integer indicating one of the following errors: VT_EIO An I/O error occurred. VT_ENOTSUP This operation is not supported on this disk. VT_ERROR An unknown error occurred. VT_OVERFLOW The caller attempted an operation that is illegal on the disk and may overflow the fields in the data structure. Upon successful completion, write_vtoc() and write_extvtoc() return 0. Otherwise, they return a negative integer indicating one of the fol- lowing errors: VT_EINVAL The VTOC contains an incorrect field. VT_EIO An I/O error occurred. VT_ENOTSUP This operation is not supported on this disk. VT_ERROR An unknown error occurred. VT_OVERFLOW The caller attempted an operation that is illegal on the disk and may overflow the fields in the data structure. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |MT-Level |Unsafe | +-----------------------------+-----------------------------+ SEE ALSO
fmthard(1M), format(1M), prtvtoc(1M), ioctl(2), efi_alloc_and_init(3EXT), attributes(5), dkio(7I) BUGS
The write_vtoc() function cannot write a VTOC on an unlabeled disk. Use format(1M) for this purpose. SunOS 5.11 7 Oct 2008 read_vtoc(3EXT)
All times are GMT -4. The time now is 10:22 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy