Skip to content

Mounts

The mount command allows the root user to mount a file system manually. The first argument of the mount command specifies the file system to mount. The second argument specifies the directory to use as the mount point in the file-system hierarchy.

There are two common ways to specify the file system on a disk partition to the mount command: With the name of the device file in /dev containing the file system. With the UUID written to the file system, a universally-unique identifier.

Use the lsblk command to list the details of a specified block device or all the available devices. Use the blkid to obtain UUID numbers.

mount /dev/sdb1 /data
mount UUID="d00efaa4-d929-4966-bbda-9b21c7c719a3" /data

Unmount a file system with umount /data.

To mount an ISO image the loop option is required.

mount -o loop /opt/isos/image.iso /opt/iso-mount-point/

Use either parted or fdisk to create new partitions on disks.

parted /dev/sdb
fdisk /dev/sdb

File systems are created using mkfs.xfs. To persistently mount a file system upon system boot and entry in /etc/fstab needs adding.

Example of the process:

fdisk /dev/sdb
mkfs.xfs /dev/sdb
blkid
vi /etc/fstab
UUID=d00efaa4-d929-4966-bbda-9b21c7c719a3 /data                   xfs     defaults        0 0
To force the system to read and mount new entrie in /etc/fstab use systemctl daemon-reload or mount -a.

New disk lebels can be added using parted.

parted /dev/sdb mklabel msdos

Summary

The mount command allows the root user to manually mount a file system. fdisk or parted can be used to add, modify, and remove partitions on disks with the MBR or the GPT partitioning scheme. XFS file systems are created on disk partitions using mkfs.xfs. To make file system mounts persistent, they must be added to /etc/fstab.

Command References:

lsblk, blkid, mount, umount, parted and fstab.