Linux does not prevent a user from mounting a file system to a directory with a file system already attached to it. To determine whether a particular directory serves as a mount point, run the 9 utility with the directory as its argument and verify the exit code: Show
If no file system is attached to the directory, the given command returns 0. When you run the 5 command without all required information, that is without the device name, the target directory, or the file system type, the 5 reads the contents of the 3 file to check if the given file system is listed. The 3 file contains a list of device names and the directories in which the selected file systems are set to be mounted as well as the file system type and mount options. Therefore, when mounting a file system that is specified in 3, you can choose one of the following options:
Note that permissions are required to mount the file systems unless the command is run as 6 (see Section 19.2.2, “Specifying the Mount Options”). Note To determine the UUID and—if the device uses it—the label of a particular device, use the 7 command in the following form:
For example, to display information about 6:
19.2.1. Specifying the File System TypeIn most cases, 5 detects the file system automatically. However, there are certain file systems, such as ~]# 0 (Network File System) or ~]# 1 (Common Internet File System), that are not recognized, and need to be specified manually. To specify the file system type, use the 5 command in the following form:
Table 19.1, “Common File System Types” provides a list of common file system types that can be used with the 5 command. For a complete list of all available file system types, see the section called “Manual Page Documentation”. Table 19.1. Common File System Types TypeDescription ~]# 4The ~]# 4 file system.~]# 6The ~]# 6 file system.~]# 8The ~]# 8 file system.0The 0 file system. 2The 2 file system. 4The 5 file system. It is commonly used by optical media, typically CDs. 6The ~]# 0 file system. It is commonly used to access files over the network.8The 9 file system. It is commonly used to access files over the network. 0The 1 file system. It is commonly used by optical media, typically DVDs. 2The 3 file system. It is commonly used on machines that are running the Windows operating system, and on certain digital media such as USB flash drives or floppy disks. See Example 19.2, “Mounting a USB Flash Drive” for an example usage. Example 19.2. Mounting a USB Flash Drive Older USB flash drives often use the FAT file system. Assuming that such drive uses the 4 device and that the 5 directory exists, mount it to this directory by typing the following at a shell prompt as 6: ~]# 19.2.2. Specifying the Mount OptionsTo specify additional mount options, use the command in the following form:
When supplying multiple options, do not insert a space after a comma, or 5 interprets incorrectly the values following spaces as additional parameters. Table 19.2, “Common Mount Options” provides a list of common mount options. For a complete list of all available options, consult the relevant manual page as referred to in the section called “Manual Page Documentation”. Table 19.2. Common Mount Options OptionDescription 8Allows the asynchronous input/output operations on the file system. 9Allows the file system to be mounted automatically using the 0 command. 1Provides an alias for 2. 3Allows the execution of binary files on the particular file system. 4Mounts an image as a loop device. 5Default behavior disallows the automatic mount of the file system using the 0 command. 7Disallows the execution of binary files on the particular file system. 8Disallows an ordinary user (that is, other than 6) to mount and unmount the file system. 00Remounts the file system in case it is already mounted. 01Mounts the file system for reading only. 02Mounts the file system for both reading and writing. 03Allows an ordinary user (that is, other than 6) to mount and unmount the file system. See Example 19.3, “Mounting an ISO Image” for an example usage. Example 19.3. Mounting an ISO Image An ISO image (or a disk image in general) can be mounted by using the loop device. Assuming that the ISO image of the Fedora 14 installation disc is present in the current working directory and that the 05 directory exists, mount the image to this directory by running the following command:
Note that ISO 9660 is by design a read-only file system. 19.2.3. Sharing MountsOccasionally, certain system administration tasks require access to the same file system from more than one place in the directory tree (for example, when preparing a chroot environment). This is possible, and Linux allows you to mount the same file system to as many directories as necessary. Additionally, the 5 command implements the 07 option that provides a means for duplicating certain mounts. Its usage is as follows:
Although this command allows a user to access the file system from both places, it does not apply on the file systems that are mounted within the original directory. To include these mounts as well, use the following command: 0 Additionally, to provide as much flexibility as possible, Red Hat Enterprise Linux 7 implements the functionality known as shared subtrees. This feature allows the use of the following four mount types: Shared Mount A shared mount allows the creation of an exact replica of a given mount point. When a mount point is marked as a shared mount, any mount within the original mount point is reflected in it, and vice versa. To change the type of a mount point to a shared mount, type the following at a shell prompt: 1 Alternatively, to change the mount type for the selected mount point and all mount points under it: 2 See Example 19.4, “Creating a Shared Mount Point” for an example usage. Example 19.4. Creating a Shared Mount Point There are two places where other file systems are commonly mounted: the 08 directory for removable media, and the 09 directory for temporarily mounted file systems. By using a shared mount, you can make these two directories share the same content. To do so, as 6, mark the 08 directory as shared: 3 Create its duplicate in 09 by using the following command: 4 It is now possible to verify that a mount within 08 also appears in 09. For example, if the CD-ROM drive contains non-empty media and the 05 directory exists, run the following commands: 5 Similarly, it is possible to verify that any file system mounted in the 09 directory is reflected in 08. For instance, if a non-empty USB flash drive that uses the 4 device is plugged in and the 19 directory is present, type: 6Slave Mount A slave mount allows the creation of a limited duplicate of a given mount point. When a mount point is marked as a slave mount, any mount within the original mount point is reflected in it, but no mount within a slave mount is reflected in its original. To change the type of a mount point to a slave mount, type the following at a shell prompt: 7 Alternatively, it is possible to change the mount type for the selected mount point and all mount points under it by typing: 8 See Example 19.5, “Creating a Slave Mount Point” for an example usage. Example 19.5. Creating a Slave Mount Point This example shows how to get the content of the 08 directory to appear in 09 as well, but without any mounts in the 09 directory to be reflected in 08. As 6, first mark the 08 directory as shared: 9 Then create its duplicate in 09, but mark it as "slave": 0 Now verify that a mount within 08 also appears in 09. For example, if the CD-ROM drive contains non-empty media and the 05 directory exists, run the following commands: 1 Also verify that file systems mounted in the 09 directory are not reflected in 08. For instance, if a non-empty USB flash drive that uses the 4 device is plugged in and the 19 directory is present, type: 2Private Mount A private mount is the default type of mount, and unlike a shared or slave mount, it does not receive or forward any propagation events. To explicitly mark a mount point as a private mount, type the following at a shell prompt: 3 Alternatively, it is possible to change the mount type for the selected mount point and all mount points under it: 4 See Example 19.6, “Creating a Private Mount Point” for an example usage. Example 19.6. Creating a Private Mount Point Taking into account the scenario in Example 19.4, “Creating a Shared Mount Point”, assume that a shared mount point has been previously created by using the following commands as 6: 5 To mark the 09 directory as private, type: 6 It is now possible to verify that none of the mounts within 08 appears in 09. For example, if the CD-ROM drives contains non-empty media and the 05 directory exists, run the following commands: 7 It is also possible to verify that file systems mounted in the 09 directory are not reflected in 08. For instance, if a non-empty USB flash drive that uses the 4 device is plugged in and the 19 directory is present, type: 2Unbindable Mount In order to prevent a given mount point from being duplicated whatsoever, an unbindable mount is used. To change the type of a mount point to an unbindable mount, type the following at a shell prompt: 9 Alternatively, it is possible to change the mount type for the selected mount point and all mount points under it: 0See Example 19.7, “Creating an Unbindable Mount Point” for an example usage. Example 19.7. Creating an Unbindable Mount Point To prevent the 08 directory from being shared, as 6: 1This way, any subsequent attempt to make a duplicate of this mount fails with an error: 219.2.4. Moving a Mount PointTo change the directory in which a file system is mounted, use the following command: 3See Example 19.8, “Moving an Existing NFS Mount Point” for an example usage. Example 19.8. Moving an Existing NFS Mount Point An NFS storage contains user directories and is already mounted in 45. As 6, move this mount point to 47 by using the following command: 4To verify the mount point has been moved, list the content of both directories: 519.2.5. Setting Read-only Permissions for $ mount -t type device directory6Sometimes, you need to mount the root file system with read-only permissions. Example use cases include enhancing security or ensuring data integrity after an unexpected system power-off. 19.2.5.1. Configuring $ mount -t type device directory |