System Administration Guide: Devices and File Systems

Mounting File Systems

The following sections describe how to mount a file system by adding an entry in the /etc/vfstab file or by using the mount command from the command line.

How to Determine Which File Systems Are Mounted

You can determine which file systems are already mounted by using the mount command.


$ mount [ -v ]
-v

Displays the list of mounted file systems in verbose mode.


Example 17–1 Determining Which File Systems Are Mounted

This example shows how to use the mount command to display information about the file systems that are currently mounted.


$ mount
/ on /dev/dsk/c0t0d0s0 read/write/setuid/intr/largefiles/xattr/onerror=...
/devices on /devices read/write/setuid/dev=46c0000 on Thu Jan  ...
/usr on /dev/dsk/c0t0d0s6 read/write/setuid/intr/largefiles/xattr/...
/proc on /proc read/write/setuid/dev=4700000 on Thu Jan  8 ...
/etc/mnttab on mnttab read/write/setuid/dev=47c0000 on Thu Jan  8 ...
/dev/fd on fd read/write/setuid/dev=4800000 on Thu Jan  8 ...
/var/run on swap read/write/setuid/xattr/dev=1 on Thu Jan  8 ...
/tmp on swap read/write/setuid/xattr/dev=2 on Thu Jan  8 ...
/stuff on /dev/dsk/c0t0d0s5 read/write/setuid/intr/largefiles/xattr...
/export/home on /dev/dsk/c0t0d0s7 read/write/setuid/intr/largefiles/...
/home/rimmer on pluto:/export/home/rimmer remote/read/write/setuid/xattr/...
$

ProcedureHow to Add an Entry to the /etc/vfstab File

Steps
  1. Become superuser or assume an equivalent role.

  2. Create a mount point for the file system to be mounted, if necessary.


    # mkdir /mount-point
    

    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.

  3. Edit the /etc/vfstab file and add an entry. Make sure that you do the following:

    1. Separate each field with white space (a space or a tab).

    2. Enter a dash (-) if a field has no contents.

    3. Save the changes.

    For detailed information about the /etc/vfstab field entries, see Table 17–3.


    Note –

    Since the root (/) file system is mounted read-only by the kernel during the boot process, only the remount option (and options that can be used in conjunction with remount) affect the root (/) entry in the /etc/vfstab file.



Example 17–2 Adding an Entry to the /etc/vfstab File

The following example shows how to mount the disk slice /dev/dsk/c0t3d0s7 as a UFS file system to the mount point directory /files1. The raw character device /dev/rdsk/c0t3d0s7 is specified as the device to fsck. The fsck pass value of 2 means that the file system will be checked, but not sequentially.


#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       -

The following example shows how to mount the /export/man directory from the system pluto as an NFS file system on mount point /usr/man. A device to fsck nor a fsck pass is specified because it's an NFS file system. In this example, mount options are ro (read-only) and soft.


#device           device             mount    FS       fsck   mount    mount
#to mount         to fsck            point    type     pass   at boot  options
pluto:/export/man   -                /usr/man nfs      -      yes       ro,soft

The following example shows how to mount the root (/) file system on a loopback mount point, /tmp/newroot. LOFS file systems must always be mounted after the file systems that are in the LOFS file system.


#device           device             mount    FS       fsck   mount    mount
#to mount         to fsck            point    type     pass   at boot  options
#
/                   -                /tmp/newroot lofs -      yes       -                   

ProcedureHow to Mount a File System (/etc/vfstab File)

Steps
  1. Become superuser or assume an equivalent role.

  2. Mount a file system listed in the /etc/vfstab file.


    # mount /mount-point
    

    /mount-point specifies 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.


Example 17–3 Mounting a File System (/etc/vfstab File)

The following example shows how to mount the /usr/dist file system that is listed in the /etc/vfstab file.


# mount /usr/dist


Example 17–4 Mounting All File Systems (/etc/vfstab File)

The following example shows the messages that are displayed if file systems are already mounted when you use the mountall command.


# mountall
/dev/rdsk/c0t0d0s7 already mounted
mount: /tmp already mounted
mount: /dev/dsk/c0t0d0s7 is already mounted, /export/home is busy,
        or the allowable number of mount points has been exceeded

All the file systems with a device to fsck entry are checked and fixed, if necessary, before they are mounted.

The following example shows how to mount all the local systems that are listed in the /etc/vfstab file.


# mountall -l
# mount
/ on /dev/dsk/c0t0d0s0 read/write/setuid/intr/largefiles/xattr/onerror=...
/devices on /devices read/write/setuid/dev=46c0000 on Thu Jan  8 ...
/usr on /dev/dsk/c0t0d0s6 read/write/setuid/intr/largefiles/xattr/...
/proc on /proc read/write/setuid/dev=4700000 on Thu Jan  8 ...
/etc/mnttab on mnttab read/write/setuid/dev=47c0000 on Thu Jan  8 ...
/dev/fd on fd read/write/setuid/dev=4800000 on Thu Jan  8 09:38:30 2004
/var/run on swap read/write/setuid/xattr/dev=1 on Thu Jan  8 ...
/tmp on swap read/write/setuid/xattr/dev=2 on Thu Jan  8 09:38:30 2004
/stuff on /dev/dsk/c0t0d0s5 read/write/setuid/intr/largefiles/xattr...
/export/home on /dev/dsk/c0t0d0s7 read/write/setuid/intr/largefiles/...

The following example shows how to mount all of the remote file systems that are listed in the /etc/vfstab file.


