baumi's blog

baumi's personal blog … Linux, OS X, Windows, Random things, …

ZFS zpool creation


fdisk /dev/sdXXXX #then "g" to set type GPT
sgdisk --zap-all /dev/sdXXXX
zpool create poolname raidz2 /dev/sd[b-f]
zfs set compression=lz4 poolname
zfs set mountpoint=/mnt/poolname poolname

zpool add poolname spare /dev/sdXXXXXXX
zpool set autoreplace=on poolname
zpool status poolname

*FORCING /dev/disk/by-id instead of /dev/sdX*

zpool import -d /dev/disk/by-id/ata-Hitachi_HDS722020ALA330_JK1101YAKDJN7V-part1 -d /dev/disk/by-id/ata-Hitachi_HDS722020ALA330_JK1161YAGS0G5V-part1 -d /dev/disk/by-id/ata-Hitachi_HDS723020BLA642_MN1270FA02L5ED-part1 -d /dev/disk/by-id/ata-Hitachi_HDS723020BLA642_MN1270FA02TW8D-part1 -d /dev/disk/by-id/ata-HGST_HUS724020ALE640_PK1131P6G73LJN-part1 -d /dev/disk/by-id/ata-Hitachi_HDS723020BLA642_MN1220F32DDADD-part1 zpoolname

zpool import -d /dev/disk/by-id/ata-HGST_HDN726060ALE614_NCGU9UJS-part1 zbackup


sudo zpool export poolname
zpool import -d /dev/disk/by-id -aN poolname


zpool export poolname


In case your disk order changed and thus your zpool disappeared after reboot, try:
zpool import poolname


Personal notice: using zfs snapshot to backup pools to another disk seems to suck majorly, i’ve moved back to rsync. Maybe it’s not as fast, but it fckn just works and doesn’t run for many hours and then ends with a stupid error message such as “no space left on disk” despite i just destroyed and created a brand new pool previously and the backup disk being the same size as the initial pool. As much as i love zfs, doing backups to other disks using snapshots seems silly. Snapshots are great for the live system, of course.

#create backup pool
sudo sgdisk --zap-all /dev/sdXXXXX
zpool create zbackup /dev/sdXXXX
zfs set compression=lz4 zbackup
zfs set mountpoint=/mnt/backup zbackup

# -r = recursive
zfs snapshot -r zpool@backup
zfs list -t snapshot
#zfs send -R zpool@backup | zfs recv -Fu zbackup
zfs send -R zpool@backup | zfs recv -F zbackup
zfs destroy -r zpool@backup

Comments are currently closed.