Questo contenuto non è disponibile nella lingua selezionata.
Chapter 29. Mounting file systems
As a system administrator, you can mount file systems on your system to access data on them.
29.1. The Linux mount mechanism
These are the basic concepts of mounting file systems on Linux.
On Linux, UNIX, and similar operating systems, file systems on different partitions and removable devices (CDs, DVDs, or USB flash drives for example) can be attached to a certain point (the mount point) in the directory tree, and then detached again. While a file system is mounted on a directory, the original content of the directory is not accessible.
Note that Linux does not prevent you from mounting a file system to a directory with a file system already attached to it.
When mounting, you can identify the device by:
- 
							a universally unique identifier (UUID): for example, UUID=34795a28-ca6d-4fd8-a347-73671d0c19cb
- 
							a volume label: for example, LABEL=home
- 
							a full path to a non-persistent block device: for example, /dev/sda3
					When you mount a file system using the mount command without all required information, that is without the device name, the target directory, or the file system type, the mount utility reads the content of the /etc/fstab file to check if the given file system is listed there. The /etc/fstab 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 /etc/fstab, the following command syntax is sufficient:
				
- Mounting by the mount point: - mount directory - # mount directory- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Mounting by the block device: - mount device - # mount device- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
29.2. Listing currently mounted file systems
					List all currently mounted file systems on the command line by using the findmnt utility.
				
Procedure
- To list all mounted file systems, use the - findmntutility:- findmnt - $ findmnt- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- To limit the listed file systems only to a certain file system type, add the - --typesoption:- findmnt --types fs-type - $ findmnt --types fs-type- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - For example: - Example 29.1. Listing only XFS file systems - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
29.3. Mounting a file system with mount
					Mount a file system by using the mount utility.
				
Prerequisites
- Verify that no file system is already mounted on your chosen mount point: - findmnt mount-point - $ findmnt mount-point- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
Procedure
- To attach a certain file system, use the - mountutility:- mount device mount-point - # mount device mount-point- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - Example 29.2. Mounting an XFS file system - For example, to mount a local XFS file system identified by UUID: - mount UUID=ea74bbec-536d-490c-b8d9-5b40bbd7545b /mnt/data - # mount UUID=ea74bbec-536d-490c-b8d9-5b40bbd7545b /mnt/data- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- If - mountcannot recognize the file system type automatically, specify it using the- --typesoption:- mount --types type device mount-point - # mount --types type device mount-point- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - Example 29.3. Mounting an NFS file system - For example, to mount a remote NFS file system: - mount --types nfs4 host:/remote-export /mnt/nfs - # mount --types nfs4 host:/remote-export /mnt/nfs- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
29.4. Moving a mount point
					Change the mount point of a mounted file system to a different directory by using the mount utility.
				
Procedure
- To change the directory in which a file system is mounted: - mount --move old-directory new-directory - # mount --move old-directory new-directory- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - Example 29.4. Moving a home file system - For example, to move the file system mounted in the - /mnt/userdirs/directory to the- /home/mount point:- mount --move /mnt/userdirs /home - # mount --move /mnt/userdirs /home- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Verify that the file system has been moved as expected: - findmnt ls old-directory ls new-directory - $ findmnt $ ls old-directory $ ls new-directory- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
29.5. Unmounting a file system with umount
					Unmount a file system by using the umount utility.
				
Procedure
- Try unmounting the file system using either of the following commands: - By mount point: - umount mount-point - # umount mount-point- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- By device: - umount device - # umount device- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
 - If the command fails with an error similar to the following, it means that the file system is in use because of a process is using resources on it: - umount: /run/media/user/FlashDrive: target is busy. - umount: /run/media/user/FlashDrive: target is busy.- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- If the file system is in use, use the - fuserutility to determine which processes are accessing it. For example:- fuser --mount /run/media/user/FlashDrive /run/media/user/FlashDrive: 18351 - $ fuser --mount /run/media/user/FlashDrive /run/media/user/FlashDrive: 18351- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - Afterwards, stop the processes using the file system and try unmounting it again. 
29.6. Mounting and unmounting file systems in the web console
To be able to use partitions on RHEL systems, you need to mount a file system on the partition as a device.
You also can unmount a file system and the RHEL system will stop using it. Unmounting the file system enables you to delete, remove, or re-format devices.
Prerequisites
- 
							The cockpit-storagedpackage is installed on your system.
- You have installed the RHEL 8 web console.
- You have enabled the cockpit service.
- Your user account is allowed to log in to the web console. - For instructions, see Installing and enabling the web console. 
- If you want to unmount a file system, ensure that the system does not use any file, service, or application stored in the partition.
Procedure
- Log in to the RHEL 8 web console. - For details, see Logging in to the web console. 
- Click the Storage tab.
- In the Storage table, select a volume from which you want to delete the partition.
- In the GPT partitions section, click the menu button, next to the partition whose file system you want to mount or unmount.
- Click or .
29.7. Common mount options
					The following table lists the most common options of the mount utility. You can apply these mount options using the following syntax:
				
mount --options option1,option2,option3 device mount-point
# mount --options option1,option2,option3 device mount-point| Option | Description | 
|---|---|
| 
									 | Enables asynchronous input and output operations on the file system. | 
| 
									 | 
									Enables the file system to be mounted automatically using the  | 
| 
									 | 
									Provides an alias for the  | 
| 
									 | Allows the execution of binary files on the particular file system. | 
| 
									 | Mounts an image as a loop device. | 
| 
									 | 
									Default behavior disables the automatic mount of the file system using the  | 
| 
									 | Disallows the execution of binary files on the particular file system. | 
| 
									 | Disallows an ordinary user (that is, other than root) to mount and unmount the file system. | 
| 
									 | Remounts the file system in case it is already mounted. | 
| 
									 | Mounts the file system for reading only. | 
| 
									 | Mounts the file system for both reading and writing. | 
| 
									 | Allows an ordinary user (that is, other than root) to mount and unmount the file system. |