Expand ZFS Pool On Raw Disk Image
Introduction
I have a large raw disk image attached to a KVM virtual machine. It has run out of space, so I need to expand the disk. Normally I would just attach another disk and move the content to that larger disk, but that is not an option because the server does not have enough space to create yet another disk that is the same size or larger than the original. Thus, my only option is to expand the existing disk.
Steps
Create A Backup
If you can create a backup (probably by performing a ZFS send/recieve to another server), then go ahead and do that now.
Expand The Raw Disk
Run the following command to increase the size of your raw disk.
sudo qemu-img resize \
-f raw \
myDisk.raw \
+[SIZE_IN_GB]G
Identify Disk To Expand
Now we need to find out the name of the disk to expand (from within the server). I did this by running:
sudo zpool status -v
... which outputted the following:
pool: zpool1
state: ONLINE
config:
NAME STATE READ WRITE CKSUM
zpool1 ONLINE 0 0 0
vdb ONLINE 0 0 0
This shows that the disk that my pool is set up on is vdb
.
Expand The Zpool
DISK="vdb"
sudo zpool online -e zpool1 $DISK
Now you should see that your pool has been expanded by running:
sudo zfs list
... which outputted for me:
NAME USED AVAIL REFER MOUNTPOINT
zpool1 147K 28.6G 24K /zpool1
This should show you that you now have more available space in your pool.
References
First published: 15th November 2024