Linux mount command

In Linux there is a hierarchical file system. We can mount additional child file systems uner this file system or we can mount a storage device with the help of Linux mount command. By doing this, we make this file system or a storage device accessible in the existing Linux system. In this Linux lesson, we will learn about mounting.

 


You can check Linux Commands Cheat Sheet for more Linux commands.


 

How to use Linux mount command?

Linux mount command can be use with or without any options. If you use Linux mount command without options, it displays all the mounted file systems, mount points and mount options.

 

 

 

Beside using this command alone, we can also use additional options with mount. One of them is -t options. With -t option, we can define the type of the file that will be mounted to the system. This can be any of the file types like ext2, ext3, ext4, xfs, btrfs, vfat, sysfs, proc, nfs and cifs.

 

If we use this command without other parameter, it shows only that file system.

 

root@kali:/home/kali# mount -t ext4

/dev/sda1 on / type ext4 (rw,relatime,errors=remount-ro)

 

 

We can use also -a option to mount all devices described at /etc/fstab.

 

 

 

If we use -l option with mount, it lists all the file systems mounted yet.

 

 

 

To mount something in Linux system, we will use the below syntax:

 

mount -t type device dir

 

/etc/fstab is the place in which there are information about which device need to be mount where. If we leave dir part, it checks for a  mount point in /etc/fstab.

 


 

Mounting a File System

To mount a file system, we need to specify the file system that we will mount and the mount point. For example, if we mount /dev/sdb1 file system to the /mnt/media direcrıty, we will use the below comman:

 

root@kali:/home/kali# mount /dev/sdb1 /mnt/media

 


 

Mounting USB Drive

To mount a USB drive, we use Linux mount command. To do this, again, we specify the name of the usb drive with its location and give also the target mount place.

 

root@kali:/home/kali# mount /dev/sdb1 /media/usb-drive

 

 


 

Mounting ISO Files

We sometimes mount ISO files to use them on our Linux system. In Linux mount an ISO is not difficult. To do this,  we need to map the data of this ISO to a loop device. We will use -o loop option for this process.

 

root@kali:/home/kali# mount /image.iso /media/my-iso-file-1 -o loop

 


 

Linux umount command

Linux umount command is used to do a reverse job with mount command. With Linux umouth command, we detach any file or a storage device from Linux system.

 

root@kali:/home/kali# umount /dev/sdb1 /media/usb-drive

 

Lesson tags: linux commands
Back to: Kali Linux Course

Leave a Reply

Your email address will not be published. Required fields are marked *

Latest Blog Posts