Let's say you had a small disk on a VM and now it's full and wants to resize disk without rebooting.
(I've tested this on NixOS but it should work on other distros as well)
[root@nixos-box:~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sr0 11:0 1 4M 0 rom
vda 253:0 0 3.1G 0 disk
└─vda1 253:1 0 3.1G 0 part /nix/store
/Resize on a virtual hardware level:
- (on Proxmox) Choose VM > Select Disk > Disk Action > Resize Disk
- (do the equivalent for other VMM)
[root@nixos-box:~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sr0 11:0 1 4M 0 rom
vda 253:0 0 23.1G 0 disk # disk has grown
└─vda1 253:1 0 3.1G 0 part /nix/store # but not here
/[root@nixos-box:~]# nix-shell -p cloud-utils # to install growpart
[nix-shell:~]# growpart /dev/vda 1
CHANGED: partition=1 start=2048 old: size=6469632 end=6471679 new: size=48412639 end=48414686
[nix-shell:~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sr0 11:0 1 4M 0 rom
vda 253:0 0 23.1G 0 disk
└─vda1 253:1 0 23.1G 0 part /nix/store # now it's grownBut inodes are running out
[nix-shell:~]# df -ih
Filesystem Inodes IUsed IFree IUse% Mounted on
devtmpfs 245K 408 244K 1% /dev
tmpfs 247K 1 247K 1% /dev/shm
tmpfs 247K 1.2K 246K 1% /run
/dev/disk/by-label/nixos 198K 145K 54K 73% / # see here
tmpfs 1.0K 1 1023 1% /run/credentials/systemd-journald.service
tmpfs 1.0K 1 1023 1% /run/credentials/systemd-resolved.service
tmpfs 247K 18 247K 1% /run/wrappers
tmpfs 1.0K 1 1023 1% /run/credentials/systemd-networkd.service
tmpfs 1.0K 1 1023 1% /run/credentials/[email protected]
tmpfs 1.0K 1 1023 1% /run/credentials/[email protected]
tmpfs 50K 17 50K 1% /run/user/0[nix-shell:~]# resize2fs /dev/vda1
resize2fs 1.47.2 (1-Jan-2025)
Filesystem at /dev/vda1 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 3
The filesystem on /dev/vda1 is now 6051579 (4k) blocks long.[nix-shell:~]# df -ih
Filesystem Inodes IUsed IFree IUse% Mounted on
devtmpfs 245K 408 244K 1% /dev
tmpfs 247K 1 247K 1% /dev/shm
tmpfs 247K 1.2K 246K 1% /run
/dev/disk/by-label/nixos 1.5M 145K 1.3M 10% / # now it's grown
tmpfs 1.0K 1 1023 1% /run/credentials/systemd-journald.service
tmpfs 1.0K 1 1023 1% /run/credentials/systemd-resolved.service
tmpfs 247K 18 247K 1% /run/wrappers
tmpfs 1.0K 1 1023 1% /run/credentials/systemd-networkd.service
tmpfs 1.0K 1 1023 1% /run/credentials/[email protected]
tmpfs 1.0K 1 1023 1% /run/credentials/[email protected]
tmpfs 50K 17 50K 1% /run/user/0All good now!