Disk Partitions, Formatting & Mounting in Linux VPS

In this article, we will learn how to create disk partitions, format the partition and Mounting on location in your Linux system setup on your Local System, Virtual Machine, Dedicated Server or VPS.

Let us begin by checking the current disks mounted on locations along with its size

df -h

By default, in Hostaya VPS, Primary SSD disk is already mounted on system with structure shown in above image.

We can see /dev/vda1 has size of 48G mounted on /

However, you can’t able to see other secondary disk which is unpartitioned.

All Devices are can be appeared with its partition information can be get using the command below

fdisk -l

In the above screenshot, we can clearly see disk /dev/vda has 64.4GB which is partitioned into /dev/vda1 (Storage) & /dev/vda2 (swap)

But /dev/vdb is unpartitioned with 536.9 GB

In order to make the secondary disk usable, we have to do the following things

  1. Create Partition
  2. Format Partition
  3. Create Mountpoint for mounting the disk

1.Create Partition

To create the partition, we have to run the following command

fdisk /dev/vdb

To create a new partition


Select partition type as primary


Press Enter key again and again to select default values till here

Till here, we have already configured the partition parameters, but it will only effect when you write into the system.

To write all values, we have to run this command


Now we can check partition blocks using the following command


We can clearly see vdb has been parted into vdb1

2. Format Partition

We can format the partition by using mkfs.ext4 file system

mkfs.ext4 /dev/vdb1

3. Mounting the Partition

Before mounting the partition at mountpoint, we have to make sure we have prepared the suitable directory for mountpoint.

We can create new directory with any name, lets say, newstorage

mkdir /newstorage

Now we can mount the partition into storage path

mount /dev/vdb1 /newstorage

Now we can check the filesystem

df -h

Now we can see, our new storage has been successfully mounted on /newstorage having 493G effective size.

There are many ways to make partition except from fdisk are parted and few more. Do not get confused with parted command lines as it does the same thing what fdisk did in this tutorial.

Multiple partition with advance examples will be explained in upcoming tutorials.

Leave a Reply

Your email address will not be published. Required fields are marked *