How do I make Ubuntu's resize2fs command work after increasing Droplet size?

September 20, 2016 5.8k views
Storage Ubuntu
TokyoRob
By:
TokyoRob

Earlier today I increased the drive space on my Ubuntu droplet from 30GB to 40GB. After restarting, the drive size has increased:

> fdisk -l
...
Disk /dev/vda: 40 GiB, 42949672960 bytes, 83886080 sectors

But naturally the filesystem itself is still 30GB:

> df -h
...
/dev/vda1        30G   16G   13G  55% /
> fdisk -l
...
/dev/vda1  *     2048 62910539 62908492  30G 83 Linux

The problem is that the resize2fs command doesn't behave as expected.

> sudo resize2fs /dev/vda1
resize2fs 1.42.12 (29-Aug-2014)
The filesystem is already 7863561 (4k) blocks long.  Nothing to do!

Have I missed a step here? As I understand it, I should be able to increase the size of the root filesystem without unmounting it. Is there something I need to do to the partition table to tell resize2fs that the additional 10GiB is there for the taking?

Any suggestions would be much appreciated!

3 Answers

Hi TokyoRob,

First unmount the /dev/vda1 using below command.

sudo umount /dev/vda1

Now run the sudo resize2fs /dev/vda1

Hope it will help...

  • Thank you for your quick reply!

    Since this is the root filesystem (mapped to /), it's not possible to unmount it.

    The man page for resize2fs says that unmounting is not required to increase file system size:

    If the filesystem is mounted, it can be used to expand the size of the mounted filesystem...
    

    I have a feeling that the missing step in the tutorials on DigitalOcean and elsewhere is an fdisk operation to increase the partition size, but I can't find confirmation of this anywhere.

HOW WILL I INCREASE SIZE FOR UBUNTU

Hi,
i am using two operating systems windows and ubuntu parallelly, i alloted 20GB to ubuntu and remainig space to windows but now the space in ubuntu is not enough to me i want to increase disk size. so, plz any one tell me how to increase disk space in ubuntu

Hi guys,

I had the same issue as above. Talking with DO Support it sounds like this is an occasional issue with resizing disk space on droplets. resize2fs didn't work for me either, but following these instructions to repartition and then resize2fs did work for me:

https://linuxconfig.org/how-to-resize-ext4-root-partition-live-without-umount

DO Support suggested this command but I had already run the fdisk process above - it should do the same thing:

 growpart /dev/vda1

Make sure to snapshot your droplet before attempting the above!

Dougie.

  • Thanks you so much, I change command a little bit to correct syntax and and add resize2fs which is necessary. The commands works on ubuntu 16.04 (NONE LVM) and machine is running a kvm:

    growpart /dev/vda 1
    resize2fs /dev/vda1   
    
Have another answer? Share your knowledge.