Mount is a command used in Linux to attached filesystems and drives and unmount command is used to detach (unmount) any attached file systems or devices.
Basically, Before you can access and use any kind of storage device, it must first be mounted on the operating system. This is what is referred to as mounting. The storage medium has to be mounted for the OS to recognize its filesystem and interpret the data written on it.
Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform related Drive queries on Linux Systems.
In this context, we shall look into how to mount a drive on Linux. The commands will work for all Linux Distributions.
The mount/umount commands are used for attaching or detaching storage devices in Linux / UNIX systems. To list the currently attached or mounted devices, run the mount command as follows:
$ mount
The output will display all filesystems including virtual filesystems such as sysfs, proc, and cgroup. Every line consists of the device's name, directory on which the device is mounted, filesystem type, and the mount options.
To narrow down to specific file systems, pass the -t option followed by the filesystem type. The command below displays all mounted ext4 filesystems on the system:
$ mount -t ext4
Mounting a filesystem is quite a straightforward process. You must first create a mount directory on which the device will be mounted and thereafter mount the device using the mount command.
Usually, USB drives are automounted when plugged in. However, sometimes, they are be accidentally unmounted and in such cases, you might need to mount them manually.
Here, we have a drive plugged in labeled as /dev/sdb1. You can get a list of attached devices or volumes using the lsblk command:
$ lsblk
To mount the device I will first, create a directory or mountpoint to mount the drive. Here, we have created the /media/winnie mount point as shown.
$ sudo mkdir -p /media/winnie/
To mount the USB drive on the mount point, the command will be:
$ sudo mount /dev/sdb1 /media/winnie/
To confirm that the drive has been mounted, run the df command and grep utility to search for the volume:
$ df -Th | grep -i sdb
Now, we have successfully managed to mount a USB drive. In the next step, you will see how you can mount an ISO image.
Mounting an ISO file, such as an ISO image allows you to access its contents, the same way we did with the USB drive. It's the equivalent of the files being written on a physical medium which is then plugged in.
The procedure of mounting an ISO file is similar to what we did when mounting a drive.
1. First, create a mount point.
$ sudo mkdir -p /media/winnie/iso
2. Then mount the ISO using the syntax shown. This mounts the ISO file in read-only mode.
$ sudo mount /path/to/iso/image/ /mount/directory -o loop
To detach a drive, simply run the command:
$ sudo umount device
This article covers the process of Mounting and unmounting a drive or an ISO image in Linux. After creating disk partitions and formatting them properly, you may want to mount or unmount your drives.
On Linux, mounting drives is done via mountpoints on the virtual filesystem, allowing system users to navigate the filesystem as well as create and delete files on them.
How to List Mounted File Systems and Linux Drives ?
To display all currently attached file systems we will type:
$ mount
By default, the output will include all of the file systems including the virtual ones such as cgroup, sysfs, and others. Each line contains information about the device name, the directory to which the device is mounted, the filesystem type and the mount options.
How to install NFS client on Ubuntu and Debian ?
NFS stands for Network File System. To mount an NFS share you'll need to have the NFS client package installed on your Linux system.
1. To install NFS client on Ubuntu and Debian, type:
$ sudo apt install nfs-common
2. To install NFS client on CentOS and Fedora:
$ sudo yum install nfs-utils