The mount command on Linux Temporary Mounting

On Linux, you have many options to create new hard disk partitions. No matter which option you choose to create new partitions, you cannot use them until you mount them after creating a file system on them. There are two ways to mount a partition on Linux: temporary and permanent. In this tutorial, we will learn how to mount a partition temporarily.

We use the mount command to mount a partition temporarily. We can use it to mount any newly created partition or external file system to the Linux file system. It needs two arguments: the absolute path of the partition we want to mount and a mount point. A mount point is an access point of the partition. We can use any directory as a mount point.

The mount command mounts the specified partition to the specified directory. After mounting, anything we save in the mount point directory is saved in the mounted partition. Let us understand this process through an example.

Create a new partition. You can use an existing partition. However, a new partition will make this process easier. You can check the following tutorial to learn how to create a new partition.

The fdisk command on Linux Explained

The following image shows a newly created unmounted partition. Since the partition is not mounted, we can use it to save data.

unmounted partitions

Create two directories. We will use these directories to understand the concept of the mount point.

#mkdir /tmp-mount-point-1
#mkdir /tmp-mount-point-2

create directory for testing

Mount the /dev/sda1 partition to the /tmp-mount-point-1 directory.

#mount /dev/sda1 /tmp-mount-point-1

mount a partition

Now, we can use this partition to save data. To verify it, let us create a directory and file. The directory and file will be saved on the /dev/sda1 partition.

#mkdir dir1
#cat > file1
This is a test file.

testing mount point

To verify it, we can unmount this partition and list this file and directory again. To unmount a partition, we use the umount command. This command needs the mount point's name as an argument.

#umount /tmp-mount-point-1


As we can see in the above output, the /tmp-mount-point-1 directory is empty. The file and directory we created in this directory were saved in the partition we mounted on this directory.

To verify it, let's mount the partition on the second directory we created for the testing and list the directory.

#mount /dev/sda1 /tmp-mount-point-2

mounting on the second directory

As we can see in the above output, both the file and directory we created for testing are available in this directory. It verifies the data we save in the mount point directory saves in the partition that is mounted on that directory.

ComputerNetworkingNotes Linux Tutorials The mount command on Linux Temporary Mounting