Resize partition from virtual machine without reboot

I run several virtual ubuntu machines on a proxmox server. They all have a single disk without LVM. When disk space runs out I poweroff the virtual machine, then enlarge the partition, mount gparted ISO, boot from this ISO, resize the partition, and boot the vm again.

Now I wonder if there is a simpler way without rebooting the virtual machine.

1 Answer

Toggle some informations about the root filesystem:

df /
# Filesystem 1K-blocks Used Available Use% Mounted on
# /dev/sda2 31365948 5249140 24500424 18% /

/dev/sda2 is the second partition of block device /dev/sda. To size up this partition, you can use the tool parted.

parted /dev/sda
# (parted) resizepart 2
# Warning: Partition /dev/sda2 is being used. Are you sure you want to continue?
# Yes/No? yes
# End? [41.0GB]? 82GB
# (parted) q
# Information: You may need to update /etc/fstab.

After changing size of partition, you have to size up the filsystem too:

resize2fs /dev/sda2
# resize2fs 1.45.5 (07-Jan-2020)
# Filesystem at /dev/sda2 is mounted on /; on-line resizing required
# old_desc_blocks = 4, new_desc_blocks = 9
# The filesystem on /dev/sda2 is now 18019403 (4k) blocks long.

This is for checking modifications:

df /
# Filesystem 1K-blocks Used Available Use% Mounted on
# /dev/sda2 70817420 5253016 62349464 8% /
1

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

You Might Also Like