2
2

More than 1 year has passed since last update.

Ubuntu 20.04 で OpenZFS 最新版を導入する

Last updated at Posted at 2021-05-30

※Ubuntu 22.04ではOpenZFS 2.1系が採用されましたので、素直にUbuntu22.04にアップデートすることをお勧めします。

Ubuntu20.04環境で、最新のOpenZFS を使う方法です。
Ubuntu20.04だとディストリ公式では0.8.3の配布のみですので、OpenZFSのgithubからソース取得の上dpkg生成しdkmsでカーネルモジュールインストールする方針とします。

手順のベースは公式ドキュメントの Developer Resources > Custom Packages になります。
https://openzfs.github.io/openzfs-docs/Developer%20Resources/Custom%20Packages.html

本件ナレッジではOpenZFSの導入のみの紹介とし、poolの作成等は紹介しない。
poolの作成についてはこちらの記事がよく纏まっているので参照すると良い。
https://chibiegg.gitbooks.io/how-to-zfs/content/

#前提条件

  • Ubuntu20.04 x86_64
$ uname -a
Linux nas 5.4.0-73-generic #82-Ubuntu SMP Wed Apr 14 17:39:42 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 20.04.2 LTS
Release:	20.04
Codename:	focal

#インストール
本件では現時点での最新安定版 OpenZFS 2.0.4 をインストールする前提になります。
githubのcheckoutを変えることによって、最新の開発masterのままや、2.1.0のRC版もインストール可能です。

# Kernel Headerなど必要なものを入れる
$ sudo apt-get -y  install build-essential autoconf automake libtool gawk alien fakeroot dkms libblkid-dev uuid-dev libudev-dev libssl-dev zlib1g-dev libaio-dev libattr1-dev libelf-dev linux-headers-$(uname -r) python3 python3-dev python3-setuptools python3-cffi libffi-dev python3-packaging git gdebi-core

# OpenZFSをgithubからクローンとクローン先へ移動
$ git clone https://github.com/zfsonlinux/zfs.git && cd zfs

# zfs-2.0.4をチェックアウト(バージョン変えたい場合、gitのtag参照)
$ git checkout zfs-2.0.4

# autogen.sh実行
$ ./autogen.sh

# systemd 環境指定でのconfigure
$ ./configure --enable-systemd

# dpkgとdkms利用のパッケージ作成
$ make -j1 deb-utils deb-dkms

# 生成されたパッケージのインストール
$ for file in *.deb; do sudo gdebi -q --non-interactive $file; done

# ブート時に自動的に起動するようにサービスを有効化
$ sudo systemctl enable zfs.target

# デーモンを手動で起動
$ sudo systemctl start zfs.target

# ZFS プールを再起動時に自動的にマウントするようサービス・ターゲットを有効にする
$ sudo systemctl enable zfs-import-cache
$ sudo systemctl enable zfs-mount
$ sudo systemctl enable zfs-import.target

これでインストールが完了するので、再起動し、プール作成をすれば利用できます。

#インストール後アップデート
最新バージョンがリリースされた場合のアップデート方法を記載しておきます。

# githubからクローンしたディレクトリに移動
$ cd ~/zfs

# make cleanや生成したdpkgやrpmを削除
$ make clean && rm *.deb && rm *.rpm

# git fetchならびに更新されたtagを確認
$ git fetch --tags

# zfs-2.0.4をチェックアウト
# git checkout zfs-2.0.4

# autogen.sh実行
$ ./autogen.sh

# systemd 環境指定でのconfigure
$ ./configure --enable-systemd

# dpkgとdkms利用のパッケージ作成
$ make -j1 deb-utils deb-dkms

# 生成されたパッケージのインストール
$ for file in *.deb; do sudo gdebi -q --non-interactive $file; done

インストール後再起動をし、poolのアップデートが必要か確認します。

$ zpool status

実行結果に
action: Upgrade the pool using 'zpool upgrade'.というのがあれば、アップデートが必要です。

$ zpool status
  pool: pool0
 state: ONLINE
status: The pool is formatted using an older on-disk format.  The pool can
        still be used, but some features are unavailable.
action: Upgrade the pool using 'zpool upgrade'.  Once this is done, the
        pool will no longer be accessible on older software versions.
 scrub: none requested
config:

	NAME        STATE     READ WRITE CKSUM
	pool0       ONLINE       0     0     0
	  raidz2-0  ONLINE       0     0     0
	    zfs0    ONLINE       0     0     0
	    zfs1    ONLINE       0     0     0
	    zfs2    ONLINE       0     0     0
	    zfs3    ONLINE       0     0     0

errors: No known data errors

このような場合は zpool upgrade -a ですべてのプールをアップデートを行いましょう。

$ sudo zpool upgrade -a

#最後に
これでインストールやアップデートができます。

enjoy!

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2