How To Mount And Unmount File Systems From The Linux Terminal?
This post was last updated on July 1st, 2020 at 10:24 am
In Linux or Unix, mount command is used to mount(attach) a filesystem or storage device to a specific directory in the directory tree. The directory to which it is mounted is known as the mount point for the filesystem.
The umount command is used to safely unmount(detach) a mounted filesystem from the directory tree.
In this article, we will discuss to mount or unmount a mounted filesystem in Linux by using the terminal.
List the mounted filesystems using the mount command
You can list the mounted filesystems by using mount command without any option. It displays the information of all filesystem including virtual ones such cgroup, sysfs, etc. Now use the following command –
You can refine the output of mount command by using the option
For example –
mount -t ext4
Mount a filesystem
To mount a filesystem in the existing directory structure we will use the mount command. The syntax of mount command is given below –
mount [options] filesystem_or_device_name directory
For example –
/dev/sdb1 filesystem to
/mnt/media directory we use –
mount /dev/sdb1 /mnt/media
Usually, when you mount a device with a common filesystem such as ext4, it detects filesystem type automatically. If not detected you can explicitly mention the filesystem by using the option
How to mount an ISO file
You can mount an iso file to a specific directory so that it’s content available as the part of existing filesystem. I have Ubuntu 20.04 LTS iso in my system I will mount it to
/mnt directory. To mount iso use the following command –
sudo mount -t iso9660 -o loop ubuntu-20.04-desktop-amd64.iso /mnt
Now you can access the content by navigating to
How to mount the USB drive
In most of the distributions, a USB drive is automatically get mounted when you insert it in a USB port. If not mounted automatically you can manually mount it. When you manually mount a USB drive you can mount it to a specific directory.
Suppose we have USB
/dev/sdb1 and want to mount it on
/media/usbdrive. First, create the directory
usbdrive inside media directory by using the following command-
mkdir -p /media/usbdrive
Now use the following command to mount
sudo mount /dev/sdb1 /media/usbdrive
Unmount a filesystem
To unmount a filesystem or storage device umount command is used. Following is the syntax of umount command –
If a filesystem is in use umount command will fail to unmount. You can use the
fuser command to see which process is accessing the filesystem.
fuser -m directory_or_device
Once you identify the process you can stop it and unmount the filesystem.
-l option can be used to unmount a busy filesystem safely. This option causes the umount to wait until the filesystem is able to be safely unmounted. Run the following command if you want to use lazy unmount-
umount -l filesystem_or_device
You can use
--force option to forcefully unmount a filesystem. Use the command as given below to force unmount a filesystem.
umount -f filesystem_or_device
Now I hope you got a basic understanding of how to mount or unmount a filesystem in Linux or Unix. If you want to say something on this topic then write to us in the comments below.
You might also like
FTP or File Transfer Protocol is a standard networking protocol used to transfer files between client and server. An FTP user may authenticate themselves by using username and a password.
This post was last updated on June 27th, 2020 at 12:55 pmContents1 Bootscreen2 Plymouth3 Steps to change the logo in Linux mint-4 Conclusion Bootscreen A bootscreen is a graphical representation
Linux/Unix are multi-user operating systems that means different users can access and use system resources simultaneously. To access the resources of a system you must have a user account on