In this article, you will learn about the mount command in Linux.
Mounting is the way to access any filesystem at some point in the Linux directory tree. When you mount a filesystem, it does not matter that it is a hard disk partition, USB storage device, floppy, CD/DVD-ROM, a tape drive, or any other external media.
If you want to mount any device then only you have to know, the device associated with a particular storage device and directory where you want it to mount. If you wish to access the files on a CD-ROM, then you have to inform the system to make the filesystem on the CD-ROM appear in some directory, typically /mnt/cdrom.
How to get help for the mount command
I always suggest reading the manual page and help. It will give you an in-depth introduction to the command.
To get the manual page type the below command,
But, to get the only command options, you can type the below command.
Syntax of the mount command
Now you know how to get help about the mount command. So, let’s talk about mount syntax. The syntax of the mount command is as below,
Syntax 1: mount [-l|-h|-V]
There is another syntax 2: mount -a [-fFnrsvw] [-t fstype] [-O optlist]
The syntax 3: mount [-fnrsvw] [-o options] device|dir
Syntax 4: mount [-fnrsvw] [-t fstype] [-o options] device dir
Use of the mount command
When you press enter after typing mount command, this command will display all the mounted devices, the filesystem type it is mounted as, and the mount point.
If you want to mount any device, you have to first create the directory where you want it to mount. In many Linux distribution, you can find an /mnt directory where you can mount that device. But you can also create a directory in different locations as you want.
I’m going to create a directory with the name /mnt/hdd, the below command will create a directory with the name hdd.
Now I will mount that device to the /mnt/hdd directory,
mount -t ext4 /dev/sdb1 /mnt/hdd
here, t stands for type, file type If you don’t know what type of file it is, It will try to identify itself. Also, you can remove that -t.
You can see in below picture,
Now we are going to umount it, to umount it you just need to type umount and followed by the mount point location.
Note: This mount is temporary. If you restart the computer, you can lose all the mounted devices because you did not put them permanently. If You want to make it permanent then you have to put it in fstab. So, to read more about fstab click on the below link,
In conclusion, you learned about the mount command in Linux. It is an important command. If you want to see the data of any drive, then you have to mount it somewhere. So practice it. So, I hope you understand. But if you have any questions, you can ask in the comment section.
Also, you can read about