How To Resize Disk On Linux

This is a note summarizing how to resize disk on Linux.

Assuming you have a Linux VM, and you enlarged the disk. Take the following steps on your Linux to apply the changes.

Step 1: Resize the volume

The easiest way to resize your volume is to use cfdisk.

sudo cfdisk

This is what it looks like on my VM.

                                     Disk: /dev/sda
                   Size: 64 GiB, 68719476736 bytes, 134217728 sectors
              Label: gpt, identifier: 89F6152F-43FB-4262-8B2E-06EF3344C5A3

    Device               Start           End       Sectors     Size Type
>>  /dev/sda1             2048          4095          2048       1M BIOS boot
    /dev/sda2             4096     134217694     134213599      64G Linux filesystem



 ┌────────────────────────────────────────────────────────────────────────────────────┐
 │Partition UUID: 1BDD55B2-1581-4671-878E-5891F4802220                                │
 │Partition type: BIOS boot (21686148-6449-6E6F-744E-656564454649)                    │
 └────────────────────────────────────────────────────────────────────────────────────┘
   [ Delete ]  [ Resize ]  [  Quit  ]  [  Type  ]  [  Help  ]  [  Write ]  [  Dump  ]

Go to your target device, and then resize it as you need. For my case, it is /dev/sda2, because that’s where the root directory is mounted.

Step 2: Apply the change to your filesystem.

To apply the change to your file system, run the following command

sudo resize2fs /dev/sda2

Now you have added more spaces to your disk.