Create a FreeBSD mirror for swap on partitioned devices
List the devices names:
# camcontrol devlist
'ada1' and 'ada2' are a pair of disks that will be used. Create a GPT on each of the disks. Create a partition on each disk with a label. This label is added to the filesystem as 'dev/gpt/<label>'.
# gpart create -s GPT ada1 # gpart create -s GPT ada2 # gpart add -t freebsd-swap -l swap-mirror0 ada1 # gpart add -t freebsd-swap -l swap-mirror1 ada2
Create a mirror:
# gmirror label -v -b round-robin swap-mirror gpt/swap-mirror0 gpt/swap-mirror1 Metadata value stored on gpt/swap-mirror0. Metadata value stored on gpt/swap-mirror1. Done.
Manually load the swap (this will automatically occur at boot):
# swapon /dev/mirror/swap-mirror # swapinfo Device 1K-blocks Used Avail Capacity /dev/mirror/swap-mirror 34771188 0 34771188 0%
Create ZFS log mirrors
This is a workaround for not being able to afford distinct SSD's for multiple ZFS pools. Instead partition up a slice off the two SSD for each pool (This will limit the synchronous write bandwidth to this disks). Use a GPT label for each partition and add them to the zpool using those GPT labels.
# gpart add -t freebsd-zfs -l tank-log0 -s 30G ada1 # gpart add -t freebsd-zfs -l tank-log1 -s 30G ada2 # zpool add tank log mirror gpt/tank-log0 gpt/tank-log1
Links
- https://www.freebsd.org/doc/handbook/geom-mirror.html
- https://www.freebsd.org/cgi/man.cgi?query=gmirror&apropos=0&sektion=0&manpath=FreeBSD+10.1-stable&arch=default&format=html
Appendices
gpart show
# gpart show => 34 312581741 ada0 GPT (149G) 34 155189248 1 freebsd-zfs (74G) 155189282 157392493 2 freebsd-zfs (75G) => 34 195371501 ada1 GPT (93G) 34 62914560 1 freebsd-zfs (30G) 62914594 62914560 2 freebsd-zfs (30G) 125829154 69542381 3 freebsd-swap (33G) => 34 195371501 ada2 GPT (93G) 34 62914560 1 freebsd-zfs (30G) 62914594 62914560 2 freebsd-zfs (30G) 125829154 69542381 3 freebsd-swap (33G)