Solaris Block Devices and Mount / Un-mounting Options

Overview

Under Solaris, one of the most involved UNIX devices to understand is the disk device file. Here are several key points that may help:

  • In many cases, a disk device file (i.e. /dev/dsk/c0t2d0s7) refers to a particular partition (aka “slice”) of a disk, and not the entire physical device. There are several device files which refer to the entire physical device, but are rarely used.
  • For every disk device, there are usually two device files – the block device and the character (“raw”) device. In general:
    • block devices are generally stored under /dev/dsk and used for filesystem type access (e.g mount)
    • character devices are generally stored under /dev/rdsk used for everything else (e.g. fsck, newfs, etc..)
  • Discs are generally attached to a controller (or a bus) which can handle multiple devices. IDE and SCSI are both common attach methods. This tends to make disk device filename more complex than other types of devices.

/etc/vfstab

To see the difference between the block device and character device for a device, consider the following. The /etc/vfstab contains entries for a single filesystem on a Solaris server:

/dev/dsk/c0t2d0s7 /dev/rdsk/c0t2d0s7 /opt ufs 3 yes -

The first 2 fields in the above entry, list the same disk device as both a block device (“dsk”) and character device (“rdsk”). The block device is used by mount when mounting the filesystem while the character device is used by fsck when checking the filesystem and newfs when creating the filesystem.. Both fields must be present in /etc/vfstab.

Breaking Down c0t2d0s7

This section breaks down the different components of a disk device file. In this example, I will be using the disk device file: c0t2d0s7. The four components of the disk device file are: controller, target, LUN and slice/partition and further defined in the following table:

Sector or disk blocks : The smallest addressable unit on a platter. One sector can hold 512 bytes of data. Sectors are also known as disk blocks.

Track A series of sectors positioned end-to-end in a circular path.
Cylinder A stack of tracks.
Disk Slices Disks are logically divided into individual partitions known as disk slices
Controller number Identifies the host bus adapter (HBA), which controls communications between the system and disk unit.
The HBA takes care of sending and receiving both commands and data to the device. The controller
number is assigned in sequential order, such as c0, c1, c2, and so on.

Target number Target numbers, such as t0, t1, t2, and t3, correspond to a unique hardware address that is
assigned to each disk, tape, or CD-ROM. Some external disk drives have an address switch located
on the rear panel.

Disk number The disk number is also known as the logical unit number (LUN). This number reflects the number of
disks at the target location

Slice number A slice number ranging from 0 to 7.

Logical device names Logical disk device names are symbolic links to the physical device names kept in the
/devices directory.
Physical device names Physical device names uniquely identify the physical location of the hardware devices on the
system and are maintained in the /devices directory.

Instance names are abbreviated names assigned by the kernel for each device on the system

Listing a System’s Devices
Using the /etc/path_to_inst file
Using the prtconf command
Using the format command
devfsadm -c device_class

The values for device_class include disk, tape, port, audio, and pseudo.

For example, to restrict the devfsadm command to the disk device class, perform the command:

# devfsadm -c disk
Use the -c option more than once on the command line to specify multiple device classes. For example, to specify the disk, tape, and audio device classes, perform the command:
# devfsadm -c disk -c tape -c audio

syntax : devfsadm -i driver_name

To configure only those disks supported by the dad driver, perform the command:
# devfsadm -i dad

To configure only those disks supported by the sd driver, perform the command:
# devfsadm -i sd

To configure devices supported by the st driver, perform the command:
# devfsadm -i st

For a verbose output of changes to the device tree, perform the command:
# devfsadm -v

To invoke cleanup routines that remove unreferenced symbolic links for devices, perform the command:
# devfsadm -C
The prtvtoc command enables you to view a disk’s VTOC

