b0rken.org / freebsd / Resizing zpool comprising GPT partitions
Resizing zpool and underlying GPT partitions
Here are the results of my experiment in resizing the GPT partitions that a raidz zpool is built on. The test machine is a virtual host running 8.1-RELEASE amd64, with twelve 1GB virtual disks attached. They are detected by FreeBSD as ada1 through ada12.
- Create GPT tables on three disks:
- Create one freebsd-zfs partition on each disk, each using half the available space (512MB):
- Display partitions so far:
- Create raidz pool and show the status:
- Export the pool, delete one of the underlying partitions and recreate it spanning the whole disk:
- Reimport the pool and check its status:
- Export pool and resize the other two partitions:
- Reimport the pool again and check its status:
vFreeBSD# gpart create -s GPT ada1 ada1 created vFreeBSD# gpart create -s GPT ada2 ada2 created vFreeBSD# gpart create -s GPT ada3 ada3 created
vFreeBSD# gpart add -s 1048576 -t freebsd-zfs ada1 ada1p1 added vFreeBSD# gpart add -s 1048576 -t freebsd-zfs ada2 ada2p1 added vFreeBSD# gpart add -s 1048576 -t freebsd-zfs ada3 ada3p1 added
vFreeBSD# gpart show
(snipped)
=> 34 2097085 ada1 GPT (1.0G)
34 1048576 1 freebsd-zfs (512M)
1048610 1048509 - free - (512M)
=> 34 2097085 ada2 GPT (1.0G)
34 1048576 1 freebsd-zfs (512M)
1048610 1048509 - free - (512M)
=> 34 2097085 ada3 GPT (1.0G)
34 1048576 1 freebsd-zfs (512M)
1048610 1048509 - free - (512M)
vFreeBSD# zpool create test1 raidz ada1p1 ada2p1 ada3p1
vFreeBSD# zpool status
pool: test1
state: ONLINE
scrub: none requested
config:
NAME STATE READ WRITE CKSUM
test1 ONLINE 0 0 0
raidz1 ONLINE 0 0 0
ada1p1 ONLINE 0 0 0
ada2p1 ONLINE 0 0 0
ada3p1 ONLINE 0 0 0
errors: No known data errors
vFreeBSD# zfs list
NAME USED AVAIL REFER MOUNTPOINT
test1 87.9K 980M 24.0K /test1
The pool is about 1GB in size, which is expected for a raidz pool based on three 512MB devices
vFreeBSD# zpool export test1
vFreeBSD# gpart delete -i 1 ada1
ada1p1 deleted
vFreeBSD# gpart add -t freebsd-zfs ada1
ada1p1 added
vFreeBSD# gpart show
(snipped)
=> 34 2097085 ada1 GPT (1.0G)
34 2097085 1 freebsd-zfs (1.0G)
=> 34 2097085 ada2 GPT (1.0G)
34 1048576 1 freebsd-zfs (512M)
1048610 1048509 - free - (512M)
=> 34 2097085 ada3 GPT (1.0G)
34 1048576 1 freebsd-zfs (512M)
1048610 1048509 - free - (512M)
vFreeBSD# zpool import test1
vFreeBSD# zpool status
pool: test1
state: ONLINE
scrub: none requested
config:
NAME STATE READ WRITE CKSUM
test1 ONLINE 0 0 0
raidz1 ONLINE 0 0 0
ada1p1 ONLINE 0 0 0
ada2p1 ONLINE 0 0 0
ada3p1 ONLINE 0 0 0
errors: No known data errors
vFreeBSD# zfs list
NAME USED AVAIL REFER MOUNTPOINT
test1 87.9K 980M 24.0K /test1
The pool is still intact and has no errors and is the same size as before.
vFreeBSD# zpool export test1
vFreeBSD# gpart delete -i 1 ada2
ada2p1 deleted
vFreeBSD# gpart add -t freebsd-zfs ada2
ada2p1 added
vFreeBSD# gpart delete -i 1 ada3
ada3p1 deleted
vFreeBSD# gpart add -t freebsd-zfs ada3
ada3p1 added
vFreeBSD# gpart show
(snipped)
=> 34 2097085 ada1 GPT (1.0G)
34 2097085 1 freebsd-zfs (1.0G)
=> 34 2097085 ada2 GPT (1.0G)
34 2097085 1 freebsd-zfs (1.0G)
=> 34 2097085 ada3 GPT (1.0G)
34 2097085 1 freebsd-zfs (1.0G)
Now all three partitions underlying the zpool have been expanded from 512MB to 1GB
vFreeBSD# zpool import test1
vFreeBSD# zpool status
pool: test1
state: ONLINE
scrub: none requested
config:
NAME STATE READ WRITE CKSUM
test1 ONLINE 0 0 0
raidz1 ONLINE 0 0 0
ada1p1 ONLINE 0 0 0
ada2p1 ONLINE 0 0 0
ada3p1 ONLINE 0 0 0
errors: No known data errors
vFreeBSD# zfs list
NAME USED AVAIL REFER MOUNTPOINT
test1 91.9K 1.96G 24.0K /test1
Now that all three underlying freebsd-zfs partitions have been grown, the zpool has automatically expanded to fill the available space and is now about 2GB in size. At no point was the zpool in an error state.
The act of deleting a partition does not in itself destroy the filesystem that was contained in it. As long as a new partition is created with the the same starting sector number and the ending sector number equal or greater then before, the filesystem should remain intact.
Last modified: 2011-01-30 10:54