Introduction

In this article we are going to learn How to mount and unmount Linux file system. In Linux operating system after create a fresh partition we have to format that partition with some file system eg: ext2, ext3, ext4 and so on and then Mount that file system (Partition) on a directory to use that partition and to store data on that partition.

Download Free Linux eBook HERE! "Learn Linux in 5 Days" - A Free Linux eBooks for Beginners

There are two types of file system mounting we have in Linux. one is Temporary mounting & other one is Permanent mounting. Here I am going to explain both type of mounting in this article. So let’s get started.

Here I have a partition i.e /dev/sdb1 which I am going to mount on a directory.

elinuxbook@ubuntu:~$ sudo fdisk -l | grep /dev/sdb1 /dev/sdb1 2048 8390655 8388608 4G 83 Linux

Mount a File System (Partition) [Temporary Mounting]

What is Temporary Mounting of File System ?

Ans : Temporary mounting of file system is something that will unmount automatically after reboot the system.

So to mount a file system (Partition) we need a directory. So first create a directory using below command. Here I am going to create a directory named mydata.

elinuxbook@ubuntu:~$ mkdir mydata # Create a Directory

My partition is formatted with ext3 file system and ready for mounting. So let’s mount the file system using mount command. Refer the below command.

elinuxbook@ubuntu:~$ sudo mount /dev/sdb1 mydata/ # Mount a File System

We have successfully mounted the file system using mount command. To confirm the same you can use the df -h command. Refer the command below.

elinuxbook@ubuntu:~$ df -h | grep mydata # Confirm the mounted file system /dev/sdb1 3.9G 8.2M 3.7G 1% /home/elinuxbook/mydata

OR you can also use mount command to check mounted file system. Refer the command below.

elinuxbook@ubuntu:~$ mount | grep /dev/sdb1 # Confirm the mounted file system /dev/sdb1 on /home/elinuxbook/mydata type ext3 (rw,relatime,data=ordered)

Unmount Linux File System

To unmount the file system use the below command.

elinuxbook@ubuntu:~$ sudo umount mydata/ # Unmount the File System

Also Read :

Permanent Mounting

Above I explained How to do temporary mounting of a file system. Now to mount the file system permanently you have to edit a file called /etc/fstab. So edit the file using below command.

elinuxbook@ubuntu:~$ sudo nano /etc/fstab # Edit the /etc/fstab file

After edit the file add the below line in to that file and save it.

/dev/sdb1 /home/elinuxbook/mydata ext3 defaults 0 0

Explanation of above line :

/dev/sdb1 : Partition Name

: Partition Name /home/elinuxbook/mydata : Mount Directory

: Mount Directory ext3 : File System

: File System defaults : Permission

: Permission 0 : For dump Backup

: For dump Backup 0 : For FSCK check

To Unmount Permanent File System just edit the /etc/fstab file and remove the line which we added on above step. Then to refresh the file system table run the below command.

elinuxbook@ubuntu:~$ mount -a # Refresh the File System Table

This is how we can Mount and Unmount Linux File System. If you found this article useful then Like us, Share this post on your preferred Social media, Subscribe our Newsletter OR if you have something to say then feel free to comment on the comment box below.