By Heidy RamirezJanuary 11th 2021

There could be multiple scenarios where you would need to resize the primary partition and
extend non lvm root partition space.

Prerequisites:

  • sudo/root access
  • Information about disk capacity and existing partition(s)
  • Create a data backup (just to be safe).

Let's start with listing our available partitions:

sudo fdisk -l

fdisk commands:

  • p to print the partition table
  • d to delete the partition
  • n to create a partition
  • w to save changes and exit

Now we will resize a swap partition. Run the following command and use an option to double check a partition:

sudo fdisk /dev/vda

Enter d to delete a /dev/vda2 partition;

pick a partition number (from a partition table), in our case, it will be 2;

Enter n to create a new partition and pick a partition type p;

Select a partition number (2-4)

Pick a first sector (we will use a default option);

Pick a partition size - 500M;

Enter N to keep a swap signature;

Use a p command to double check the outcome:

And finally, enter a w command to write the changes to the partition table: 

)