Extend FreeBSD ZFS inside KVM with virsh

## Example details:

# Disk is sized 15G, we will extend it to 25G.
# RAM is 2G, Swap is also 2G.
# First partition is freebsd-boot.
# Second and third is eigher freebsd-swap or freebsd-zfs. I will cover both cases below.

## From KVM Host:

# When extending a ‘raw’ device, it will warn you that it is dangerous.
# I just ignored that warning, but it might mean something to you.

virsh shutdown <host>
cd /var/kvm
qemu-img info <host>.img
qemu-img resize <host>.img +10G
virsh start <host>

## Inside host: (FreeBSD ZFS)

# The recover command is due to the last copy of GPT is not in the right place.
# This will fix the ‘CORRUPT’ error.

# If zfs partition is p3 and swap is p2:

gpart show
gpart recover vtbd0  
gpart show
gpart resize -i 3 -a 4k vtbd0
gpart show 
zpool list
zpool set autoexpand=on zroot
zpool online -e zroot vtbd0p3
zpool list
zfs list

# If the swap partition is p3 and zfs is p2, it is in the way. Delete it, resize with ‘-s <size>’ to make room for swap, and create it again.

gpart show
gpart recover vtbd0  
gpart show
swapoff /dev/vtbd0p3
gpart delete -i 3 vtbd0
gpart resize -i 2 -a 4k -s 23G vtbd0
gpart add -t freebsd-swap -a 4k vtbd0
gpart show
swapon /dev/vtbd0p3
zpool list
zpool set autoexpand=on zroot
zpool online -e zroot vtbd0p2
zpool list
zfs list

 

Dette indlæg blev udgivet i FreeBSD, Knowledge Base, Old Base, Zfs. Bogmærk permalinket.

Skriv et svar