# prtvtoc /dev/dsk/c1t3d0s0
* /dev/dsk/c1t3d0s0 partition map
*
* Dimensions:
* 512 bytes/sector
* 133 sectors/track
* 27 tracks/cylinder
* 3591 sectors/cylinder
* 4926 cylinders
* 4924 accessible cylinders
*
* Flags:
* 1: unmountable
* 10: read-only
*
* First Sector Last
* Partition Tag Flags Sector Count Sector Mount Directory
0 9 00 0 2007369 2007368
1 3 01 2007369 1052163 3059531
2 5 11 0 17682084 17682083
7 8 00 3059532 14622552 17682083

Find out the backup super blocks
# newfs -N /dev/rdsk/c1t3d0s7
/dev/rdsk/c1t3d0s7: 6295022 sectors in 1753 cylinders of 27 tracks,
133 sectors
3073.7MB in 110 cyl groups (16 c/g, 28.05MB/g, 3392 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
32, 57632, 115232, 172832, 230432, 288032, 345632, 403232, 460832,
518432, 5746208, 5803808, 5861408, 5919008, 5976608, 6034208, 6091808,
6149408, 6207008, 6264608,
#
or
# newfs -N -T /dev/rdsk/c1t3d0s7 ( -T –> file system to be a multi-Terabyte file system.)

The following command uses a backup superblock.
# fsck -o b=32 /dev/rdsk/c0t0d0s7
Alternate super block location: 32.
** /dev/rdsk/c0t0d0s7
** Last Mounted on
** Phase 1 – Check Blocks and Sizes
** Phase 2 – Check Pathnames
** Phase 3 – Check Connectivity
** Phase 4 – Check Reference Counts
** Phase 5 – Check Cyl groups
2 files, 9 used, 5174880 free (16 frags, 646858 blocks, 0.0%
fragmentation)
#

The /etc/vfstab file lists all the file systems to be automatically mounted at system boot time, with the exception of the /etc/mnttab

# mount /dev/dsk/c0t0d0s7 /export/home
read/write Indicates whether reads and writes are allowed on the file system.
setuid Permits the execution of setuid programs in the file system.
intr/nointr Allows and forbids keyboard interrupts to kill a process that is waiting for an operation on a locked file
system.
logging Indicates that logging is enabled for the ufs file system. This is the default for the Solaris 10 OS.
largefiles Allows for the creation of files larger than 2 Gbytes. A file system mounted with this option can contain
files larger than 2 Gbytes
xattr Supports extended attributes not found in standard UNIX filesystems
onerror=action Specifies the action that the ufs file system should take to recover from an internal inconsistency on
a file system.
An action can be specified as:
panic—Causes a forced system shutdown. This is the default.
lock — Applies a file system lock to the file system.
umount — Forcibly unmounts the file system .
mount -o option,option,… device_name mount_point
ro – Mounts the file system as read-only
# mount -o ro /dev/dsk/c0t0d0s7 /export/home
nosuid – Prohibits the execution of setuid programs in the file system. This does not restrict the creation of setuid programs.
mount -o ro,nosuid /dev/dsk/c0t0d0s7 /export/home
noatime – Suppresses the time-last-accessed modification on inodes, which reduces disk activity on a file system where access times are not important. Specifying this option generally improves file access times and boosts overall performance
mount -o noatime /dev/dsk/c0t0d0s7 /export/home
nolargefiles – Prevents a file system that contains one or more “large files” from being mounted
mount -o nolargefiles /dev/dsk/c0t0d0s7 /export/home

Determining a File System’s Type
The /etc/vfstab file for the FS type field
The /etc/default/fs file for a local file system type
The /etc/dfs/fstypes file for a remote file system type

# fstyp /dev/rdsk/c0t0d0s7
ufs

# mount -F hsfs -o ro /dev/dsk/c0t6d0s0 /cdrom

# umount /export/home

# umountall —————>unmount manually all the file systems listed in the /etc/mnttab file
# umountall -l —————>To unmount only the local file systems listed in the /etc/mnttab file

# fuser -cu mount_point ——> displays who using the file system
# fuser -ck mount_point ——> Kill all processes accessing the file system