Unmounting a File System
Unmounting a file system removes it from the file system mount point and deletes the entry from /etc/mnttab. Some file system administration tasks, such as labelit and fsck, cannot be performed on mounted file systems. You should unmount a file system if any of the following three conditions exist:
<mount-point> is the name of the file system you want to unmount. This can be either the directory name in which the file system is mounted or the device name path of the file system. For example, to unmount the /home2 file system, type the following:
The fuser Command
Before you can unmount a file system, you must be logged in as the administrator (root) and the file system must not be busy. A file system is considered busy if a user is in a directory in the file system or if a program has a file open in that file system. You can make a file system available for unmounting by changing to a directory in a different file system or by logging out of the system. If something is causing the file system to be busy, you can use the fuser command, described in Table 1.18, to list all the processes that are accessing the file system and to stop them if necessary.
Informing Users Always notify users before unmounting a file system.
The syntax for fuser is as follows:
/usr/sbin/fuser [options] <file>|<file system>
Replace <file> with the filename you are checking, or replace <file system> with the name of the file system you are checking.
The following example uses the fuser command to find out why /home2 is busy:
fuser -cu /home2
The system displays each process and user login name that is using this file system:
/home2: 8448c(root) 8396c(root)
The following command stops all processes that are using the /home2 file system by sending a SIGKILL to each one. Don't use it without first warning the users:
fuser -c -k /home2
Using the fuser command as described is the preferred method for determining who is using a file system before unmounting it. Added in Solaris 8 was another, less desirable method for unmounting a file system, using the umount command with the -f option, as follows:
umount -f /home2
The -f option forcibly unmounts a file system. Using this option can cause data loss for open files and programs that access files after the file system has been unmounted; it returns an error (EIO). The -f option should be used only as a last resort.
You can also use the fuser command to check on any device such as the system console. By typing:
/dev/console: 459o 221o
When a file system is mounted, an entry is maintained in the mounted file system table called /etc/mnttab. The file /etc/mnttab is really a file system that provides read-only access to the table of mounted file systems for the current host. The mount command adds entries to this table, and umount removes entries from this table. The kernel maintains the list in order of mount time. For example, the first mounted file system is first in the list, and the most recently mounted file system is last. When mounted on a mount point, the file system appears as a regular file containing the current mnttab information. Each entry in this table is a line of fields separated by spaces in this form:
<special> <mount_point> <fstype> <options> <time>
Table 1.19 describes each field.
Following is a sample /etc/mnttab file:
# more /etc/mnttab /dev/dsk/c0t0d0s0 / ufs \ rw,intr,largefiles,logging,xattr,onerror=panic,dev=2200008 1127941982 /devices /devices devfs dev=4380000 1127941959 ctfs /system/contract ctfs dev=43c0001 1127941959 proc /proc proc dev=4400000 1127941959 mnttab /etc/mnttab mntfs dev=4440001 1127941959 swap /etc/svc/volatile tmpfs xattr,dev=4480001 1127941959 objfs /system/object objfs dev=44c0001 1127941959 /dev/dsk/c0t0d0s6 /usr ufs \ rw,intr,largefiles,logging,xattr,onerror=panic,dev=220000e 1127941982 fd /dev/fd fd rw,dev=4640001 1127941982 /dev/dsk/c0t0d0s1 /var ufs \ rw,intr,largefiles,logging,xattr,onerror=panic,dev=2200009 1127941983 swap /tmp tmpfs xattr,dev=4480002 1127941983 swap /var/run tmpfs xattr,dev=4480003 1127941983 /dev/dsk/c0t0d0s5 /opt ufs \ rw,intr,largefiles,logging,xattr,onerror=panic,dev=220000d 1127941991 /dev/dsk/c0t0d0s7 /export/home ufs \ rw,intr,largefiles,logging,xattr,onerror=panic,dev=220000f 1127941991 -hosts /net autofs nosuid,indirect,ignore,nobrowse,dev=4700001 1127942006 auto_home /home autofs indirect,ignore,nobrowse,dev=4700002 1127942006 smokey:vold(pid487) /vol nfs ignore,noquota,dev=46c0001 1127942024 /vol/dev/dsk/c0t2d0/s10_software_companion /cdrom/s10_software_companion hsfs\ ro,nosuid,noglobal,maplcase,rr,traildot,dev=16c0001 1127942029 /dev/dsk/c2t1d0s1 /mnt ufs rw,intr,largefiles,logging,xattr,\ onerror=panic,dev=800089 1128021589
Before Solaris 8, the /etc/mnttab file was a text file. The downside of being a text file was that it could get out of sync with the actual state of mounted file systems, or it could be manually edited. Now this file is a mntfs file system that provides read-only information directly from the kernel about mounted file systems for the local hosts.
You can display the contents of the mount table by using the cat or more commands, but you cannot edit them.
Creating an Entry in the /etc/vfstab File to Mount File Systems
Explain the purpose and function of the vfstab file in mounting UFS file systems, and the function of the mnttab file system in tracking current mounts.
The /etc/vfstab (virtual file system table) file contains a list of file systems, with the exception of the /etc/mnttab and /var/run, to be automatically mounted when the system is booted to the multiuser state. The system administrator places entries in the file, specifying what file systems are to be mounted at bootup. The following is an example of the /etc/vfstab file:
# cat /etc/vfstab #device device mount FS fsck mount mount #to mount to fsck point type pass at boot options # fd - /dev/fd fd - no - /proc - /proc proc - no - /dev/dsk/c0t0d0s3 - - swap - no - /dev/dsk/c0t0d0s0 /dev/rdsk/c0t0d0s0 / ufs 1 no - /dev/dsk/c0t0d0s6 /dev/rdsk/c0t0d0s6 /usr ufs 1 no - /dev/dsk/c0t0d0s1 /dev/rdsk/c0t0d0s1 /var ufs 1 no - /dev/dsk/c0t0d0s7 /dev/rdsk/c0t0d0s7 /export/home ufs 2 yes - /dev/dsk/c0t0d0s5 /dev/rdsk/c0t0d0s5 /opt ufs 2 yes - /devices - /devices devfs - no - ctfs - /system/contract ctfs - no - objfs - /system/object objfs - no - swap - /tmp tmpfs - yes -
You'll need to make entries in the vfstab file on the exam. Understand the syntax and know how to create a new line in this file for both a UFS file system and swap.
Each column of information follows this format:
Type the mount command with the -p option to display a list of mounted file systems in /etc/vfstab format:
The system responds with this:
/dev/dsk/c0t0d0s0 - / ufs - no rw,intr,largefiles,logging,xattr,onerror=panic /devices - /devices devfs - no ctfs - /system/contract ctfs - no proc - /proc proc - no mnttab - /etc/mnttab mntfs - no swap - /etc/svc/volatile tmpfs - no xattr objfs - /system/object objfs - no /dev/dsk/c0t0d0s6 - /usr ufs - no rw,intr,largefiles,logging,xattr,onerror=panic fd - /dev/fd fd - no rw /dev/dsk/c0t0d0s1 - /var ufs - no rw,intr,largefiles,logging,xattr,onerror=panic swap - /tmp tmpfs - no xattr swap - /var/run tmpfs - no xattr /dev/dsk/c0t0d0s4 - /data ufs - no rw,intr,largefiles,logging,xattr,onerror=panic /dev/dsk/c0t0d0s5 - /opt ufs - no rw,intr,largefiles,logging,xattr,onerror=panic /dev/dsk/c0t0d0s7 - /export/home ufs - no rw,intr,largefiles,logging,xattr,\ onerror=panic