Jul '14 15

ZFS on Linux

I’ve been looking at ZFS on Linux for some time now, mainly due to silent corruption on my EXT4 file-system. One of the big benefits for me is data/meta checksums, on data corruption is fetched from parity, and a data scrub picks up large numbers of errors. One of implementation problems is that people recommend ECC memory. This is due to the chance that bad memory may corrupt the disk when doing a scrub of the data and the Checksums fail to match.

Another feature that I hope to use is Autogrow, by replacing the existing disks with larger disks one-by-one, then resilvering the data across all the disks, when the last one is replaced, the new space becomes available to the pool. While its a lot to get your head around, ZFS (now owned by Oracle) is very similar to WAFL on NetApp. So that makes it far easier for me to grasp.

  • Use /dev/disk/by-id/ata-* convention when adding to the zpool
  • Use Whole Disk and ashift=12 for 4k blocks
  • Use disk quantity’s of power of 2 plus parity
  • set parameters such as autoexpand/autoreplace on before they are needed
  • create subvolumes on the pool for space and or quota management
  • unmount any previous mountpoint before doing set mountpoint (its immediate)
  • Align Partitions on 4k boundaries ie: python ((314574848*512)%4096) = 0 remainder

For my new setup I plan to use 2 x 2TB, partitioned as follows

  • Part1 – 100G – linux mirror (md0)
    • / (root/boot) – 30G ext4
    • /var  – 80G riserfs
    • /home/media/Videos/PchMenu – 10G riserfs
    • swap – 20G swap
  • Part2 – Remainder – ZFS mirror
    • rpool/home
    • rpool/home/photos
    • rpool/home/camera
    • rpool/music

For my media I plan to use 3x4TB in raidz1 as follows

  • Whole of disk
    • storage
    • storage/media
    • storage/backups

zpool create -o ashift=12 backup /dev/disk/by-id/ata-HGST_HDN724040ALE640_PK2334PBHE5JHR

zpool create -o ashift=12 rpool mirror sda sdb
zpool set autoexpand=on rpool
zfs create rpool/home
zfs create rpool/home/photos
zfs create rpool/home/camera
zfs create rpool/music
zfs set canmount=noauto rpool
zfs set atime=off rpool
zfs set atime=on rpool/home
zfs set relatime=on rpool/home
zfs set atime=off rpool/home/photos
zfs set atime=off rpool/home/camera
zfs set mountpoint=/home rpool/home
zfs set quota=10G rpool/home/camera
#zfs set copies=2 rpool/home/photos

zpool create -o ashift=12 storage raidz sdc sdd sde
zpool set autoexpand=on storage
zfs create storage/media
zfs create storage/backups
zfs create storage/backups/dad
zfs create storage/backups/dean
zfs set canmount=noauto storage
zfs set canmount=noauto storage/backups
zfs set atime=off storage
#zpool set autoreplace=on storage
#zfs set sync=disabled storage
#zfs set compression=on documents

You can put swap onto zfs, not sure if its wise though

#sudo zfs create tank/swap -V 2G -b 4K
#sudo mkswap -f /dev/tank/swap
#sudo swapon /dev/tank/swap