Before doing anything: backup your data!
A disk contains partition(s). Each partition contains a file system like ext4.
To grow a file system, you have to:
- Resize the partition
- Resize the filesystem
To shrink:
- Resize the filesystem
- Resize the partition
The order is important.
Following is an example of:
- 1 disk:
xvdb
- 1 partition:
xvdb1
- 1 ext4 filesystem
The partition is being resized to take up all the space on the disk and the filesystem to take up all the space on the partition:
# unmount before making any changes to the partition table.
sudo umount /dev/xvdb1
# resize the partition.
sudo parted /dev/xvdb
(parted) resizepart 1 100%
(parted) quit
# resize the filesystem.
sudo resize2fs /dev/xvdb1
mount /dev/xvdb1 /mnt
And now xvdb1
has grown to take all the available disk space.