Disk and Filesystems Management in Unix | Mount Options | Performing Mounts | Mounting CD-ROM | |
df | du |
The file system is best visualized as a tree, rooted, as it were, at /. /dev, /usr, and the other directories in the root directory are branches, which may have their own branches, such as /usr/local, and so on.
There are various reasons to house some of these directories on separate file systems. /var contains the directories log/, spool/, and various types of temporary files, and as such, may get filled up. Filling up the root file system is not a good idea, so splitting /var from / is often favorable.
Another common reason to contain certain directory trees on other file systems is if they are to be housed on separate physical disks, or are separate virtual disks, such as Network File System mounts, or CDROM drives.
During the boot process, file systems listed in /etc/fstab are automatically mounted (unless they are listed with the noauto option).The /etc/fstab file contains a list of lines of the following format:
device /mount-point fstype options dumpfreq passno
Consult the fstab(5) manual page for more information on the format of the /etc/fstab file and the options it contains.
The mount(8) command is what is ultimately used to mount file systems.
In its most basic form, you use:
# mount device mountpoint
There are plenty of options, as mentioned in the mount(8) manual page, but the most common are:
Mount Options``ufs'' is the default file system type.
The -o option takes a comma-separated list of the options, including the following:
-a and -A are used to unmount all mounted file systems, possibly modified by the file system types listed after -t. -A, however, does not attempt to unmount the root file system.
Mounting is a process that attach individual file systems to their mount points on the directory hierarchy. This action makes a file system accessible to the system and to the users.
You use the unmounting process to detach a file system from its mount point in the directory hierarchy. This action makes a file system unavailable to the system or users.
After you have created a file system by using the newfs command, you must attach it to the Unix directory hierarchy at a mount point. A mount point is a directory that is the point of connection for a file system. File systems are commonly referred to by the names of their mount points, for example, the / (root) file system or the /usrfile system.
To determine which file systems are currently mounted use
mount command. The mount command, which is located in the /usr/sbin directory, maintains a table of currently mounted file systems in the /etc/mnttab file. When the mount command is used without arguments, it lists all of the mounted file systems in the /etc/mnttab directory. When used with only a partial argument list, the command searches the /etc/vfstab file for an entry that supplies the missing arguments.
df command. The dfcommand displays the amount of disk space occupied by mounted or unmounted file systems and, depending on the options used, displays both locally mounted and virtual file system information.
Note – While system administrators typically use the /usr/sbin/mount command, the system boot scripts use the /sbin/mount command.
The Unix provides several methods for automating file system mounts.
The Unix creates a default /etc/vfstab file during software installation, based on your selections. However, you can edit the /etc/vfstab file whenever file system entries need to be added or modified.
The automounter can mount network file systems on demand.
The /etc/vfstab file lists all the file systems to be automatically mounted at system boot time, with the exception of the /etc/mnttab and /var/runfile systems.
The file format includes seven fields per line entry. By default, a tab separates each field, but any whitespace can be used for separators. The dash ( - ) character is used as a placeholder for fields when text arguments are not appropriate. Commented lines begin with the hash ( # ) symbol.
To add a line entry, you need the following information:
Note : For / (root), /usr , and /var (if it is a separate file system) file systems, the mount at boot field value is specified as no . The kernel mounts these file systems as part of the boot sequence before the mountall command is run. The mount command explicitly mounts the file systems /(root) and /usr as specified in the /etc/rcS.d/S30rootusr.sh script and the /var file system as specified in the /etc/rcS.d/S70buildmnttab script.
device to mount The device to be mounted. For example, a local ufs file system /dev/dsk/c#t#d#s# , or a pseudo file system /proc .
device to fsck
mount point The name of the directory that serves as the attach mount point in the Unix directory hierarchy.
FS type
fsck pass
mount at boot Enter yes to enable the mountall command to mount the file systems at boot time. Enter no to prevent a file system mount at boot time.
mount optionsA comma-separated list of options passed to the mount command. A dash (-) indicates the use of default mount options.
Note – Because the default is to use tabs to separate the fields in the /etc/vfstab file, the fields often do not line up under their respective headings. This can lead to some confusion when you are viewing this file in a terminal window.
An example of a /etc/vfstab file follows:
# more /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/c0t0d0s1 - - swap - no -
/dev/dsk/c0t0d0s0 /dev/rdsk/c0t0d0s0 / ufs 1 no -
/dev/dsk/c0t0d0s7 /dev/rdsk/c0t0d0s7 /export/home ufs 2 yes -
swap - /tmp tmpfs - yes -
The /etc/mnttab file is really an mntfs file system that provides read-only information directly from the kernel about mounted file systems on the local host.
Each time a file system is mounted, the mount command adds an entry to this file. Whenever a file system is unmounted, its entry is removed from the /etc/mnttab file.
Mount Point The mount point or directory name where the file system is to be attached within the / (root) file system (for example, /usr, /opt ).
Device Name The name of the device that is mounted at the mount point. This block device is where the file system is physically located.
Mount Options The list of mount options in effect for the file system. dev=number The major and minor device number of the mounted file system.
Date and Time Mounted The date and time that the file system was mounted to the directory hierarchy.
The /var/run file system is a tmpfs mounted file system in the Unix. It is the repository for temporary operating system files that are not needed across system reboots in this Unix release. It is mounted as a pseudo file system rather than a disk-based file system.
The /var/run directory requires no administration. For security reasons, it is owned by the root user.
The /tmp directory continues to be a tmpfs mounted file system in the Unix. It is the repository for temporary user and application files that are not needed across system reboots. It is a pseudo file system rather than a disk-based file system.
The following examples show two ways to display currently mounted file systems.
# more /etc/mnttab
/dev/dsk/c0t0d0s0 / ufs
rw,intr,largefiles,xattr,onerror=panic,suid,dev=2200000 10164665 25
/proc /proc proc dev=4300000 1016466524
mnttab /etc/mnttab mntfs dev=43c0000 1016466524
fd /dev/fd fd rw,suid,dev=4400000 1016466527
swap /var/run tmpfs xattr,dev=1 1016466529
swap /tmp tmpfs xattr,dev=2 1016466532
/dev/dsk/c0t0d0s7 /export/home ufs
rw,intr,largefiles,xattr,onerror=panic,suid,dev=2200007 1016466532
-hosts /net autofs indirect,nosuid,ignore,nobrowse,dev=4580001 1016466537
auto_home /home autofs indirect,ignore,nobrowse,dev=4580002 1016466537
-xfn /xfn autofs indirect,ignore,dev=4580003 1016466537 sys41:vold(pid248) /vol nfs ignore,dev=4540001 1016466554
# mount
/ on /dev/dsk/c0t0d0s0
read/write/setuid/intr/largefiles/xattr/onerror=panic/dev=2200000 on Mon Mar 18
08:48:45 2002
/proc on /proc read/write/setuid/dev=4300000 on Mon Mar 18 08:48:44 2002
/etc/mnttab on mnttab read/write/setuid/dev=43c0000 on Mon Mar 18 08:48:44 2002
/dev/fd on fd read/write/setuid/dev=4400000 on Mon Mar 18 08:48:47 2002
/var/run on swap read/write/setuid/xattr/dev=1 on Mon Mar 18 08:48:49 2002
/tmp on swap read/write/setuid/xattr/dev=2 on Mon Mar 18 08:48:52 2002
/export/home on /dev/dsk/c0t0d0s7
read/write/setuid/intr/largefiles/xattr/onerror=panic/dev=2200007 on Mon Mar 18
08:48:52 2002
You can mount file systems manually by logging in as the root user and running the mount command, or the system can automatically mount file systems at boot time after consulting the /etc/vfstab file.
The mount command not only lists which file systems are currently mounted, it also provides you, as the root user, with a method for mounting file systems.
To mount a local file system manually, you need to know the name of the device where the file system resides and its mount point directory name. Perform the command:
#
mount /dev/dsk/c0t0d0s7 /export/homeIn this example, the default action mounts the file system with the following options: read/write , setuid , intr , nologging , and largefiles , xattr , and onerror .
The following list explains the default options for the mount command.
read/write
setuid
intr/nointr
nologging
largefiles
xattr
Note – Due to file system overhead, the largest file size that can be created is approximately 866 Gbytes.
The /etc/vfstab file provides you with another important feature. Because the /etc/vfstab file contains the mapping between the mount point and the actual device name, the root user can manually mount a file system specifying only the mount point on the command line.
#
mount /export/home # means take options from /etc/vfstabmount command is unique amont Unix utilities in that it requres options to be preseded by the -o flag. When you are using multiple options, enter them as a comma-separated list following the -o flag. Some options used to mount local file systems include: ro , nosetuid ,
mount -o
option,option,... device_name mount_pointNote – Mount options are discussed in detail in the man page for the mount_ufs command.
onerror=
panic
lock
umount
noatime
l ro – Mounts the file system as read-only.The following is an example using this option on the command line:
mount -o ro /dev/dsk/c0t0d0s6 /usr#
l nosuid – Prohibits the execution of setuid programs in the filtsystem. This does not restrict the creation of setuid programs.The following example shows the use of multiple options on the command line:
mount -o ro,nosuid /dev/dsk/c0t0d0s7 /export/home#
l 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, for example:
mount -o noatime /dev/dsk/c0t0d0s7 /export/home#
l nolargefiles – Prevents a file system that contains one or more "large files" from being mounted, for example:
mount -o nolargefiles /dev/dsk/c0t0d0s7 /export/home#
Use of the nolargefiles option fails if the file system to be mounted contains a large file or did contain a large file at one time. If the file system currently contains a large file and the root user needs to mount it with this option, then the large file must be located and moved or removed from the file system. Then you must execute the fsck command manually to update the superblock information. The mount also fails if the file system at one time contained a large file, even though it was moved or removed. You must execute the fsck command to clear the old information and allow the file system to be mounted.
logging – Enables logging for a ufs file system, for example:
mount -o logging /dev/dsk/c0t0d0s7 /export/home#
UFS logging is a process of storing file system transactions or changes that make up a complete file or directory operation into a log before they are applied to the file system. After a transaction is stored, the complete transaction can be applied to the file system later. The UFS log is allocated from free blocks in the file system. It is sized approximately 1 Mbyte per 1 Gbyte, up to a maximum of 64 Mbytes.
As a UFS log reaches its maximum size, it begins to write transactions to the file system. When the file system is unmounted, the entire UFS log is emptied, and all transactions are written to the file system. UFS logging offers two advantages. First, it prevents file systems from becoming inconsistent, therefore eliminating the need to run lengthy fsck scans. Secondly, you can bypass fsck scanning, which reduces the time required to reboot a system if it was stopped by a method other than an orderly shutdown.
The /etc/vfstab file is read by the /usr/sbin/mountall command during the system boot sequence and mounts all file systems that have a yes in the mount at boot field. The root user can use the mountall command to mount manually every file system in the /etc/vfstab file that has a yes in the mount at boot field, for example:
#
mountallTo mount only the local file systems listed in the /etc/vfstab file, execute:
mountall -l#
During the boot sequence, the fsck utility checks each local file system in the /etc/vfstab file that has a device to fsck entry and an fsck pass number greater than 0. The utility determines if the file system is in a usable state to be safely mounted.
If the fsck utility determines that the file system is in an unusable state (for example, corrupted), the fsck utility repairs it before the mount is attempted. The system attempts to mount any local file systems that have a - (dash) or 0 (zero) entry in the fsck pass field without checking the file system itself.
To add a new disk to the system, prepare the disk to hold a file system, and mount the file system, perform these general steps:
Set up the disk hardware, which might include setting address switches and connecting cables.
Perform a reconfiguration boot or run the devfsadm utility to add support for the new disk.
Use the format utility to partition the disk into one or more slices.
Create a new file system on one slice by using the newfs command.
Create a mount point for the file system by using the mkdir command to create a new directory in the /
(root) file system.
# mkdir /database
Mount the new file system manually by using the mount command.
#
mount /dev/dsk/c1t4d0s0 /database7. Use the mount command to determine if the file system is mounted.
#
mount/ on /dev/dsk/c0t0d0s0
read/write/setuid/intr/largefiles/xattr/onerror=panic/dev=2200000 on Mon
Mar 18 08:48:45 2002
/proc on /proc read/write/setuid/dev=4300000 on Mon Mar 18 08:48:44 2002
/etc/mnttab on mnttab read/write/setuid/dev=43c0000 on Mon Mar 18
08:48:44 2002
/dev/fd on fd read/write/setuid/dev=4400000 on Mon Mar 18 08:48:47 2002
/var/run on swap read/write/setuid/xattr/dev=1 on Mon Mar 18 08:48:49
2002
/tmp on swap read/write/setuid/xattr/dev=2 on Mon Mar 18 08:48:52 2002
/export/home on /dev/dsk/c0t0d0s7
read/write/setuid/intr/largefiles/xattr/onerror=panic/dev=2200007 on Mon
Mar 18 08:48:52 2002
/database on /dev/dsk/c1t4d0s0
read/write/setuid/intr/largefiles/xattr/onerror=panic/dev=800020 on Mon
Mar 18 09:15:26 2002
8. Edit the /etc/vfstab file to add a line entry for the new file system.
#
vi /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/c0t0d0s1 - - swap - no -
/dev/dsk/c0t0d0s0 /dev/rdsk/c0t0d0s0 / ufs 1 no -
/dev/dsk/c0t0d0s7 /dev/rdsk/c0t0d0s7 /export/home ufs 2 yes -
swap - /tmp tmpfs - yes -
/dev/dsk/c1t4d0s0 /dev/rdsk/c1t4d0s0 /database ufs 1 yes logging
#
The file system automatically mounts whenever the system boots .
Different file system types have unique properties that affect how the mount command functions.
By default, the mount command assumes it is mounting a ufs -type file system. However, when you are mounting a different type of file system, you might have to specify its type on the command line. You use the -F option with the mount command to specify the type of file system mounted. The file system type must be determinable from the
/etc/vfstab
, /etc/default/fs , or /etc/dfs/fstypes files.Because the mount commands need the file system type to function properly, the file system type must be explicitly specified or determined by searching the following files:
If the file system’s type has not been explicitly specified on the command line using the mount -F FStype option, the mount command examines the /etc/vfstab file to determine the file system’s type. The mount command makes this determination by using the file system’s block device name, raw device name, or mount point directory name.
If the mount command cannot determine the file system’s type by searching the /etc/vfstab file, the mount command uses the default file system type specified in either the /etc/default/fs file or the /etc/dfs/fstypes file, depending on whether the file system is local or remote.
The default local file system type is specified in the /etc/default/fs file by the line entry LOCAL=fstype .
LOCAL=ufs
The first line entry in the /etc/dfs/fstypes file determines the default remote file system type.
nfs NFS Utilities
autofs AUTOFS Utilities
cachefs CACHEFS Utilities
Using the
fstypCommandYou can also use the fstyp command with the raw device name of the
disk slice to determine a file system’s type.
#
fstyp /dev/rdsk/c0t0d0s7ufs
To mount a file system that resides on a CD-ROM when the Volume Management services are stopped, as the root user perform the command:
# mount -F hsfs -o ro /dev/dsk/c0t6d0s0 /cdrom
In this example, the file system type is hsfs , the file system resides on disk slice /dev/dsk/c0t6d0s0 , and the mount point /cdrom is a pre-existing directory in the Unix.
To mount a file system that resides on a diskette when the Volume Management services are stopped, as the root user, perform the commands:
#
mkdir /pcfs#
mount -F pcfs /dev/diskette /pcfsIn this example, the file system type is pcfs . This file system resides on the device /dev/diskette , and the mount point is /pcfs .
A file system is commonly unmounted if it needs to be checked and repaired by the fsck command, or if it needs to be backed up completely.
Some file system administration tasks cannot be performed on mounted file systems. To unmount a file system to prepare it for system maintenance, use the umount command.
Unmounting a file system by using the umount command removes it from the file system mount point and deletes its entry from the /etc/mnttab file.
Note – Notify users before unmounting a file system that they are currently accessing.
To unmount a file system manually by using the directory mount point, perform the command:
#
umount /export/homeTo unmount a file system manually by using the logical disk device name, perform the command:
#
umount /dev/dsk/c0t0d0s7The /etc/mnttab file is read by the /usr/sbin/umountall command during the system shutdown sequence or when umountall is invoked from the command line. The umountall unmounts all file systems
specified in the vfstab file except / (root), /usr , /proc , /dev/fd , /var , /var/run , and /tmp .
Run the umountall command as the root user when you want to unmount manually all the file systems listed in the /etc/mnttab file, for example:
#
umountallTo unmount only the local file systems listed in the /etc/mnttab file, perform the command:
#
umountall -lTo verify that a file system or a number of file systems have been unmounted, invoke the mount command and check the output.
Any file system that is busy is not available for unmounting. Both the umount and umountall commands display the error message: umount: file_system_name busy
A file system is considered to be busy if one of the following conditions exists:
l
l
l
l
There are two methods to make a file system available for unmounting if it is busy:
fuser command – Lists all of the processes that are accessing the file system and kills them if necessary
umount -f command – Forces the unmount of a file system
Note – The fuser command displays the process IDs of all processes currently using the specified file system. Each process ID is followed by a letter code. These letter codes are described in the man page for this command.
To stop all processes that are currently accessing a file system, follow these steps:
1. As the root user, list all of the processes that are accessing the file system. Use the following command to identify which processes need to be terminated.
#
fuser -cu mount_pointThis command displays the name of the file system and the user login name for each process currently active in the file system.
2. Kill all processes accessing the file system.
#
fuser -ck mount_pointA SIGKILL message is sent to each process that is using the file system.
3. Verify that there are no processes accessing the file system.
#
fuser -c mount_point4. Unmount the file system.
#
umount mount_pointUsing the
umount -fCommandAs the root user, you can unmount a file system, even if it is busy, by using the -f (force) option with the umount command. The following is the format for this command:
# umount -f
mount_pointThe file system is unmounted even if it contains open files. A forced unmount can result in loss of data and in zombie processes that are left running on the system. However, it is particularly useful for unmounting a shared file system if the remote file server is nonfunctional.
The following procedure describes how to boot from the Unix Software CD-ROM to edit a misconfigured /etc/vfstab file.
1. Insert the Unix 9 OE Software 1 of 2 CD-ROM into the CD-ROM drive.
2. Execute a single-user boot from the CD-ROM.
ok
boot cdrom -sBoot device: /pci@1f,0/pci@1,1/ide@3/cdrom@2,0:f File and args -s
SunOS Release 5.9 Generic 64 bit
Copyright 1983-2002 by Sun Microsystems, Inc. All rights reserved.
Configuring /dev and /devices
Use is subject to license terms
Using RPC Bootparams for network configuration information.
Skipping interface hme0
-
INIT: SINGLE USER MODE
#
Note – Performing a single-user boot operation from this software CD-ROM creates an in-memory copy of the /var file system, which supports your ability to perform administrative tasks.
3. Use the fsck command on the / (root) partition to check and repair any potential problems in the file system.
#
fsck /dev/rdsk/c0t0d0s04. If the fsck command is successful, mount the / (root) file system on the /a directory to gain access to the file system on disk.
#
mount /dev/dsk/c0t0d0s0 /a5. Set and export the TERM variable, which enables the vi editor to work properly.
#
TERM=sun#
export TERM6. Edit the /etc/vfstab file, and correct any problems. Then exit the file.
#
vi /a/etc/vfstab:wq!
#
cd /#
umount /a8. Reboot the system.
#
init 6To provide access to file systems on diskettes and CD-ROMs, the Unix provides users a standard interface referred to as Volume Management.
Note – The Unix 9 OE includes support for additional removable media such as DVDs, Jaz drives, Zip drives, and PCMCIA memory cards. (PCMCIA stands for Personal Computer Memory Card International Association.) For more information on using these devices, see the resources available on the Unix 9 Documentation CD.
Volume Management provides two major benefits:
l
It automatically mounts removable media for both the root user and non-root users.l
It can give other systems on the network automatic access to any removable media currently inserted in the local system.The Volume Management service is controlled by the /usr/sbin/vold daemon. By default, this service is always running on the system so that it can automatically manage diskettes and CD-ROMs for regular users.
Volume Management features automatic detection of CD-ROMs. However, it does not detect the presence of a diskette that has been inserted in the drive until the volcheck command is run. This command instructs the vold daemon to check the diskette drive for any inserted media. Volume Management can mount ufs , pcfs , hsfs , and udfs file systems.
To make working with diskettes and CD-ROMs simple for your users, each device is easy to mount and mounts at an easy-to-remember location.
If the vold daemon detects that the mounted device contains a file system, then the device is mounted at the directory location.
If the vold daemon detects that the mounted device does not contain a file system, the device is accessible through a path.
Media Device Access File Systems On
First diskette drive /floppy/floppy0
First CD-ROM or DVDdrive /cdrom/cdrom0
First Jaz drive /rmdisk/jaz0
First Zip drive /rmdrive/zip0
First PCMCIA card /pcmem0
Media Device Access Raw Device On
First diskette drive /vol/dev/aliases/floppy0
First CD-ROM or DVD drive /vol/dev/aliases/cdrom0
First Jaz drive /vol/dev/aliases/jaz0
First Zip drive /vol/dev/aliases/zip0
First PCMCIA card /vol/dev/aliases/pcmem0
When Volume Management is running on the system, a regular user can easily access a diskette or CD-ROM by following these basic steps:
Insert the media.
For diskettes only, enter the volcheck command.
Use the cd command to change to the directory of the mounted volume.
Work with files on the media.
Unmount the media.
Eject the media.
File Description
/etc/vold.conf
The Volume Management configuration file. This file defines items, such as what action should be taken when media is inserted or ejected, which devices are managed by Volume Management, and which file system types are unsafe to eject. /etc/rmmount.conf The rmmount command configuration file. The rmmount command is a removable media mounter that is executed by the Volume Management daemon whenever a CD-ROM or diskette is inserted.To restrict regular users from accessing diskettes or CD-ROMs on the system, you can, as the root user, terminate the Volume Management service.
To stop Volume Management from running on a system temporarily, as the root user perform the command:
#
/etc/init.d/volmgt stopTo restart the Volume Management service, as the root user perform the command:
#
/etc/init.d/volmgt startIf a CD-ROM fails to eject from the drive, as the root user attempt to stop Volume Management. If this is unsuccessful, kill the vold daemon.
#
/etc/init.d/volmgt stopor as a last resort:
#
pkill -9 voldPush the button on the system to eject the CD-ROM. The CD-ROM tray ejects. Remove the CD-ROM, and leave the tray out. Then restart the Volume Management service.
#
/etc/init.d/volmgt startWait a few seconds, and then push the CD-ROM tray back into the drive.
When Volume Management is not running, only the root user can mount
and access a diskette or CD-ROM. Follow these steps:
Insert the media device.
Become the root user.
Create a mount point, if necessary.
Determine the file system type.
Mount the device by using the mount options listed in the following Sections.
Work with files on the media device.
Unmount the media device.
Eject the media device.
Exit the root session.
To mount a file system that resides on a CD-ROM when the Volume Management services are stopped, as the root user, perform the command:
# mount -F hsfs -o ro /dev/dsk/c0t6d0s0 /cdrom
In this example, the file system type is hsfs , the file system resides on disk slice /dev/dsk/c0t6d0s0 , and the mount point /cdrom is a pre-existing directory in the Unix.
To mount a file system that resides on a diskette when the Volume Management services are stopped, as the root user, perform the command:
#
mkdir /pcfs#
mount -F pcfs /dev/diskette /pcfsIn this example, the file system type is pcfs. This file system resides on the /dev/diskette device, and the mount point used is /pcfs .
Last modified: March 12, 2019