Ubuntu 20.04LTSにZFSストレージプールを作成する


# 動機
1. 複数HDDをひとまとめにしたい
1. LVMは追加、切り離しの操作が面倒なのでパス

# 検証環境
RaspberryPi3
Ubuntu 20.04 LTS
ZFS追加ストレージ用にUSBメモリ2個

# ZFSインストール

```bash
apt update
apt install zfsutils-linux

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  libnvpair1linux libuutil1linux libzfs2linux libzpool2linux zfs-zed
Suggested packages:
  nfs-kernel-server samba-common-bin zfs-initramfs | zfs-dracut
The following NEW packages will be installed:
  libnvpair1linux libuutil1linux libzfs2linux libzpool2linux zfs-zed zfsutils-linux
0 upgraded, 6 newly installed, 0 to remove and 96 not upgraded.
Need to get 1399 kB of archives.
After this operation, 4876 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://ports.ubuntu.com/ubuntu-ports focal-updates/main arm64 libnvpair1linux arm64 0.8.3-1ubuntu12.13 [47.0 kB]
Get:2 http://ports.ubuntu.com/ubuntu-ports focal-updates/main arm64 libuutil1linux arm64 0.8.3-1ubuntu12.13 [46.5 kB]
Get:3 http://ports.ubuntu.com/ubuntu-ports focal-updates/main arm64 libzfs2linux arm64 0.8.3-1ubuntu12.13 [194 kB]
Get:4 http://ports.ubuntu.com/ubuntu-ports focal-updates/main arm64 libzpool2linux arm64 0.8.3-1ubuntu12.13 [712 kB]
Get:5 http://ports.ubuntu.com/ubuntu-ports focal-updates/main arm64 zfsutils-linux arm64 0.8.3-1ubuntu12.13 [342 kB]
Get:6 http://ports.ubuntu.com/ubuntu-ports focal-updates/main arm64 zfs-zed arm64 0.8.3-1ubuntu12.13 [58.1 kB]
Fetched 1399 kB in 3s (402 kB/s)
Selecting previously unselected package libnvpair1linux.
(Reading database ... 67044 files and directories currently installed.)
Preparing to unpack .../0-libnvpair1linux_0.8.3-1ubuntu12.13_arm64.deb ...
Unpacking libnvpair1linux (0.8.3-1ubuntu12.13) ...
Selecting previously unselected package libuutil1linux.
Preparing to unpack .../1-libuutil1linux_0.8.3-1ubuntu12.13_arm64.deb ...
Unpacking libuutil1linux (0.8.3-1ubuntu12.13) ...
Selecting previously unselected package libzfs2linux.
Preparing to unpack .../2-libzfs2linux_0.8.3-1ubuntu12.13_arm64.deb ...
Unpacking libzfs2linux (0.8.3-1ubuntu12.13) ...
Selecting previously unselected package libzpool2linux.
Preparing to unpack .../3-libzpool2linux_0.8.3-1ubuntu12.13_arm64.deb ...
Unpacking libzpool2linux (0.8.3-1ubuntu12.13) ...
Selecting previously unselected package zfsutils-linux.
Preparing to unpack .../4-zfsutils-linux_0.8.3-1ubuntu12.13_arm64.deb ...
Unpacking zfsutils-linux (0.8.3-1ubuntu12.13) ...
Selecting previously unselected package zfs-zed.
Preparing to unpack .../5-zfs-zed_0.8.3-1ubuntu12.13_arm64.deb ...
Unpacking zfs-zed (0.8.3-1ubuntu12.13) ...
Setting up libuutil1linux (0.8.3-1ubuntu12.13) ...
Setting up libnvpair1linux (0.8.3-1ubuntu12.13) ...
Setting up libzfs2linux (0.8.3-1ubuntu12.13) ...
Setting up libzpool2linux (0.8.3-1ubuntu12.13) ...
Setting up zfsutils-linux (0.8.3-1ubuntu12.13) ...
insmod /lib/modules/5.4.0-1042-raspi/kernel/zfs/spl.ko
insmod /lib/modules/5.4.0-1042-raspi/kernel/zfs/icp.ko
insmod /lib/modules/5.4.0-1042-raspi/kernel/zfs/zavl.ko
insmod /lib/modules/5.4.0-1042-raspi/kernel/zfs/znvpair.ko
insmod /lib/modules/5.4.0-1042-raspi/kernel/zfs/zcommon.ko
insmod /lib/modules/5.4.0-1042-raspi/kernel/zfs/zlua.ko
insmod /lib/modules/5.4.0-1042-raspi/kernel/zfs/zunicode.ko
insmod /lib/modules/5.4.0-1042-raspi/kernel/zfs/zfs.ko
Created symlink /etc/systemd/system/zfs-import.target.wants/zfs-import-cache.service → /lib/systemd/system/zfs-import-cache.service.
Created symlink /etc/systemd/system/zfs.target.wants/zfs-import.target → /lib/systemd/system/zfs-import.target.
Created symlink /etc/systemd/system/zfs-mount.service.wants/zfs-load-module.service → /lib/systemd/system/zfs-load-module.service.
Created symlink /etc/systemd/system/zfs.target.wants/zfs-load-module.service → /lib/systemd/system/zfs-load-module.service.
Created symlink /etc/systemd/system/zfs.target.wants/zfs-mount.service → /lib/systemd/system/zfs-mount.service.
Created symlink /etc/systemd/system/zfs.target.wants/zfs-share.service → /lib/systemd/system/zfs-share.service.
Created symlink /etc/systemd/system/zfs-volumes.target.wants/zfs-volume-wait.service → /lib/systemd/system/zfs-volume-wait.service.
Created symlink /etc/systemd/system/zfs.target.wants/zfs-volumes.target → /lib/systemd/system/zfs-volumes.target.
Created symlink /etc/systemd/system/multi-user.target.wants/zfs.target → /lib/systemd/system/zfs.target.
zfs-import-scan.service is a disabled or a static unit, not starting it.
zfs-import-scan.service is a disabled or a static unit, not starting it.
Setting up zfs-zed (0.8.3-1ubuntu12.13) ...
Created symlink /etc/systemd/system/zed.service → /lib/systemd/system/zfs-zed.service.
Created symlink /etc/systemd/system/zfs.target.wants/zfs-zed.service → /lib/systemd/system/zfs-zed.service.
Processing triggers for systemd (245.4-4ubuntu3.11) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
```

# ストレージプール追加用ディスクの作成

```bash
parted /dev/sda

GNU Parted 3.3
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel
New disk label type? gpt
Warning: The existing disk label on /dev/sda will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? Yes
(parted) mkpart
Partition name?  []? zfs1
File system type?  [ext2]? zfs
Start?
Start? 2048s
End? -1s
Warning: You requested a partition from 1049kB to 15.7GB (sectors 2048..30670847).
The closest location we can manage is 1049kB to 15.7GB (sectors 2048..30670814).
Is this still acceptable to you?
Yes/No? y
(parted) print
Model: Generic STORAGE DEVICE (scsi)
Disk /dev/sda: 15.7GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name  Flags
 1      1049kB  15.7GB  15.7GB  zfs          zfs1

(parted) quit
```

# ストレージプール作成

```bash
zpool create tank /dev/sda1
zpool status
  pool: tank
 state: ONLINE
  scan: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        tank        ONLINE       0     0     0
          sda1      ONLINE       0     0     0

errors: No known data errors
```