Skip to main content How do I resize a partition? : r/debian

How do I resize a partition?

I'm running Debian 12 via VirtualBox. Originally I had it set to a 32Gb drive but today I got a "low disk space" warning. Closed the VM and went into VirtualBox and changed the disk size to 64Gb. Started the VM again but can't figure out how to resize the disk to use the extra 32Gb of space. GParted shows the 32Gb as "unallocated". There is a swap partition between the primary drive and the unallocated space.

So how do I increase the drive size to include the new 32Gb of space? (I'm relatively new to this).

r/debian - How do I resize a partition?
Discover how AI is shaping the way we work and live in Deloitte’s Tech Trends 2025.
Thumbnail image: Discover how AI is shaping the way we work and live in Deloitte’s Tech Trends 2025.
Sort by:
Best
Open comment sort options

Turn swap off, delete swap partition, make new partition of size N, add as physical volume in lvm, add to volume group, expand logical volume, recreate swap space and swap on. If you are not using lvm, swap off, delete swap partition, use parted or other tools to expand partition, then recreate swap partition and swap on.

LVM is nice but there is no need for it in this case.

  • backup the system

  • disable swap

  • remove swap

  • remove extended partition

  • resize /dev/sda1 (disk size - wanted swap size)

  • create new swap partition /dev/sda2 or on extended

  • resize2fs /dev/sda1

  • mkswap on swap partition

  • add swap partition to /etc/fstab

(run swapon -a or reboot)

More replies

Thanks for the detailed answer! Very much appreciated!

Doesn't OP also need to expand the filesystem?

More replies
More replies