/etc/vfstab tutorial

The vfstab file is used by the operating system to define default filesystems. The vfstab file consists of seven "columns" or fields, separated by tabs or spaces. In order to keep things consistent, we will use tabs to separate our fields. The vfstab file is read at startup or when you run the mountall command.

A typical vfstab file will look like this:
========================
#device device mount FS fsck mount mount
#to mount to fsck point type pass at boot options
#
#/dev/dsk/c1d0s2 /dev/rdsk/c1d0s2 /usr ufs 1 yes -
fd - /dev/fd fd - no -
/proc - /proc proc - no -
/dev/dsk/c0t0d0s1 - - swap - no -
/dev/dsk/c0t0d0s0 /dev/rdsk/c0t0d0s0 / ufs 1 no -
swap - /tmp tmpfs - yes -
========================

The first thing you will probably notice is that the fields do not line up neatly under the "column headings." The file appears to makes absolutely no sense. However, the computer does not need to see neat little rows in order to make sense of the file. The computer tells the difference between fields by looking for the whitespace between fields. The same file as above edited for ease of viewing by a human would appear as the following:

========================
#device			device			mount		FS	fsck	mount	mount
#to mount		to fsck			point		type	pass	at boot	options
#
#/dev/dsk/c1d0s2 	/dev/rdsk/c1d0s2 	/usr          	ufs	1	yes	-
fd			-			/dev/fd		fd	-	no	-
/proc			-			/proc		proc	-	no	-
/dev/dsk/c0t0d0s1	-			-		swap	-	no	-
/dev/dsk/c0t0d0s0	/dev/rdsk/c0t0d0s0	/		ufs	1	no	-
swap			-			/tmp		tmpfs	-	yes	-
========================

You will also notice that fields that do not have information in them are not left blank. Instead a hypen is used to let the computer know that the information is not necessary. Let's take a closer look at what each column means.

++++++++++++++++++++++++
device to mount: the name of the resource to be mounted (i.e. /dev/dsk/c0t1d0s0)

device to fsck: the raw device to be checked by fsck (i.e. /dev/rdsk/c0t1d0s0)

mount point: the name of the directory where the device will be attached to the filesystem (i.e. /disk2)

FS type: the kind of filesystem on the device (i.e. ufs, tmpfs)

fsck pass: a numeric value used by fsck to determine whether to check the filesystem or not. To be on the safe side, put a 1 in this field unless it is a read-only filesystem, in which case you should put a hyphen. If you want the long explaination, see Table 39-3 on this page: http://docs.sun.com/db/doc/805-7228/6j6q7uf0g?a=view

mount at boot: this field is used to determine whether the file system will be automatically mounted at boot time; can either be yes or no; usually, entries specifying devices with removable media will take an 'no' in this field

mount options: allows you to set special FS-specific mount options, such as read-only, logging, etc. For more information on special mount options see man pages for the following: mount_cachefs, mount_hsfs, mount_nfs, mount_pcfs, mount_tmpfs or mount_ufs
++++++++++++++++++++++++

For a walkthrough on using the vfstab file to automount a slice at startup, see our page on automounting.