# mountall -r
# mount
/ on /dev/dsk/c0t0d0s0 read/write/setuid/intr/largefiles/xattr/onerror=...
/devices on /devices read/write/setuid/dev=46c0000 on Thu Jan  8 ...
/usr on /dev/dsk/c0t0d0s6 read/write/setuid/intr/largefiles/xattr/...
/proc on /proc read/write/setuid/dev=4700000 on Thu Jan  8 ...
/etc/mnttab on mnttab read/write/setuid/dev=47c0000 on Thu Jan  8 ...
/dev/fd on fd read/write/setuid/dev=4800000 on Thu Jan  8 ...
/var/run on swap read/write/setuid/xattr/dev=1 on Thu Jan  8 ...
/tmp on swap read/write/setuid/xattr/dev=2 on Thu Jan  8 09:38:30 2004
/stuff on /dev/dsk/c0t0d0s5 read/write/setuid/intr/largefiles/xattr...
/export/home on /dev/dsk/c0t0d0s7 read/write/setuid/intr/largefiles/...
/home/rimmer on pluto:/export/home/rimmer remote/read/write/setuid/xattr/...

ProcedureHow to Mount a UFS File System (mount Command)

Steps
  1. Become superuser or assume an equivalent role.

  2. Create a mount point for the file system to be mounted, if necessary.


    # mkdir /mount-point
    

    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.

  3. Mount the UFS file system.


    # mount [-o mount-options] /dev/dsk/device-name /mount-point
    
    -o mount-options

    Specifies mount options that you can use to mount a UFS file system. For a list of options, see Table 17–2 or mount_ufs(1M).

    /dev/dsk/device-name

    Specifies the disk device name for the slice that contains the file system (for example, /dev/dsk/c0t3d0s7). To get slice information for a disk, see How to Display Disk Slice Information.

    /mount-point

    Specifies the directory on which to mount the file system.


Example 17–5 Mounting a UFS File System (mount Command)

The following example shows how to mount /dev/dsk/c0t3d0s7 on the /files1 directory.


# mount /dev/dsk/c0t3d0s7 /files1

ProcedureHow to Mount a UFS File System Without Large Files (mount Command)

When you mount a file system, the largefiles option is selected by default, which enables you to create files larger than 2 Gbytes. Once a file system contains large files, you cannot remount the file system with the nolargefiles option or mount it on a system that is running Solaris 2.6 or compatible versions, until you remove any large files and run the fsck command to reset the state to nolargefiles.

This procedure assumes that the file system is in the /etc/vfstab file.

Steps
  1. Become superuser or assume an equivalent role.

  2. Create a mount point for the file system to be mounted, if necessary.


    # mkdir /mount-point
    

    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.

  3. Make sure there are no large files in the file system.


    # cd /mount-point
    # find . -xdev -size +20000000 -exec ls -l {} \;
    

    /mount-point identifies the mount point of the file system you want to check for large files.

  4. Remove or move any large files in this file system to another file system, if necessary.

  5. Unmount the file system.


    # umount /mount-point
    
  6. Reset the file system state.


    # fsck /mount-point
    
  7. Remount the file system with the nolargefiles option.


    # mount -o nolargefiles /mount-point
    

Example 17–6 Mounting a File System Without Large Files (mount Command)

The following example shows how to check the /datab file system and remount it with the nolargefiles option.


# cd /datab
# find . -xdev -size +20000000 -exec ls -l {} \;
# umount /datab 
# fsck /datab
# mount -o nolargefiles /datab

ProcedureHow to Mount an NFS File System (mount Command)

Steps
  1. Become superuser or assume an equivalent role.

  2. Create a mount point for the file system to be mounted, if necessary.


    # mkdir /mount-point
    

    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.

  3. Make sure the resource (file or directory) is available from a server.

    To mount an NFS file system, the resource must be made available on the server by using the share command. For information on how to share resources, see About the NFS Service in System Administration Guide: Resource Management and Network Services.

  4. 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 an NFS file system. See Table 17–2 for the list of commonly used mount options or mount_nfs(1M) for a complete list of options.

    server:/directory

    Specifies the server's host name that contains the shared resource, and the path to the file or directory to mount.

    /mount-point

    Specifies the directory on which to mount the file system.


Example 17–7 Mounting an NFS File System (mount Command)

The following example shows how to mount the /export/packages directory on /mnt from the server pluto.


# mount -F nfs pluto:/export/packages /mnt

Procedurex86: How to Mount a PCFS (DOS) File System From a Hard Disk (mount Command)

Use the following procedure to mount a PCFS (DOS) file system from a hard disk.

Steps
  1. Become superuser or assume an equivalent role.

  2. Create a mount point for the file system to be mounted, if necessary.


    # mkdir /mount-point
    

    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.

  3. 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 (rw) or read-only (ro). If you do not specify this option, the default is rw.

    /dev/dsk/device-name

    Specifies 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

    Specifies the directory on which to mount the file system.

    Note that the device-name and logical-drive must be separated by a colon.


Example 17–8 x86: Mounting a PCFS (DOS) File System From a Hard Disk (mount Command)

The following example shows how to mount the logical drive in the primary DOS slice on the /pcfs/c directory.


# mount -F pcfs /dev/dsk/c0t0d0p0:c /pcfs/c

The following example shows how to mount the first logical drive in the extended DOS slice read-only on /mnt.


# mount -F pcfs -o ro /dev/dsk/c0t0d0p0:2 /mnt