Linux disk expansion (Debian, CentOS, Ubuntu)

Important! Before making any changes, be sure to back up all server data. Any manipulations with partitions carry the risk of data loss.

The extension will be completed without data loss. This is such a "cunning technique": the existing partition is deleted, and a new, larger one is created in its place.

In our example, the device is called vda and is located in the /dev directory.

  1. It is necessary to find out the name of the hard disk device that we want to expand. This is done with the fdisk -l command.

  2. To increase the size of a partition (partition, slice) on a disk, we need to run: fdisk / dev / vda

Add disk space linux server

  1. Then, inside the fdisk command line, execute p (print) to see the partition table on the disk.

Add disk space linux server

Dedicated Server

Dedicated server

Check out SIM-Networks’ powerful pre-made server configurations

See packages

In our example, there is only one partition. It is called /dev/vda1 and has a capacity of 5GB. The hard disk itself has a capacity of 10GB. Let's expand /dev/vda1 to 10GB.

  1. Run d to delete the existing partition. Then n is for creating a new one, p is for primary, 1 is the partition number; and indicates the beginning and end of the section in sectors. The start sector must match the start sector of the partition that was deleted. The screenshot shows that this is 2048. We select the last sector of the partition as much as possible. In our case, fdisk offers us 20971519. We will enter it.

Add disk space linux server

  1. Once again p - to make sure that the partition has now grown to the size we need. And w is for writing and exiting fdisk.

Add disk space linux server

After that, we will receive a warning that the device is mounted and the superblock is not available and the volume of the partition will be changed after the OS is restarted.

  1. Reboot the OS - reboot

  2. After the reboot, we need to expand the FS to the entire partition. Let's do this with the resize2fs /dev/vda1 command

Add disk space linux server

  1. Next, df -h - to make sure everything worked out.

Add disk space linux server


Was this article helpful?

Did you like the article?

Cookie consent

By clicking «I agree», you consent to our website's use of cookies to give you the most relevant experience by remembering your preferences and repeat visits. However, you may visit «Manage сookies» to provide controlled consent. Learn more

Cookies settings


Necessary cookies are crucial for the basic functions of the website and the website will not work in its intended way without them.


Analytical cookies are used to understand how visitors interact with the website.


Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns.