From 1d2c31a15ad15cea117f6e15a0ac34b36f50de4f Mon Sep 17 00:00:00 2001 From: Przemyslaw Kwiatkowski Date: Mon, 21 Dec 2020 09:21:53 +0100 Subject: [PATCH] ZFS on HDD --- docs/helios64/install/docker-zfs.md | 67 +++++++++++++++++++++++++++++ docs/helios64/install/lxd-zfs.md | 47 ++++++++++++++++++++ docs/helios64/install/zfs.md | 66 ++++++++++++++++++++++++++++ mkdocs.yml | 3 ++ 4 files changed, 183 insertions(+) create mode 100644 docs/helios64/install/docker-zfs.md create mode 100644 docs/helios64/install/lxd-zfs.md create mode 100644 docs/helios64/install/zfs.md diff --git a/docs/helios64/install/docker-zfs.md b/docs/helios64/install/docker-zfs.md new file mode 100644 index 0000000..129787e --- /dev/null +++ b/docs/helios64/install/docker-zfs.md @@ -0,0 +1,67 @@ +# Docker with ZFS pool + +When you already have working ZFS pool (see [here](/helios64/install/zfs)) and want to use Docker - it is good idea to use them togeter. + +## **Step 1** - Prepare filesystem + +```bash +sudo zfs create -o mountpoint=/var/lib/docker mypool/docker-root +sudo zfs create -o mountpoint=/var/lib/docker/volumes mypool/docker-volumes +sudo chmod 700 /var/lib/docker/volumes +``` + +Optional: If you use zfs-auto-snapshot, you might want to consider this: + +```bash +sudo zfs set com.sun:auto-snapshot=false mypool/docker-root +sudo zfs set com.sun:auto-snapshot=true mypool/docker-volumes +``` + +Create `/etc/docker/daemon.json` with the following content: + +```bash +{ + "storage-driver": "zfs" +} +``` + +## **Step 2** - Install Docker + +Add `/etc/apt/sources.list.d/docker.list` with the following content: + +```bash +deb [arch=arm64] https://download.docker.com/linux/ubuntu focal stable +# deb-src [arch=arm64] https://download.docker.com/linux/ubuntu focal stable +``` + +Proceed with installation: + +```bash +sudo apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common +curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add - +sudo apt update +sudo apt install docker-ce docker-ce-cli containerd.io +``` + +You might want this: +```bash +sudo usermod -aG docker your-user +``` + +Voila! Your Docker should be ready! Test it: + +```bash +docker run hello-world +``` + +## **Step 3** - Optional: Install Portainer + +```bash +sudo zfs create mypool/docker-volumes/portainer_data +# You might omit the above line if you do not want to have separate dataset for the docker volume (bad idea). + +docker volume create portainer_data +docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce +``` + +Go to `http://yourip:9000` and configure. diff --git a/docs/helios64/install/lxd-zfs.md b/docs/helios64/install/lxd-zfs.md new file mode 100644 index 0000000..44ee3f9 --- /dev/null +++ b/docs/helios64/install/lxd-zfs.md @@ -0,0 +1,47 @@ +# LXD with ZFS pool + +When you already have working ZFS pool (see [here](/helios64/install/zfs)) and want to use LXD - it is good idea to use them togeter. + +## **Step 1** - Prepare filesystem + +```bash +sudo zfs create -o mountpoint=none mypool/lxd-pool +``` + +## **Step 2** - Install LXD + +```bash +sudo apt install lxd +``` + +You might want this: +```bash +sudo usermod -aG lxd your-user +``` + +## **Step 3** - Configure LXD + +```bash +sudo lxc init +``` + +Configure ZFS this way: +```bash +Do you want to configure a new storage pool (yes/no) [default=yes]? yes +Name of the new storage pool [default=default]: +Name of the storage backend to use (dir, btrfs, ceph, lvm, zfs) [default=zfs]: zfs +Create a new ZFS pool (yes/no) [default=yes]? no +Name of the existing ZFS pool or dataset: mypool/lxd-pool +[...] +``` + +## **Step 4** - Optional + +If you use zfs-auto-snapshot, you might want to consider this: + +```bash +sudo zfs set com.sun:auto-snapshot=false mypool/lxd-pool +sudo zfs set com.sun:auto-snapshot=true mypool/lxd-pool/containers +sudo zfs set com.sun:auto-snapshot=true mypool/lxd-pool/custom +sudo zfs set com.sun:auto-snapshot=true mypool/lxd-pool/virtual-machines +``` diff --git a/docs/helios64/install/zfs.md b/docs/helios64/install/zfs.md new file mode 100644 index 0000000..bab7b85 --- /dev/null +++ b/docs/helios64/install/zfs.md @@ -0,0 +1,66 @@ +# ZFS on HDD + +So you already installed the system on eMMC or SD? You might want to use ZFS on the hard disk(s)! + +Note: This wiki does not cover root-on-zfs. (Althrough it should be also possible.) We assume rootfs is already on eMMC (or SD) and you want to keep your data on HDDs in ZFS pool. + +Important: *Focal* is required. Do not use Buster. + +## **Step 1** - Install Focal on eMMC + +See necessary steps [here](/helios64/install/transfer). + +## **Step 2** - Install ZFS + +```bash +sudo armbian-config +``` + +Go to Software and install headers. + +```bash +sudo apt install zfs-dkms zfsutils-linux +``` + +Optional: +```bash +sudo apt install zfs-auto-snapshot +``` + +Reboot. + +## **Step 3** - Prepare partitions + +Use `fdisk` of `gdisk` to create necessary partitions on your hard drive. This is beyond scope of this wiki. +When ready look for assigned uuids: + +```bash +ls -l /dev/disk/by-partuuid/ +``` + +## **Step 4** - Create ZFS pool + +```bash +sudo zpool create -o ashift=12 -m /mypool mypool mirror /dev/disk/by-partuuid/abc123 /dev/disk/by-partuuid/xyz789 +sudo zfs set atime=off mypool +sudo zfs set compression=on mypool +``` + +Of course you may use more disks and create raidz instead of mirror. Your choice. :-) + +Note: Do not use `/dev/sdXY` names. Use uuids only. This way your system will still work when you remove a disk or change order of disks. + +If your disks are SSDs, enable trim support: +```bash +sudo zpool set autotrim=on mypool +``` + +## **Step 5** - Reboot + +After reboot make sure the pool was imported automatically: +```bash +zpool status +``` + +You should now have working system with root on eMMC and ZFS pool on HDD. + diff --git a/mkdocs.yml b/mkdocs.yml index 3a914ce..9717035 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -81,6 +81,9 @@ nav: - SDcard Install : 'helios64/install/sdcard.md' - First Start : 'helios64/install/first-start.md' - Transfer Installed OS: 'helios64/install/transfer.md' + - ZFS on HDD: 'helios64/install/zfs.md' + - Docker with ZFS: 'helios64/install/docker-zfs.md' + - LXD with ZFS: 'helios64/install/lxd-zfs.md' - Recovery : - Recovery Mode: '/helios64/button/#recovery-button' - Maskrom Mode: 'helios64/maskrom.md'