17 November 2010

Host Info - Disks

Continuing the 'host info' series, we check out what disks are presented
to the system.  As usual, the details of our hosts are:
        HOSTS:          snorkle (sunhost), tux (linhost), beastie (bsdhost)
        PROMPT:         host [0]
        Solaris INFO:   Solaris 10, x86
        Linux INFO:     CentOS 5.4, x86
        FreeBSD INFO:   FreeBSD 8.1, x86
Unlike Linux and FreeBSD, we have to actually tell Solaris about some
of our devices, such as disks.  Typically, we can accomplish this in
the simplest fashion with a reconfiguration boot (boot -r) or reboot
(reboot -- -r).  After all disks have been identified by Solaris, we can
get info on them.  To see what disks are attached, we can use 'cfgadm':

        snorkle [0] /usr/sbin/cfgadm -al
        Ap_Id                          Type         Receptacle   Occupant     Condition
        c1                             scsi-bus     connected    configured   unknown
        c1::dsk/c1t0d0                 disk         connected    configured   unknown
        c1::dsk/c1t2d0                 disk         connected    configured   unknown
        c1::dsk/c1t3d0                 disk         connected    configured   unknown
        usb0/1                         unknown      empty        unconfigured ok
        <snip...>
    To see the device paths and disk size of each known disk, use format:

        snorkle [0] echo "^D" | /usr/sbin/format
        Searching for disks...done


        AVAILABLE DISK SELECTIONS:
               0. c1t0d0 <DEFAULT cyl 1334 alt 2 hd 255 sec 63>
                  /pci@0,0/pci1000,8000@14/sd@0,0
               1. c1t2d0 <DEFAULT cyl 509 alt 2 hd 64 sec 32>
                  /pci@0,0/pci1000,8000@14/sd@2,0
               2. c1t3d0 <DEFAULT cyl 509 alt 2 hd 64 sec 32>
                  /pci@0,0/pci1000,8000@14/sd@3,0
        Specify disk (enter its number): `' is not an integer.
        Specify disk (enter its number):
        snorkle [1]
    To resolve the disk sizes, with c1t0d0 as the example, multiply the
    cylinders, heads, sectors.  Since this gives the number of 512 byte
    blocks, divide by 2 to get the size in KB.  To get the disk size in
    GB, divide by 1048576:
        snorkle [1] echo "scale=2 ; ((1334 * 255 * 63) / 2) / 1048576" | /usr/bin/bc
        10.21
In Linux:

    'fdisk' keeps things simple by listing all known disks and sizes:
        tux [0] /sbin/fdisk -l | /bin/grep ^Disk
        Disk /dev/sda: 11.0 GB, 11004805120 bytes
        Disk /dev/sdb: 11.0 GB, 11005853696 bytes
        Disk /dev/sdc: 536 MB, 536870912 bytes
        Disk /dev/sdd: 536 MB, 536870912 bytes
In FreeBSD:

    In FreeBSD versions 7.0 and newer, 'gpart' will list out similar
    data to 'fdisk' in Linux:
        beastie [0] /sbin/gpart show | /usr/bin/grep '=>'
        =>      63  21495726  da1  MBR  (10G)
        =>      63  21493647  mirror/gm0  MBR  (10G)
        =>       0  21478842  da1s1  BSD  (10G)
        =>     32  1048544  da3  MBR  (512M)
        =>       0  21478842  mirror/gm0s1  BSD  (10G)
        =>      0  1048544  da3s1  BSD  (512M)
        =>     32  1048544  da2  MBR  (512M)
    Since a GEOM mirror device was listed, 'gmirror' will tell us the
    supporting device(s) and 'fdisk' will get us the disk size:
        beastie [0] /sbin/gmirror status gm0
              Name    Status  Components
        mirror/gm0  COMPLETE  da0
        beastie [0] /sbin/fdisk -s da0
        /dev/da0: 1337 cyl 255 hd 63 sec
        Part        Start        Size Type Flags
           1:          63    21478842 0xa5 0x80
    To get the disk size in GB, the same process as in Solaris of
    multiplying the cylinders, heads, and sectors, diviing by 2, and
    dividing by 1048576 can be used:
        beastie [0] echo "scale=2; ((1337 * 255 * 63) / 2) / 1048576" | /usr/bin/bc
        10.24
    For all versions of FreeBSD going back to 4.1, you can also grab the
    disk info from 'dmesg.boot'.  The 'egrep' pattern is for lines
    beginning with any of the known FreeBSD disk types:
        beastie [0] /usr/bin/egrep '^(ad|da|fla|aacd|mlxd|amrd|idad|twed)' /var/run/dmesg.boot
        da0 at mpt0 bus 0 scbus0 target 0 lun 0
        da0: <VBOX HARDDISK 1.0> Fixed Direct Access SCSI-5 device
        da0: 3.300MB/s transfers
        da0: Command Queueing enabled
        da0: 10495MB (21493760 512 byte sectors: 255H 63S/T 1337C)
        da1 at mpt0 bus 0 scbus0 target 1 lun 0
        da1: <VBOX HARDDISK 1.0> Fixed Direct Access SCSI-5 device
        da1: 3.300MB/s transfers
        da1: Command Queueing enabled
        da1: 10496MB (21495808 512 byte sectors: 255H 63S/T 1338C)
        da2 at mpt0 bus 0 scbus0 target 2 lun 0
        da2: <VBOX HARDDISK 1.0> Fixed Direct Access SCSI-5 device
        da2: 3.300MB/s transfers
        da2: Command Queueing enabled
        da2: 512MB (1048576 512 byte sectors: 64H 32S/T 512C)
        da3 at mpt0 bus 0 scbus0 target 3 lun 0
        da3: <VBOX HARDDISK 1.0> Fixed Direct Access SCSI-5 device
        da3: 3.300MB/s transfers
        da3: Command Queueing enabled
        da3: 512MB (1048576 512 byte sectors: 64H 32S/T 512C)
Next up is network interfaces.

No comments: