April 6, 2010

Solaris diskinfo utility

Posted in Utility at 11:08 am by alessiodini

Some days ago i wrote with Emanuel this script.
When on a system disks are used in slice format ( not used in SVM , VxVM , ZFS ) this tool is useful for obtain free space information.
Follow this example:

# df -h
File system dim. usati disp. capacità Attivato su
/dev/dsk/c1t0d0s0 15G 5,1G 9,5G 35% /
/devices 0K 0K 0K 0% /devices
ctfs 0K 0K 0K 0% /system/contract
proc 0K 0K 0K 0% /proc
mnttab 0K 0K 0K 0% /etc/mnttab
swap 29G 964K 29G 1% /etc/svc/volatile
objfs 0K 0K 0K 0% /system/object
sharefs 0K 0K 0K 0% /etc/dfs/sharetab
/dev/dsk/c1t0d0s4 5,9G 2,9G 3,0G 50% /usr
/usr/lib/libc/libc_hwcap1.so.1
5,9G 2,9G 3,0G 50% /lib/libc.so.1
fd 0K 0K 0K 0% /dev/fd
/dev/dsk/c1t0d0s3 3,9G 1,5G 2,4G 40% /var
swap 29G 52K 29G 1% /tmp
[output omitted]

I run diskinfo

# ./diskinfo
Usage:

./diskinfo {list|all}
./diskinfo list – for see total dimension of every path
./diskinfo all – for see free space

# ./diskinfo list
c1t0d0 : 46G
c1t1d0 : 87G
c1t2d0 : 311G
c1t3d0 : 419G
c1t4d0 : 199G
c1t5d0 : 9G

For see free space on every disk

# ./diskinfo all

Disk c1t0d0 : 46G
Free Space : 7M

Disk c1t1d0 : 87G
Free Space : 0M

[output omitted]

Just for be clear this is the output of format command ( it be compared with diskinfo output )

format
Searching for disks…done

AVAILABLE DISK SELECTIONS:
0. c1t0d0
/pci@0,0/pci1000,30@10/sd@0,0
1. c1t1d0
/pci@0,0/pci1000,30@10/sd@1,0
2. c1t2d0
/pci@0,0/pci1000,30@10/sd@2,0
3. c1t3d0
/pci@0,0/pci1000,30@10/sd@3,0
4. c1t4d0
/pci@0,0/pci1000,30@10/sd@4,0
5. c1t5d0
/pci@0,0/pci1000,30@10/sd@5,0
Specify disk (enter its number): 0
selecting c1t0d0
[disk formatted]
Warning: Current Disk has mounted partitions.
/dev/dsk/c1t0d0s0 is currently mounted on /. Please see umount(1M).
/dev/dsk/c1t0d0s1 is currently used by swap. Please see swap(1M).
/dev/dsk/c1t0d0s3 is currently mounted on /var. Please see umount(1M).
/dev/dsk/c1t0d0s4 is currently mounted on /usr. Please see umount(1M).
/dev/dsk/c1t0d0s6 is currently mounted on /export/home. Please see umount(1M).

FORMAT MENU:
disk – select a disk
type – select (define) a disk type
partition – select (define) a partition table
current – describe the current disk
format – format and analyze the disk
fdisk – run the fdisk program
repair – repair a defective sector
label – write label to the disk
analyze – surface analysis
defect – defect list management
backup – search for backup labels
verify – read and display labels
save – save new disk/partition definitions
inquiry – show vendor, product and revision
volname – set 8-character volume name
! – execute , then return
quit
format> p

PARTITION MENU:
0 – change `0′ partition
1 – change `1′ partition
2 – change `2′ partition
3 – change `3′ partition
4 – change `4′ partition
5 – change `5′ partition
6 – change `6′ partition
7 – change `7′ partition
select – select a predefined table
modify – modify a predefined partition table
name – name the current table
print – display the current table
label – write partition map and label to the disk
! – execute , then return
quit
partition> p
Current partition table (original):
Total disk cylinders available: 6132 + 2 (reserved cylinders)

Part Tag Flag Cylinders Size Blocks
0 root wm 1 – 1959 15.01GB (1959/0/0) 31471335
1 swap wu 3920 – 6130 16.94GB (2211/0/0) 35519715
2 backup wm 0 – 6131 46.97GB (6132/0/0) 98510580
3 var wm 1960 – 2482 4.01GB (523/0/0) 8401995
4 usr wm 2483 – 3266 6.01GB (784/0/0) 12594960
5 unassigned wm 0 0 (0/0/0) 0
6 home wm 3267 – 3919 5.00GB (653/0/0) 10490445
7 unassigned wm 0 0 (0/0/0) 0
8 boot wu 0 – 0 7.84MB (1/0/0) 16065
9 unassigned wm 0 0 (0/0/0) 0

This is really useful where i must work in delivery systems !

Here there is the code

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: