After you create a file system, you need to make it available. You make file systems available by mounting them. A mounted file system is attached to the system directory tree at the specified mount point, and becomes available to the system. The root (/) file system is always mounted. Any other file system can be connected or disconnected from the root (/) file system.
You can mount a local file system in these ways:
By creating an entry in the /etc/vfstab (virtual file system table) file. The /etc/vfstab file contains a list of file systems that are automatically mounted when the system is booted to multiuser state.
From the command line by using the mount command.
When file systems are shared from a server, a client can mount them as NFS file systems in any of these three ways:
By adding an entry to the /etc/vfstab file so that the file system is automatically mounted when the system is booted to multiuser state.
By using AutoFS to automatically mount or unmount the file system when a user changes into (mount) or out of (umount) the directory. See the NFS Administration Guide for information about AutoFS.
By using the mount command from the command line.
CD-ROMs containing file systems are mounted when the CD-ROM is inserted. Diskettes containing file systems are mounted by running the volcheck(1) command.
The prerequisites to mount file systems are:
You must be superuser.
There must be a mount point on the local system to mount a file system. A mount point is a directory to which the mounted file system is attached.
To verify that you mounted a file system or a number of file systems, look at the output from the mount command. This is described in "How to See Which File Systems Are Mounted".
Table 28-1 lists the commands in the /usr/sbin directory that you use to mount and unmount file systems.
Table 28-1 Commands for Mounting and Unmounting File Systems
Command |
Description |
---|---|
mount(1M) |
Mounts file systems and remote resources. |
mountall(1M) |
Mounts all file systems specified in the /etc/vfstab file. The mountall command is run automatically when entering multiuser run states. |
umount(1M) |
Unmounts file systems and remote resources. |
umountall(1M) |
Unmounts all file systems specified in the /etc/vfstab file. |
The mount commands will not mount a read/write file system that has inconsistencies. If you receive an error message from the mount or mountall command, you may need to check the file system. See Chapter 31, Checking File System Integrity for information on how to check the file system.
The umount commands will not unmount a file system that is 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.
Table 28-2 describes the general mount options that you can specify with the -o option of the mount command. If you specify multiple options, separate them with commas (no spaces). For example, -o ro,nosuid.
Table 28-2 General Mount Options
Option |
File System |
Description |
---|---|---|
-rw | ro |
CacheFS, NFS, PCFS, UFS, S5FS |
Specifies read/write or read-only. If you do not specify this option, the default is read/write. |
-nosuid |
HSFS, NFS, UFS |
Disallows setuid execution and prevents devices on the file system from being opened. The default is to allow setuid execution and allow devices to be opened. |
-remount |
NFS, UFS, S5FS |
With rw, remounts a file system with read/write access. |
-f |
UFS, S5FS |
Fakes an entry in /etc/mnttab, but doesn't really mount any file systems. |
-n |
UFS, S5FS |
Mounts the file system without making an entry in /etc/mnttab. |
-bg | fg |
NFS |
If the first attempt fails, retries in the background (bg) or in the foreground (fg). The default is fg. |
-soft | hard |
NFS |
Specifies the procedure if the server does not respond. soft indicates that an error is returned. hard indicates that the retry request is continued until the server responds. The default is hard. |
-intr | nointr |
NFS |
Specifies whether keyboard interrupts are allowed to kill a process hung while waiting for a response on hard-mounted file systems. The default is intr (interrupts allowed). |
-retry=n |
NFS |
Retries the mount operation when it fails. n is the number of times to retry. |
An entry in the /etc/vfstab file has seven fields, which are described in Table 28-3.
Table 28-3 Field Descriptions of the /etc/vfstab File
Field Name |
Description |
---|---|
device to mount |
The device to mount can be:
|
device to fsck |
The raw (character) special device that corresponds to the file system identified by the device to mount field (for example, /dev/rdsk/c0t0d0s0). This determines the raw interface that is used by fsck. Use a dash (-) when there is no applicable device, such as for a read-only file system or a remote file system. |
mount point |
The default mount point directory (for example, /usr for /dev/dsk/c0t0d0s6).
|
FS type |
The type of file system identified by the device to mount field. |
fsck pass |
The pass number used by fsck to decide whether to check a file system. When the field contains a dash (-), the file system is not checked. When the field contains a value greater than zero, the file system is checked; non-UFS file systems with a zero value for fsck pass are checked. For UFS file systems only, when the field contains a zero, the file system is not checked. When fsck is run on multiple UFS file systems that have fsck pass values greater than one and the preen option (-o p) is used, fsck automatically checks the file systems on different disks in parallel to maximize efficiency. When the field contains a value of 1, the file system is checked sequentially. Otherwise, the value of the pass number does not have any effect. In SunOS system software, the fsck pass field does not explicitly specify the order in which file systems are checked. |
mount at boot |
Set to yes or no for whether the file system should be automatically mounted by mountall when the system is booted. Note that this field has nothing to do with AutoFS. |
mount options |
A list of comma-separated options (with no spaces) that are used in mounting the file system. Use a dash (-) to show no options. See mount(1M) for a list of the available options. |
You must have an entry in each field in the /etc/vfstab file. If there is no value for the field, be sure to enter a dash (-).
To see which file systems are mounted:
$ mount |
$ mount / on /dev/dsk/c0t3d0s0 read/write/setuid/largefiles on ... /usr on /dev/dsk/c0t3d0s6 read/write/setuid/largefiles on ... /proc on /proc read/write/setuid on Fri May 16 11:39:05 1997 /dev/fd on fd read/write/setuid on Fri May 16 11:39:05 1997 /export on /dev/dsk/c0t3d0s3 setuid/read/write/largefiles on ... /export/home on /dev/dsk/c0t3d0s7 setuid/read/write/largefiles on ... /export/swap on /dev/dsk/c0t3d0s4 setuid/read/write/largefiles on ... /opt on /dev/dsk/c0t3d0s5 setuid/read/write/largefiles on ... /tmp on swap read/write on Fri May 16 11:39:07 1997 $ |
Make sure you have met the prerequisites listed on "Prerequisites".
Edit the /etc/vfstab file and add an entry.
See Table 28-3for detailed information about the /etc/vfstab field entries. Make sure you:
Separate each field with white space (a space or a tab).
Enter a dash (-) if a field has no contents.
Save the changes.
#device device mount FS fsck mount mount #to mount to fsck point type pass at boot options # /dev/dsk/c0t3d0s7 /dev/rdsk/c0t3d0s7 /files1 ufs 2 yes - pluto:/export/man - /usr/man nfs - yes ro,soft / - /tmp/newroot lofs - yes - |
This example mounts the disk slice /dev/dsk/c0t3d0s7 as a UFS file system attached to the mount point directory /files1 with the default mount options (read/write). It specifies the raw character device /dev/rdsk/c0t3d0s7 as the device to fsck. The fsck pass value of 2 means that the file system will be checked, but not sequentially.
This example mounts the directory /export/man from the system pluto as an NFS file system on mount point /usr/man. It does not specify a device to fsck or a fsck pass because it's an NFS file system. In this example, mount options are ro (read-only) and soft. For greater reliability, specify the hard mount option for read/write NFS file systems.
This example mounts the root (/) file system on a loopback mount point named /tmp/newroot. It specifies yes for mount at boot, no device to fsck, and no fsck pass number. Loopback file systems must always be mounted after the file systems used to make up the loopback file system. Be sure that the loopback entry is the last entry in the /etc/vfstab file so that it follows the entries that it depends on.
Make sure you have met the prerequisites listed on "Prerequisites".
Mount the file systems listed in the /etc/vfstab file.
# mountall [-l | -r] [-F fstype] |
If no options are specified, all file systems listed in the /etc/vfstab file with yes in the mount at boot field are mounted.
-l |
Mounts all the local file systems listed in the /etc/vfstab file with yes in the mount at boot field. |
-r |
Mounts all the remote file systems listed in the /etc/vfstab file with yes in the mount at boot field. |
-F fstype |
Mounts all file systems of the type fstype listed in the /etc/vfstab file with yes in the mount at boot field. |
All the file systems with a device to fsck entry are checked and fixed, if necessary, before mounting.
This example shows the messages displayed if file systems are already mounted when you use the mountall command.
# mountall mount: /tmp already mounted nfs mount: mount: /usr/openwin: Device busy nfs mount: mount: /usr/man: Device busy |
This example mounts all the local systems listed in the /etc/vfstab file.
# mountall -l # mount / on /dev/dsk/c0t3d0s0 read/write/setuid/largefiles on ... /usr on /dev/dsk/c0t3d0s6 read/write/setuid/largefiles on ... /proc on /proc read/write/setuid on Fri May 16 11:39:05 1997 /dev/fd on fd read/write/setuid on Fri May 16 11:39:05 1997 /tmp on swap read/write on Fri May 16 11:39:07 1997 |
This example mounts all the remote file systems listed in the /etc/vfstab file.
# mountall -r # mount / on /dev/dsk/c0t3d0s0 read/write/setuid/largefiles on ... /usr on /dev/dsk/c0t3d0s6 read/write/setuid/largefiles on ... /proc on /proc read/write/setuid on Fri May 16 11:39:05 1997 /dev/fd on fd read/write/setuid on Fri May 16 11:39:05 1997 /tmp on swap read/write on Fri May 16 11:39:07 1997 /nfs/mars.dist on mars:/usr/dist intr/remote on ... /nfs/mars.mail on mars:/var/mail intr/noac/remote on ... |
Make sure you have met the prerequisites listed in "Prerequisites".
Mount a file system listed in the /etc/vfstab file.
# mount mount-point |
mount-point |
An entry in the mount point or device to mount field in the /etc/vfstab file. It is usually easier to specify the mount point. |
This example mounts the /usr/openwin file system listed in the /etc/vfstab file.
# mount /usr/openwin |
Make sure you have met the prerequisites listed in "Prerequisites".
Mount the UFS file system.
# mount [-o mount-options] /dev/dsk/device-namemount-point |
-o mount-options |
Specifies mount options that you can use to mount a UFS file system. See Table 28-2 for the list of general mount options or mount_ufs(1M) for a complete list of options. |
/dev/dsk/device-name |
The special block device file for the disk slice holding the file system (for example, /dev/dsk/c0t3d0s7). See Chapter 26, File Systems (Overview) for information about how to find out disk device names. |
mount-point |
The directory where the file system is mounted. |
In this example, /dev/dsk/c0t3d0s7 is mounted on the /files1 directory.
# mount /dev/dsk/c0t3d0s7 /files1 |
The new largefiles mount option, the default state for the Solaris 2.6 environment, allows users to mount a file system containing files larger than 2Gbytes.
The procedure for mounting file systems with large files is identical to the one described previously in "How to Mount a UFS File System".
The largefiles option means that a file system mounted with this option may contain one or more files larger than 2 Gbytes. It is not required that a file system mounted with this option contain files larger that 2Gbytes, but the option allows such files within the file system.
You must explicitly use the nolargefiles mount option to disable this behavior. The nolargefiles option provides total compatibility with previous file system behavior, enforcing the 2 Gbytes maximum file size limit.
After you mount a file system with the default largefiles mount option and large files have been created, you cannot remount the file system with the nolargefiles option until you remove any large files and run fsck to reset the state to nolargefiles.
Become superuser.
Make sure there are no large files in the file system.
# cd /file-system # find . xdev -size +2000000 -exec ls -l {} \; |
file-system |
The file system you want to check for large files. |
If large files exist within this file system, they must be removed or moved to another file system.
Unmount the file system.
# umount /file-system |
Reset the file system state.
# fsck /dev/rdsk/device-name |
Remount the file system with the nolargefiles option.
# mount -o nolargefiles /dev/rdsk/device-name |
In this example, /datab is checked for large files and /dev/dsk/c0t3d0s7 is then mounted on the /datab directory.
# cd /datab # find . xdev -size +2000000 -exec ls -l {} \; # find . xdev -size +2000000 -exec ls -l {} \; # umount /datab # fsck /dev/rdsk/c0t3d0s7 /files1 # mount -o nolargefiles /dev/dsk/c0t3d0s7 /files1 |
Make sure you have met the prerequisites listed in "Prerequisites".
Make sure the file system is available from a server.
To mount an NFS file system, it must be made available from the server system. The share(1M) command creates a list of file systems on a server that can be shared across the network. See NFS Administration Guide for information on how to share file systems.
Mount the NFS file system.
# mount -F nfs [-o mount-options] server:/directory mount-point |
-o mount-options |
Specifies mount options that you can use to mount a NFS file system. See Table 28-2 for the list of general mount options or mount_nfs(1M) for a complete list of options. |
server:/directory |
The server's host name on which the file system is mounted, and the name of the file system to mount. |
mount-point |
The directory where the file system is mounted. |
In this example, packages from the server pluto in the directory /export/packages are mounted on /mnt.
# mount -F nfs pluto:/export/packages /mnt |
Make sure you have met the prerequisites listed in "Prerequisites".
Mount the S5FS file system.
# mount -F s5fs [-o mount-options] /dev/dsk/device_name mount-point |
-o mount-options |
Specifies mount options that you can use to mount a S5FS file system. See Table 28-2 for the list of common mount options or mount_s5fs(1M) for a complete list of options. |
/dev/dsk/device-name |
The device name of the disk slice holding the file system (for example, /dev/dsk/c0t3d0s7). See Chapter 20, Accessing Devices (Overview) for information about finding out disk device names. |
mount-point |
The directory where the file system is mounted. |
In this example, /dev/dsk/c0t3d0s7 is mounted on the /files1 directory.
# mount -F s5fs /dev/dsk/c0t3d0s7 /files1 |
Use the following procedure to mount a PCFS (DOS) file system from a hard disk.
Make sure you have met the prerequisites listed oin "Prerequisites".
Mount the PCFS file system.
# mount -F pcfs [-o rw | ro] /dev/dsk/device-name:logical-drive mount-point |
-o rw | ro |
Specifies that you can mount a PCFS file system read/write or read-only. If you do not specify this option, the default is read/write. |
/dev/dsk/device-name |
The device name of the whole disk (for example, /dev/dsk/c0t0d0p0). |
logical-drive |
Specifies either the DOS logical drive letter (c through z) or a drive number 1 through 24. Drive c is equivalent to drive 1 and represents the Primary DOS slice on the drive; all other letters or numbers represent DOS logical drives within the Extended DOS slice. |
mount-point |
The directory where the file system is mounted. |
Note that the device-name and logical-drive must be separated by a colon.
In this example, the logical drive in the Primary DOS slice is mounted on the /pcfs/c directory.
# mount -F pcfs /dev/dsk/c0t0d0p0:c /pcfs/c |
In this example, the first logical drive in the Extended DOS slice on the disk is mounted read-only on /pcfs/d.
# mount -F pcfs -o ro /dev/dsk/c0t0d0p0:2 /pcfs/d |