M HYPE SPLASH
// general

Resizing Ubuntu partition with resize2fs

By Emma Terry

I have an AWS EC2 instance running on Ubuntu 16.04.

It has a 2TB ext4 partition which I am trying to resize to 6TB. I have updated the AWS volume to 6TB without difficulties.

On the instance I used resize2fs to resize the partition and it does not work (even after rebooting). Using lsblk I can correctly see the total disk space of 5.9T.

gab@someserver:~$ sudo df -h
Filesystem Size Used Avail Use% Mounted on
udev 481G 0 481G 0% /dev
tmpfs 97G 8.6M 97G 1% /run
/dev/xvda1 2.0T 1.7T 309G 85% /
tmpfs 481G 8.0K 481G 1% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 481G 0 481G 0% /sys/fs/cgroup
tmpfs 97G 0 97G 0% /run/user/1001
gab@someserver:~$ sudo blkid
/dev/xvda1: LABEL="cloudimg-rootfs" UUID="*****" TYPE="ext4" PARTUUID="***"
gab@someserver:~$ sudo lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 5.9T 0 disk
└─xvda1 202:1 0 2T 0 part /
xvdb 202:16 0 1.8T 0 disk
gab@someserver:~$ sudo resize2fs /dev/xvda1
resize2fs 1.42.13 (17-May-2015)
The filesystem is already 536870655 (4k) blocks long. Nothing to do!
gab@someserver:~$ sudo df -h
Filesystem Size Used Avail Use% Mounted on
udev 481G 0 481G 0% /dev
tmpfs 97G 8.6M 97G 1% /run
/dev/xvda1 2.0T 1.7T 309G 85% /
tmpfs 481G 8.0K 481G 1% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 481G 0 481G 0% /sys/fs/cgroup
tmpfs 97G 0 97G 0% /run/user/1001
gab@someserver:~$ 

Does anyone have any experience with this issue?

1

1 Answer

The problem you're having is shown by the output of lsblk:

gab@someserver:~$ sudo lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 5.9T 0 disk
└─xvda1 202:1 0 2T 0 part /
xvdb 202:16 0 1.8T 0 disk 

/dev/xvda is 5.9T, but /dev/xvda1 is only 2T. You need to first resize the partition, and then you can resize the file system to the size of its block device. Since the file system is on /dev/xvda1, that's why resize2fs is saying "nothing to do". You need to use a partition tool, such as fdisk, or parted, to change the size of the partition for you.

On Google Compute Engine, this is actually done automatically for you. When you grow the size of the Persistent Disk (GCE's analog of AWS's EBS, if the VM is running, it will automatically resize the partition and the file system for you. If the VM is not running, it will happen automatically when the VM is booted or when the PD is attached. (Disclosure: I work for Google.) I thought AWS did the same thing --- perhaps it's because you're using a very old version of Ubuntu (16.04 is six years old and it's End of Life was in April 2021) and AWS never updated its daemons to add this feature to 16.04? I'm not sure.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy