How to Resize Linux Disk
In this tutorial, we will learn how to resize a Linux disk on a virtual server so it reflects the increase in size.
Once you have increased (or decreased) the size of the mounted disk on the hosting control panel for your virtual Linux machine, you'll notice that when running the df command the system isn't aware that the size of the disk has increased.
df -h
Filesystem Size Used Avail Use% Mounted on
tmpfs 1.5G 1.1M 1.5G 1% /run
/dev/sda1 97G 52G 45G 54% /
tmpfs 7.2G 0 7.2G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 4.0M 0 4.0M 0% /sys/fs/cgroup
/dev/sdc 15G 13G 992M 94% /mnt/vol2
/dev/sda15 105M 5.2M 100M 5% /boot/efi
/dev/sdb 679G 627G 18G 98% /mnt/vol1
tmpfs 1.5G 4.0K 1.5G 1% /run/user/1001
In my case, I increased the size of /dev/sdb
to 700GB but the changes were not applied to the system.
To update the disk size on the system, run the resize2fs
command and pass the path of the disk as the first argument.
sudo resize2fs /dev/sdb
resize2fs 1.45.7 (28-Jan-2021)
The filesystem is now 188743680 (4k) blocks long.