108 lines
2.5 KiB
Markdown
108 lines
2.5 KiB
Markdown
# ZFS
|
|
|
|
How to setup zfs on 64 bit arm boards.
|
|
|
|
*Note: this is wholly untested and likely to be broken on 32 bit arm boards*
|
|
|
|
## Initial Install / Setup
|
|
|
|
``` bash
|
|
|
|
apt-add-repository universe
|
|
apt install zfs-dkms spl-dkms zfsutils-linux
|
|
cat > /etc/modprobe.d/zfs.conf <<EOF
|
|
# Minimize RAM pain
|
|
#options zfs zfs_arc_max=268435456 zfs_arc_meta_limit=201326592
|
|
options zfs zfs_arc_max=134217728 zfs_arc_meta_limit=67108864
|
|
#options zfs zfs_arc_max=100663296 zfs_arc_meta_limit=50331648
|
|
EOF
|
|
|
|
```
|
|
|
|
## Disk Setup and Pool Creation
|
|
|
|
Partition the disk and setup the zfs pool with basic settings
|
|
|
|
``` bash
|
|
|
|
parted /dev/disk/by-id/ata-Samsung_Portable_SSD_T5_S3UKNP0K601164R
|
|
mklabel gpt
|
|
mkpart
|
|
zpool create -o ashift=12 \
|
|
-O copies=2 \
|
|
-O atime=off -O compression=lz4 \
|
|
-O normalization=formD \
|
|
tank \
|
|
/dev/disk/by-id/usb-JMicron_Tech_0000000055A1-0\:0-part1
|
|
|
|
zpool status
|
|
|
|
cat /sys/module/zfs/parameters/zfs_arc_max
|
|
cat /sys/module/zfs/parameters/zfs_arc_meta_limit
|
|
|
|
```
|
|
|
|
## zfs Backed Swap
|
|
|
|
Move swap from zram to zfs volumes on disk
|
|
|
|
``` bash
|
|
|
|
zfs create tank/swap
|
|
zfs create -V 1G -b $(getconf PAGESIZE) -o compression=zle \
|
|
-o logbias=throughput -o sync=always \
|
|
-o primarycache=metadata -o secondarycache=none \
|
|
-o com.sun:auto-snapshot=false tank/swap/swap.1
|
|
zfs create -V 1G -b $(getconf PAGESIZE) -o compression=zle \
|
|
-o logbias=throughput -o sync=always \
|
|
-o primarycache=metadata -o secondarycache=none \
|
|
-o com.sun:auto-snapshot=false tank/swap/swap.2
|
|
|
|
mkswap -f /dev/zvol/tank/swap/swap.1
|
|
mkswap -f /dev/zvol/tank/swap/swap.2
|
|
echo /dev/zvol/tank/swap/swap.1 none swap defaults 0 0 >> /etc/fstab
|
|
echo /dev/zvol/tank/swap/swap.2 none swap defaults 0 0 >> /etc/fstab
|
|
swapon -af
|
|
|
|
nano -w /etc/fstab # Add above swap and remove exiting ones
|
|
|
|
nano -w /etc/default/armbian-zram-config
|
|
# Disabe if NOT using /var/log in RAM
|
|
|
|
```
|
|
|
|
## Regular scrubs and integrity checks
|
|
|
|
``` bash
|
|
|
|
crontab -e
|
|
22 0 14 * * /sbin/zpool scrub tank
|
|
|
|
```
|
|
|
|
## Bulk storage and Samba filesystem shares
|
|
|
|
``` bash
|
|
|
|
# Samba toolchain
|
|
apt install samba tdb-tools
|
|
|
|
# Samba user setup
|
|
useradd -g users -s /usr/sbin/nologin [username]
|
|
passwd [username]
|
|
smbpasswd -a [username]
|
|
|
|
nano -w /etc/samba/smb.conf
|
|
workgroup = non-default
|
|
comment out all share definitions
|
|
|
|
systemctl restart smbd
|
|
|
|
# Bulk storage for all the things
|
|
zfs create -o sharesmb=on tank/downloads
|
|
zfs create -o sharesmb=on tank/scratch
|
|
|
|
cat /var/lib/samba/usershares/*
|
|
|
|
```
|