How Can We Help?

Special Offer

Deploy your Cloud Server now and get $100 in Free Credits!

Get Started

How to Mount Disk in Linux

Table of Content
How to Mount Disk in Linux
How to Mount Disk in Linux

How to mount the disk on the server?

Mounting is a process by which we can access the disk and access the data of the disk. There are two types of mounting.

  1. Temporary Mounting
  2. Permanent Mounting

Temporary Mounting 

This type of mounting is used to temporarily mount a disk or pendrive on the server. Following are the steps to mount the disk on the server.

Step 1: Add disk from the platform

Step 2: Login into the server using SSH

Step 3: Now use lsblk command to list the available disks on the server.


Step 4: Now create a filesystem on the disk using mkfs command.

#mkfs.xfs /dev/diskname

Here xfs is a filesystem we can also use other file system( ext4,ext3,etx2) according to our need.

Note:- By creating the file system we are just formatting the disk so be careful before using mkfs command. IF any useful data is available on the disk so please do not use mkfs command. This command may cause data loss so be careful before using it. If we have to mount pendrive on the server with the data then only follow step 5 to mount the device

Step 5: If mounting point is not available on the server so create it using mkdir command

 #mkdir /test

Step 6: Now mount the device using mount command 

#mount /dev/diskname /test

Here /dev/diskname is device name

/test is directory or mounting point on which you want to mount the device

But the main drawback of temporary mount is after the server reboot mounting is not persistent on the server, so to mitigate this problem we are going to use permanent mount on the server. Please follow the following steps for permanent mount.

Permanent Mounting

Step1: After formatting the disk UUID is assigned to device so to mount the device permanently 

           A UUID is required. For getting UUID of the device use this command.


#blkid /dev/diskname 
⇒ copy the UUID

Step2: For permanent mount we need to edit /etc/fstab file

And we have to add the content in following format

UUID=4acb391a-52bb-466e-9a9b-ca23f480f492    /test     ext4        defaults     0      0


First field is the device name or UUID of the device. Here we are using UUID but we can also use device name (exp:-/dev/vdb) to mount the device permanently but recommended is to use UUID level to mount the disk.

Second field specifies the mount point 

Third field specifies the file system of the disk

The fourth field specifies the mount point options. We can specify many mount options separated by the commas. Here we are using defaults

The fifth field specifies the dump utility if we use 0 then it means dump utility not backing up the device. IF we are using this option as 1 then the dump utility should backup the device.

The sixth field specifies the fsck it means file system check at boot time if this value is zero it means filesystem is not checked at boot time and if we use this option as 1 then it means file system will be checked at boot time. The higher value in this field specifies the priority of filesystem check of devices.

Note : If you are using Microhost console so you can not copy UUID then you can redirect the output of the command 

lsblk /dev/diskname --output=UUID >> /etc/fstab

Thank you !!

Also Read: How To Partition and Format Storage Devices in Linux, 5 Most Effective Ways to Avoid Cloud Bill Shocks.

Special Offer

Deploy your Cloud Server now and get $100 in Free Credits!

Get Started
Table of Contents