Expand disk size of Rocky Linux 8 Vagrant box for libvirt provider
2 min readMar 22, 2022
This short note shows you how to expand disk size and filesystem of Rocky Linux 8 Vagrant box for libvirt provider.
Rocky Linux 8 official Vagrant box has 4GB of disk space. Sometimes we need more disk space to play with. When you use VirtualBox provider, there is a plug-in vagrant-disksize. For libvirt provider, there isn’t a plug-in.
Here is a Vagrantfile that expand disk size 4GB to 40GB.
- Line 18:
libvirt.machine_virtual_size = 40
define disk size for VM. - Line 22:
growpart /dev/vda 1
expands partition size. - Line 23:
xfs_growfs /dev/vda1
expands filesystem.
Here is a log.
lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 253:0 0 40G 0 disk
└─vda1 253:1 0 4G 0 part /growpart /dev/vda 1lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 253:0 0 40G 0 disk
└─vda1 253:1 0 40G 0 part /df -BG
Filesystem 1G-blocks Used Available Use% Mounted on
devtmpfs 2G 0G 2G 0% /dev
tmpfs 2G 0G 2G 0% /dev/shm
tmpfs 2G 1G 2G 1% /run
tmpfs 2G 0G 2G 0% /sys/fs/cgroup
/dev/vda1 4G 4G 1G 93% /
tmpfs 1G 0G 1G 0% /run/user/1000xfs_growfs /dev/vda1
meta-data=/dev/vda1 isize=512 agcount=4, agsize=262080 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1
data = bsize=4096 blocks=1048320, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 1048320 to 10485499df -BG
Filesystem 1G-blocks Used Available Use% Mounted on
devtmpfs 2G 0G 2G 0% /dev
tmpfs 2G 0G 2G 0% /dev/shm
tmpfs 2G 1G 2G 1% /run
tmpfs 2G 0G 2G 0% /sys/fs/cgroup
/dev/vda1 40G 4G 37G 10% /
tmpfs 1G 0G 1G 0% /run/user/1000