Some assumptions about setup

  • Partition we are interested in resizing is /dev/sda1
  • System we are running is Debian 12

Make sure the drive is offline

Unmount

sudo umount -R /mnt

Verify nothing is using the drive or previous mount directory

sudo lsof /mnt
sudo lsof /dev/sda1

Stop all docker containers

For my specific configuration, I was resizing a large drive that several docker containers are using as their data store, so I made sure to stop all of them (even though this is possibly extraneous).

I have ~/docker for all my docker-compose files, so it’s a simple for loop.

cd ~/docker
for dir in $(ls .); do cd $dir; sudo docker compose stop; cd ..; done

Install necessary packages

We’ll be using growpart, resize2fs, and e2fsck. Both resize2fs and e2fsck were already installed on my system. To install growpart, run apt install cloud-guest-utils on Debian 12.

Resize the disk

sudo growpart /dev/sda 1 # NOTE THE SPACE between the drive letter and the number
 
sudo e2fsck -f /dev/sda1
 
sudo resize2fs /dev/sda1

EOF