C3rd
VM: Resize Partition on a running system
Posted: 20 Sep 2021, 22:09pm - Monday
I was stuck for a while how to resize a running partition in my VM. Been searching for answers and all answers are quite long except this one:
root@silex5:~# df -h
Filesystem Size Used Avail Use% Mounted on
udev 3.9G 0 3.9G 0% /dev
tmpfs 798M 1.1M 797M 1% /run
/dev/sda2 49G 32G 15G 69% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/loop0 100M 100M 0 100% /snap/core/11420
/dev/loop1 18M 18M 0 100% /snap/pdftk/9
/dev/loop2 100M 100M 0 100% /snap/core/11606
tmpfs 798M 0 798M 0% /run/user/1011
root@silex5:~# growpart /dev/sda 2
CHANGED: partition=2 start=4096 old: size=104851456 end=104855552 new: size=251654111,end=251658207
root@silex5:~# resize2fs /dev/sda2
resize2fs 1.44.1 (24-Mar-2018)
Filesystem at /dev/sda2 is mounted on /; on-line resizing required
old_desc_blocks = 7, new_desc_blocks = 15
The filesystem on /dev/sda2 is now 31456763 (4k) blocks long.
root@silex5:~# df -h
Filesystem Size Used Avail Use% Mounted on
udev 3.9G 0 3.9G 0% /dev
tmpfs 798M 1.1M 797M 1% /run
/dev/sda2 118G 32G 81G 29% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/loop0 100M 100M 0 100% /snap/core/11420
/dev/loop1 18M 18M 0 100% /snap/pdftk/9
/dev/loop2 100M 100M 0 100% /snap/core/11606
tmpfs 798M 0 798M 0% /run/user/1011
root@silex5:~# reboot
Reference: https://unix.stackexchange.com/questions/137482/how-to-to-resize-an-ext4-partition-from-the-command-line