Disk expansion in Linux (Debian, CentOS, Ubuntu)

In this tutorial, we look at the process of Linux disk expansion. We use the example of a public cloud provided in the Sirocco tariff from SIM-Networks.

Sirocco is a high-performance solution with a 3.3 GHz quad-core Intel® Xeon® processor, 32 GB of RAM, and 200 GB of storage. Notably, this cloud offers scalability capabilities for both RAM and storage, significantly increasing its functionality and allowing you to meet the unique needs of your business. With its high performance and customization flexibility, the Sirocco cloud can be tailored to your needs for the best return on investment and operational efficiency.

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

Security Tips:

  • Always back up your data before making any changes.
  • Make sure you have access to an emergency boot disk.
  • Use only proven and stable versions of software.

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

Ready.

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

functional

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

Analytics

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

Advertisement

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