Featured image of post ZFS RAIDz expansion 抢先体验

ZFS RAIDz expansion 抢先体验

数据无价,仅供参考,请勿模仿

编译安装 OpenZFS 2.3.0

当前 openzfs 2.3.0 仍然没有正式发布,最新版本为 2.3.0-rc3,所以需要自己编译,整个过程比较简单:

先安装一个比较新的内核(我的 NAS 上的 Debian 内核版本是 6.1.0):

1
apt install linux-image-6.9.7+bpo-amd64 linux-headers-6.9.7+bpo-amd64

完成后按照 zfs 的官方文档中相关步骤编译即可:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
apt install alien autoconf automake build-essential debhelper-compat dh-autoreconf dh-dkms dh-python dkms fakeroot gawk git libaio-dev libattr1-dev libblkid-dev libcurl4-openssl-dev libelf-dev libffi-dev libpam0g-dev libssl-dev libtirpc-dev libtool libudev-dev parallel po-debconf python3 python3-all-dev python3-cffi python3-dev python3-packaging python3-setuptools python3-sphinx uuid-dev zliblg-dev
git clone https://github.com/openzfs/zfs
cd ./zfs
git checkout zfs-2.3.0-rc3
sh autogen.sh
./configure
make -s -j$(nproc) native-deb-utils
cd ..
rm openzfs-zfs-dracut_*.deb openzfs-zfs-initramfs_2.3.0-1_all.deb
sudo dpkg -i ./openzfs-zfs-zed_2.3.0-1_amd64.deb ./openzfs-zfs-dkms_2.3.0-1_all.deb ./openzfs-libuutil3_2.3.0-1_amd64.deb ./openzfs-libzfs6_2.3.0-1_amd64.deb ./openzfs-libnvpair3_2.3.0-1_amd64.deb ./openzfs-zfsutils_2.3.0-1_amd64.deb

上面执行都顺利完成后,直接重启即可。重启完成后可能需要手动执行 zpool import -a 重新导入一下。

升级需要使用 raidz expansion 的 zpool

这一步非常简单,假设需要升级的 zpool 叫 sata-critical,一个命令即可:

1
zpool upgrade sata-critical

给 zpool 增加磁盘

这一步也非常简单:

1
zpool attach sata-critical raidz2-0 /dev/disk/by-id/ata-HGST_HUS726XXXXXXXXX_XXXXXXXX

之后就可以用 zpool status 查看进度了:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
$ zpool status sata-critical
  pool: sata-critical
 state: ONLINE
  scan: scrub repaired 0B in 05:19:56 with 0 errors on Sun Nov 17 10:31:03 2024
expand: expansion of raidz2-0 in progress since Sun Nov 17 18:48:14 2024
	1.48T / 17.9T copied at 171M/s, 8.30% done, 1 days 03:56:00 to go
config:

	NAME                                   STATE    READ WRITE CKSUM
	sata-critical                         ONLINE       0     0     0
	 raidz2-0                             ONLINE       0     0     0
	   ata-HGST_HUS726XXXXXXXXX_XXXXXXXX  ONLINE       0     0     0
	   ata-HGST_HUS726XXXXXXXXX_XXXXXXXX  ONLINE       0     0     0
	   ata-HGST_HUS726XXXXXXXXX_XXXXXXXX  ONLINE       0     0     0
	   ata-HGST_HUS726XXXXXXXXX_XXXXXXXX  ONLINE       0     0     0
	   ata-HGST_HUS726XXXXXXXXX_XXXXXXXX  ONLINE       0     0     0

errors: No known data errors

Expansion 的一些小缺点

假设使用五块新的 6TB 磁盘组建 RAIDz2 的 zpool,理论上可用空间应该是 15.643519GB(计算参考),但是升级完成后实际可用空间只有 13.08TB,具体结果如下:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
$ zfs list sata-critical 
NAME            USED  AVAIL  REFER  MOUNTPOINT
sata-critical  8.66T  4.42T  8.66T  /sata-critical
$ zpool list sata-critical -v
NAME                                    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT
sata-critical                          27.3T  17.9T  9.39T        -         -     2%    65%  1.00x    ONLINE  -
  raidz2-0                             27.3T  17.9T  9.39T        -         -     2%  65.6%      -    ONLINE
    ata-HGST_HUS726XXXXXXXXX_XXXXXXXX  5.46T      -      -        -         -      -      -      -    ONLINE
    ata-HGST_HUS726XXXXXXXXX_XXXXXXXX  5.46T      -      -        -         -      -      -      -    ONLINE
    ata-HGST_HUS726XXXXXXXXX_XXXXXXXX  5.46T      -      -        -         -      -      -      -    ONLINE
    ata-HGST_HUS726XXXXXXXXX_XXXXXXXX  5.46T      -      -        -         -      -      -      -    ONLINE
    ata-HGST_HUS726XXXXXXXXX_XXXXXXXX  5.46T      -      -        -         -      -      -      -    ONLINE

稍微查了一下原因应该是和 RAIDz expansion 的实现方式有关,具体可以查看这篇文章:ZFS RAIDZ Expansion Is Awesome but Has a Small Caveat

comments powered by Disqus
Except where otherwise noted, content on this blog is licensed under CC-BY 2.0.
Built with Hugo
主题 StackJimmy 设计