Support #521
Updated by Daniel Curtis almost 10 years ago
{{>toc}} One of the many projects I had for my pi was installing ZFS. While Raspbian is a a good distro for beginners, I require a bit more control and up to date packages than Raspbian can provide, so I use Arch Linux. This is a guide on how I compiled support for ZFS on my Raspberry Pi. *WARNING*: I have not yet finished this yet, so please treat this as experimental for the time being. *NOTE*: I have found that installing the zfs-dkms package from the AUR is much easier than trying to roll a custom kernel just for ZFS. h2. Prepare The System * Update the system: <pre> pacman -Syu </pre> * Install base-devel, cmake, and linux-headers packages <pre> pacman -S base-devel cmake linux-headers </pre> h3. Format the USB drives This guide is using USB drives for its data drives. * Format /dev/sda: <pre> fdisk /dev/sda </pre> #* And type the following to format the USB drive as a Solaris root partition: <pre> g n 1 [Enter] [Enter] t 39 w </pre> * Format /dev/sdb: <pre> fdisk /dev/sdb </pre> #* And type the following to format the USB drive as a Solaris root partition: <pre> g n 1 [Enter] [Enter] t 39 w </pre> h3. Install yaourt Yaourt isn't necessary, but makes managing AUR packages a lot easier. * Download the packages for yaourt: <pre> cd /tmp wget https://aur.archlinux.org/packages/pa/package-query/package-query.tar.gz && wget https://aur.archlinux.org/packages/ya/yaourt/yaourt.tar.gz tar xzf package-query.tar.gz tar xzf yaourt.tar.gz </pre> #* Install package-query: <pre> cd ../package-query makepkg -csi </pre> #* Install yaourt <pre> cd ../yaourt makepkg -csi </pre> --- h2. Install ZFS DKMS from the AUR * Install zfs-dkms: <pre> yaourt zfs-dkms </pre> * *NOTE*: Edit the +PKGBUILD+ for *zfs-dkms*, *spl-dkms*, and *zfs-utils* #* And modify the arch parameter to match the following; adding *"armv6h"* and *"armv6l"*: <pre> arch=("i686" "x86_64" "armv6h" "armv6l") </pre> * Install zfs-utils: <pre> yaourt zfs-utils </pre> #* Force install the zfs-utils package (probably a bad idea, but the only way I could get it to install properly): <pre> pacman -U --force /tmp/yaourt-tmp-username/zfs-utils-0.6.3-1.2-armv6h.pkg.tar.xz </pre> #* Replace *username* with the user that built the zfs-utils package #* Replace the version with the current version being installed * Install the zfs kernel module: <pre> depmod -a modprobe zfs </pre> * Check that the zfs modules were loaded: <pre> lsmod </pre> #* _Example output:_ <pre> zfs 1229845 0 zunicode 322454 1 zfs zavl 5993 1 zfs zcommon 43765 1 zfs znvpair 80689 2 zfs,zcommon spl 165409 5 zfs,zavl,zunicode,zcommon,znvpair </pre> --- h2. Setting Up The Pools This guide will be setting up a mirror of 2 USB drives, both will shown as */dev/sda* and */dev/sdb*, respectively. h3. Create a storage pool * Get the id's of the drives to add to the zpool. The zfs on Linux developers recommend using device ids when creating ZFS storage pools of less than 10 devices. To find the id's, simply: <pre> ls -lah /dev/disk/by-id/ </pre> #* _Example output:_ <pre> lrwxrwxrwx 1 root root 9 Aug 12 16:26 usb-SanDisk_Cruzer_20015001801AE2D0432E-0:0-part1 usb-SanDisk_Cruzer_9YN166_S1F0JKRR -> ../../sda lrwxrwxrwx 1 root root 9 Aug 12 16:26 usb-SanDisk_Cruzer_20022213091FE2A0CC42-0:0-part1 usb-SanDisk_Cruzer_9YN166_S1F0KDGY -> ../../sdb </pre> * Create the ZFS pool: <pre> zpool create -f -m /mnt/usbpool usbpool mirror usb-SanDisk_Cruzer_20015001801AE2D0432E-0\:0-part1 usb-SanDisk_Cruzer_20022213091FE2A0CC42-0\:0-part1 usb-SanDisk_Cruzer_9YN166_S1F0JKRR usb-SanDisk_Cruzer_9YN166_S1F0KDGY </pre> *NOTE*: Make sure the path to the partition is used and not the path for the disk itself, or else an error will occur. * Check the zpool status: <pre> zpool status </pre> #* _Example output:_ <pre> pool: usbpool state: ONLINE scan: none requested config: NAME STATE READ WRITE CKSUM usbpool ONLINE 0 0 0 mirror-0 ONLINE 0 0 0 usb-SanDisk_Cruzer_20015001801AE2D0432E-0:0-part1 ONLINE 0 0 0 usb-SanDisk_Cruzer_20022213091FE2A0CC42-0:0-part1 ONLINE 0 0 0 errors: No known data errors </pre> * Create a mountpoint: <pre> zfs create usbpool/home -o mountpoint=/home </pre> * Check the mount point status: <pre> zfs list usbpool/home </pre> #* _Example output:_ <pre> NAME USED AVAIL REFER MOUNTPOINT usbpool/home 30K 58.6G 30K /home </pre> * Automatically mount the zfs pool: <pre> mkdir -p /etc/zfs zpool set cachefile=/etc/zfs/zpool.cache usbpool </pre> #* Enable the service so it is automatically started at boot time: <pre> systemctl enable zfs.target </pre> #* To manually start the daemon: <pre> systemctl start zfs.target </pre> h2. Resources * https://wiki.archlinux.org/index.php/ZFS * https://aur.archlinux.org/packages/zfs-dkms/ * https://aur.archlinux.org/packages/zfs-utils/