In some situations, where the storage of the server gets full and we need to upgrade the storage of the server by adding a new disk. Today, we will learn how to mount a new disk to a Linux server. For this demonstration, we are using CentOS 7 cloud server.
We will use the fdisk command to mount the disk in the server.
First, list all current disk available in the server and the name of the new disk:
# fdisk -l
Now, after discovering the name of the disk, select that disk as below shown:
# fdisk /dev/vdc
After choosing the disk, create a new partition.
n – Create a new partition
p – Primary partition type
default – Enter without writing anything(Here we’re selecting default sector)
default – Enter without writing anything(Here we create the partition with full-size, we can mention as per your requirement)
p – List the partitions
w – Save and exit
After the partition created, inform the server about it.
# partprobe
Now, format the partition with XFS filesystem:
# mkfs.xfs /dev/vdc1
Create a directory as a mount point.
# mkdir /data
Mount the partition to the directory, the one we have created earlier.
# mount /dev/vdc1 /data
For permanent effect, add the mount entry into the fstab file.
# vi /etc/fstab
/dev/vdc1 /data xfs defaults 0 0
Save & exit
Now, run following command to check that added entry into the fstab file is valid or is there any error. It is a must to run this command after you add anything into the fstab file before you reboot the server. If added entry is in the wrong format and reboots the server, the server won’t start until you correct it.
# mount -a
Today, we’ve learned how our Support Engineers mount a new disk to a Linux server.
[Need assistance to fix this error or install tools? We’ll help you.]