Linux and servers · Intermediate · 12 min
Grow a cloud server's disk without downtime
By Padding · Updated 18 Nov 2026
Ubuntu 26.04.1 LTS · cloud-guest-utils 0.33 · e2fsprogs 1.47.2 · xfsprogs 6.18 · util-linux 2.41.3
You will take a snapshot, enlarge a volume in your provider's console, then grow its partition with growpart and its ext4 or XFS filesystem while it stays mounted, with the LVM variant and cloud-init's boot-time resize explained.
On this page
A server runs out of space, you raise the volume size in your provider's console, and nothing changes: df shows the same size as before. That is expected. The console grows the block device, the virtual disk. The partition on it and the filesystem inside the partition are separate layers, each with its own size, and each one has to be told to use the new space.
All three layers can grow while the filesystem is mounted and in use, so this needs no reboot and no maintenance window. You will find exactly which disk, partition and filesystem you are growing, take a snapshot, resize the volume, then grow the partition with growpart and the filesystem with resize2fs (ext4) or xfs_growfs (XFS). Two variations follow: a disk that uses LVM, and why cloud images often grow the root disk on their own at the next boot.
The steps are the same on AWS EBS, Hetzner Cloud, DigitalOcean Volumes and most other providers; only the console screens differ. If you manage servers over mobile data, work inside tmux or screen, so a dropped SSH session does not cut a command off halfway.
Step 1 · Install the tools and find what you are growing
Install the packages that provide growpart, sfdisk and the ext4 and XFS tools. Most Ubuntu cloud images already have them:
sudo apt update
sudo apt install -y cloud-guest-utils fdisk e2fsprogs xfsprogsgrowpart comes from cloud-guest-utils. It moves the end of one partition as far as the free space after it allows, and leaves the start, and so the data, where it is.
Start from the mount point that is full, not from a device name you remember. Set it in a variable; use / for the root filesystem, or your data volume's mount point. Replace the example with your own:
MNT=/srv/data
findmnt -n -o SOURCE,FSTYPE "$MNT"This prints the partition and the filesystem type, such as /dev/nvme1n1p1 ext4. If the source is under /dev/mapper/, the filesystem sits on LVM: read the LVM step before you continue. If it is a whole disk with no partition number, such as /dev/nvme1n1, there is no partition to grow; skip the growpart steps.
Ask the kernel which disk that partition belongs to and which number it has, so you never type them by hand:
PART=$(findmnt -n -o SOURCE "$MNT")
DISK=/dev/$(lsblk -n -o PKNAME "$PART")
PARTNUM=$(cat "/sys/class/block/$(basename "$PART")/partition")echo "disk=$DISK partition=$PARTNUM device=$PART"The variables last for this shell session only. If you log out, set them again before you carry on.
Check it worked
The echo prints something like disk=/dev/nvme1n1 partition=1 device=/dev/nvme1n1p1. Look at the disk as a whole:
lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS "$DISK"NAME SIZE TYPE FSTYPE MOUNTPOINTS
nvme1n1 100G disk
└─nvme1n1p1 100G part ext4 /srv/dataThe disk row should match the volume you are about to resize in the console (size, and on AWS the volume ID in lsblk -o NAME,SERIAL), and your mount point should be on the partition you found.
Step 2 · Take a snapshot and save the partition table
Growing is the safe direction: nothing is moved or deleted. Still, you are rewriting a partition table under a live filesystem, so make a way back before you start.
In your provider's console, open the volume and create a snapshot of it. For a database volume, a snapshot of the running server is crash-consistent: it holds what a sudden power cut would leave. That is usually fine for a database that recovers from its own log, but if your application cannot, pause writes or take an application-level dump first.
Then save a text copy of the current partition table in your home directory:
sudo sfdisk --dump "$DISK" > ~/partition-table-before-grow.sfdisk
cat ~/partition-table-before-grow.sfdiskIf a partition table write ever went wrong, sudo sfdisk "$DISK" < ~/partition-table-before-grow.sfdisk would write this exact layout back. You should never need it, but it costs nothing to keep.
Check it worked
The snapshot shows as completed (or available) in the console. The saved file starts with label: gpt (or label: dos on older disks) and has one line per partition, such as /dev/nvme1n1p1 : start= 2048, size= 209713119, type=.... Note the size= of your partition; you will see it grow later.
Step 3 · Resize the volume in the console
Before you confirm, two facts that apply on most providers:
- Volumes only grow. On AWS EBS, for example, you cannot decrease a volume's size; making it smaller means copying the data to a new, smaller volume. Choose the size with that in mind, and check what the larger volume costs per month.
- Some providers limit how often you can resize. EBS allows up to four modifications of a volume in a rolling 24 hours.
Raise the size in the console and confirm. On EBS the new size can be used as soon as the modification reaches the optimizing state, usually within seconds; other providers show the new size when the resize job finishes. Leave the server running.
Check it worked
Run lsblk on the disk again:
lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS "$DISK"NAME SIZE TYPE FSTYPE MOUNTPOINTS
nvme1n1 200G disk
└─nvme1n1p1 100G part ext4 /srv/dataThe disk shows the new size, while the partition, and df -hT "$MNT", still show the old one. That gap is what the next steps close. If the disk row still shows the old size after a few minutes, check the resize job in the console; on some instance types a resize only reaches the server after a restart, and your provider's documentation will say so.
Step 4 · Preview the change with a dry run
growpart can show what it would do without writing anything:
sudo growpart --dry-run "$DISK" "$PARTNUM"Note the space between the disk and the partition number: growpart /dev/nvme1n1 1, not /dev/nvme1n1p1.
Check it worked
The first line starts with CHANGE: and shows the partition's start, its old size and end, and the new size and end, in 512-byte sectors. For the 100 GiB to 200 GiB example it looks something like this:
CHANGE: partition=1 start=2048 old: size=209713119 end=209715166 new: size=419428319 end=419430366The start is the same in both, which is why your data stays in place. Below it, growpart prints the old and new sfdisk -d tables. If you see NOCHANGE: ... it cannot be grown instead, the partition already fills the disk: the server has not seen the larger volume yet, so go back to the previous step's check.
Step 5 · Grow the partition
growpart needs a few kilobytes in /tmp for its working files. If the root filesystem is completely full, it fails with No space left on device; free a little space first (see /tutorials/find-what-is-using-disk-space-linux) and run it again.
Grow the partition:
sudo growpart "$DISK" "$PARTNUM"It rewrites the partition table, moving the partition's end to the last usable sector and leaving 33 sectors at the end of the disk for the backup GPT. It then tells the running kernel about the new size with partx --update, which works while the partition is mounted, even for /.
Check it worked
growpart prints one line that starts with CHANGED: and has the same numbers as the dry run. Compare the partition with the disk:
lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS "$DISK"Now nvme1n1p1 shows nearly the full disk size (200G in the example). df -hT "$MNT" still shows the old size, because the filesystem has not grown yet. Running growpart again is harmless: it prints NOCHANGE and exits with status 1, which only means there is nothing left to do.
Step 6 · Grow the filesystem while it is mounted
Use the tool that matches the filesystem type findmnt printed in the first step. Both grow a mounted filesystem in place, while applications keep reading and writing.
For ext4, give resize2fs the partition. With no size argument it grows the filesystem to fill the partition:
sudo resize2fs "$PART"On a mounted filesystem it reports on-line resizing required and then The filesystem on /dev/nvme1n1p1 is now N (4k) blocks long. For a large volume this can take a minute or two; let it finish.
For XFS, give xfs_growfs the mount point, not the device. -d grows the data section to the largest size the partition allows:
sudo xfs_growfs -d "$MNT"It prints the filesystem geometry and then a line like data blocks changed from 26214139 to 52428539. XFS can only be grown while mounted, and it cannot be shrunk later.
Check it worked
Read the block count straight from the ext4 superblock:
sudo dumpe2fs -h "$PART" | grep -E '^(Block count|Block size):'Block count times Block size is now close to the partition size, larger than before. On any filesystem, the check that matters is df:
df -hT "$MNT"The Size column shows the new size (a little under 200G in the example, because the filesystem keeps some space for its own metadata), and Avail has gone up by the amount you added. Your files and running services were untouched throughout.
Step 7 · Grow a disk that uses LVM
If findmnt showed a source such as /dev/mapper/ubuntu--vg-ubuntu--lv, there are two more layers between the partition and the filesystem: an LVM physical volume (PV) on the partition, and a logical volume (LV) in the volume group (VG). The Ubuntu Server installer uses this layout by default. The order is the same, partition first, then each layer above it.
Find the physical volume and the partition it lives on:
sudo pvs -o pv_name,vg_name,pv_size,pv_freeSay it prints /dev/nvme0n1p3 in ubuntu-vg. Grow that partition with growpart as before, then make LVM see the extra space. Replace the device names with your own:
sudo growpart /dev/nvme0n1 3
sudo pvresize /dev/nvme0n1p3
sudo vgs ubuntu-vggrowpart 0.33 already runs pvresize itself when the partition is a physical volume, so the second command may find nothing left to do; running it is harmless and makes sure. vgs now shows the added space under VFree.
Give all the free space in the group to the logical volume, and grow its filesystem in the same command with -r (--resizefs), which calls resize2fs or xfs_growfs for you:
sudo lvextend -r -l +100%FREE /dev/ubuntu-vg/ubuntu-lv+100%FREE takes every free extent in the group. If you want to keep some back for snapshots or another volume, give a size instead, such as -L +20G.
Check it worked
sudo vgs ubuntu-vg shows VFree back near 0 (or the amount you kept), sudo lvs shows the larger LSize, and df -hT / shows the new size. The LVM tutorial (/tutorials/add-disks-and-grow-filesystems-with-lvm) covers the layers in more depth, including claiming the space the Ubuntu installer leaves unallocated.
Step 8 · Know what cloud-init does at boot
On cloud images, cloud-init runs two modules on every boot: growpart, which grows the partition holding /, and resizefs, which then grows the root filesystem. That is why a server built from a larger root disk, or rebooted after a root resize, often comes up with all the space in use without anyone running a command. You can see both modules in the default configuration and their work in the log:
grep -nE 'growpart|resizefs' /etc/cloud/cloud.cfg
sudo grep -iE 'growpart|resize' /var/log/cloud-init.log | tail -n 5Two limits make the manual steps above worth knowing anyway:
- It only acts on
/by default. Data volumes such as/srv/dataare never grown for you. - It acts at boot. Rebooting a production server to pick up space is the downtime this tutorial avoids, and a reboot of a full server is the moment you least want a surprise.
If you manage partitions yourself and do not want cloud-init to touch the root disk, you can turn the module off with a file in /etc/cloud/cloud.cfg.d/ containing growpart: {mode: "off"}.
Check it worked
The grep on cloud.cfg lists growpart and resizefs among the modules, something like - growpart and - resizefs. On a server that has been resized and rebooted, the log shows lines from cc_growpart and cc_resizefs for /. On a server without cloud-init (a physical machine, or a provider image that removes it), both commands print nothing, and the manual steps are the only way.
Next steps
- Find out what filled the disk, so the extra space lasts: /tutorials/find-what-is-using-disk-space-linux.
- Add a separate data volume instead of growing the root disk: /tutorials/partition-and-format-a-new-disk-with-parted.
- Pool several disks and grow logical volumes across them: /tutorials/add-disks-and-grow-filesystems-with-lvm.
- Make sure a data volume mounts by UUID at every boot: /tutorials/mount-a-disk-at-boot-with-fstab-and-uuids.
Related tutorials
- Write safer Bash scripts with strict mode and trapsYou will build a small Bash release script that stops on the first error, says which line failed, survives file names with spaces and always removes its temporary files.
- Write least-privilege sudo rules with visudoYou will replace blanket sudo access with checked rule files in /etc/sudoers.d that let two operators restart one service and edit one file, give an automation account a password-free command list, and audit what every account can run.
- Upgrade a server from Ubuntu 24.04 LTS to 26.04 LTSYou will take a backed-up Ubuntu 24.04 server through do-release-upgrade to 26.04 LTS over SSH with a fallback login, then confirm services, repositories and language runtimes work on the new release.
Need this done for you?
Padding does this work for growing companies, from the first diagnosis to a system that keeps working.
Get new tutorials