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.
How to List mounted file systems ?
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:
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
How to mount a drive in Linux ?
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:
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.
How to mount an ISO file in Linux ?
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
How to unmount a drive in Linux ?
To detach a drive, simply run the command:
$ sudo umount device
[Need assistance in mounting drive in Linux Systems? We can help you. ]