As we know Linux operating system mainly uses files and folders as operational units. Files folders are stored in file systems and disks. There are different tools to manage file systems and disks. But
mount is de facto command used to mount and list disks and file systems? In this tutorial, we will look at different types of usages of the mount.
List Mounted Paths
Normally most of the Linux operating systems are started by mounting some file systems for system partition and user partition. The mounted partitions can be changed according to configuration. These partitions and file systems can be listed just issuing
mount command like below. In this example we can see that are are some pseudo partitions those used by operations system-related functionalities.
Mount Given Partition or Disk To The Specified Path
Mount file systems and partitions are not so hard or complex in the command line. To mount just provide the partitions that will be mounted and the destination where the mounted partition will be accessed.
$ mount /dev/vdb1 /mnt
Mount Ext4 File System
In the previous example, we have mounted a partition without specifying a file system. Because the mount is decided the partitions file system automatically and set required parameters internally without needing any additional information. But sometimes this can not work. We can specify the file system type with
-t parameter like below. In this example, we will mount the ext4 file system.
$ mount -t ext4 /dev/vdb1 /mnt
Mount NTFS File System
As we know NTFS is a Windows native file system. The mounting NTFS file system is very similar. NTFS provides a reach feature set like the BTRFS file system which is used by some of the distributions. We can see from mount output that NTFS is named fuseblk .
$ mount -t ntfs /dev/vdb1 /mnt
Mount FAT File System
FAT is the predecessor of the NTFS file system and used wide in different systems like cameras, TV, etc. FAT file systems can be specifically mounted like below.
$ mount | grep vdb1
Mount ISO File System
CD-ROM is old technology nowadays. But the CD-ROM de facto file system ISO is used regularly for distribution of Linux distributions, Setup tools, etc. These ISO file systems can be mounted with the following command.
$ mount -t iso9660 virtio-win.iso /mnt
Mount All File Systems Of Fstab
Up to now we have mounted file systems by giving details. There is a configuration file used by mount which resides
/etc/fstab . This file is used to mount file systems during boot time. But this configuration file can be used after boot.
$ sudo mount -a
$ mount -a
Unmount All File Systems Of Fstab
In the previous example, we have used
fstab file as mount configuration but this can be also used as unmount configuration to unmount all file systems specified in fstab.
$ sudo unmount -a
Mount Specific File Systems Of Fstab
Fstab can be used to get mount configuration of the specific mount points. Below is an example fstab file that provides mount configuration for
/mnt . We will mount this line by specifying the mount path.
UUID=01f0e46f-9e44-4e25-8712-886427a3798b / ext4 errors=remount-ro 0 1 UUID=764C4C593741045B /mnt ntfs errors=remount-ro 0 1
And we mount
$ mount /mnt
List Mounted File Systems
Mounted file systems can be listed with
$ mount -l
List Mounted Ext3 File Systems
While listing specific file systems can be specified to be listed. This can be used
$ mount -l -t ext3
List Mounted Ext4 File Systems
Ext4 file systems can be listed with the
-t ext4 parameter like below.
$ mount -l -t ext4
List Mounted Btrfs File Systems
Btrfs file systems can be a list with the
-t btrfs like below.
$ mount -l -t btrfs
Bind Mounted Path To New Path
After mounting to a directory the mount point can be changed. We will provide the current mounted point and new mount point in a row with
-B parameter. This actually does not removes old mount only adds the new directory as the mount.
$ mount -B /mnt /mnt2
Mount File System Read Only
While mounting file systems there are a lot of options that affect the mount operation. One of the most used options is to read/write option. By default file systems are mounted read/writeable. But there are some situations we need to mount read-only. Mount can mount read-only with
$ mount -r /mnt
Remount Mounted File System
All ready mounted file systems can be remounted easily with
-o mount parameter. This is needed some times some configurations about the file system is changed and make new configuration effective.
$ mount -o remount /mnt
Unmount Multiple Mounts
Previously we have mounted multiple mount points. Now we may want to unmount the multiple mount points with the following commands.
$ umount /mnt /mnt2
Unmounting have some restrictions. While there are operations on the mounted partitions these partitions can not be unmounted. This can be an unwanted situation. There is a workaround which will unmount the system after the operation on the mount point.
$ umount -l /mnt
In the previous example, we have looked lazy unmount which will wait for the operation to end in order to unmount the mount point. There is a hard way which will forcibly unmount the mount point. But keep in mind that this can create problems with file systems.
$ umount -f /mnt