せいさくちゅう
btrfsの本家様 https://btrfs.readthedocs.io/en/latest/ 旧サイト https://btrfs.wiki.kernel.org/index.php/Main_Page
透過的ファイル圧縮やスナップショット機能を有するファイルシステム. zfsみたいにストレージプールから切り出してファイルシステムにすることができる.
LVMでも同様だけどファイルシステム自体で行うことが違いかな. LVMはその上にファイルシステムを作る事になりますからね
ここでは RockyLinux 9 btrfsのボリューム作成、透過的圧縮について記す
CentOS7の場合は追加パッケージで使えてたのですが、RockyLinux9ではパッケージが提供されていないです.
なのでカーネルから調整するとかになる. ここでは ELRepo リポジトリで提供している OS のパッケージを入れて btrfs 対応にしてみたいと思います
[root@rockylinux9 ~]# rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
[root@rockylinux9 ~]# dnf install https://www.elrepo.org/elrepo-release-9.el9.elrepo.noarch.rpm -y
[root@rockylinux9 ~]# dnf --enablerepo=elrepo-kernel install kernel-ml kernel-ml-core kernel-ml-devel kernel-ml-devel-matched kernel-ml-modules kernel-ml-modules-extra kernel-ml-tools kernel-ml-tools-libs kernel-ml-tools-libs-devel -y
[root@rockylinux9 ~]# reboot
これでOSのupdateは完了
次にbtrfsの関連コマンドを入れます. こちらはコンパイルですね.
[root@rockylinux9 ~]# git clone https://github.com/kdave/btrfs-progs
[root@rockylinux9 ~]# dnf --enablerepo=crb,devel install python3-sphinx e2fsprogs-devel libblkid-devel uuid-devel libuuid-devel libgudev-devel python3-devel lzo-devel libaio-devel liburing-devel
[root@rockylinux9 ~]# cd btrfs-progs
[root@rockylinux9 btrfs-progs]# ./autogen.sh
Generate build-system by:
aclocal: aclocal (GNU automake) 1.16.2
autoconf: autoconf (GNU Autoconf) 2.69
autoheader: autoheader (GNU Autoconf) 2.69
automake: automake (GNU automake) 1.16.2
Now type './configure' and 'make' to compile.
[root@rockylinux9 btrfs-progs]#
[root@rockylinux9 btrfs-progs]# ./configure
:
:
btrfs-progs: v6.3.3
libbtrfs: 0.1.2 (deprecated)
libbtrfsutil: 1.2.0
prefix: /usr/local
exec prefix: ${prefix}
bindir: ${exec_prefix}/bin
libdir: ${exec_prefix}/lib
includedir: ${prefix}/include
pkgconfigdir: ${libdir}/pkgconfig
compiler: gcc
CFLAGS: -g -O1 -Wall -D_FORTIFY_SOURCE=2
LDFLAGS:
programs: yes
shared libraries: yes
static libraries: yes
documentation: yes
doc generator: sphinx
backtrace support: yes
btrfs-convert: yes (ext2)
zstd support: yes
lzo support: yes
fsverity support: yes
Python bindings: yes
Python interpreter: /usr/bin/python
crypto provider: builtin
libudev: yes
zoned device: yes
Type 'make' to compile.
[root@rockylinux9 btrfs-progs]# make; make test; make install
可能ならばOSのsystem領域から btrfs にしてみたいが、ここらはディストリビューター側で用意されるか否かになる. RockyLinuxは未対応.
なので追加したストレージデバイスに対して btrfs でフォーマットしてみる
[root@rockylinux9 ~]# cat /etc/redhat-release
Rocky Linux release 9.2 (Blue Onyx)
[root@rockylinux9 ~]# cat /proc/version
Linux version 6.4.12-1.el9.elrepo.x86_64 (mockbuild@be221d28d6974ab8b5832df4118d6097) (gcc (GCC) 11.3.1 20221121 (Red Hat 11.3.1-4), GNU ld version 2.35.2-37.el9) #1 SMP PREEMPT_DYNAMIC Wed Aug 23 13:22:12 EDT 2023
[root@rockylinux9 ~]# cat /proc/partitions
major minor #blocks name
8 0 33554432 sda
8 1 51200 sda1
8 2 2097152 sda2
8 3 31404032 sda3
8 16 33554432 sdb
8 32 67108864 sdc
11 0 9234624 sr0
[root@rockylinux9 ~]#
使うコマンドは mkfs.btrfs です. デバイスのパーティションを切るかどうかですが、分けないのでそのまま使います. ここでは2つの領域(/dev/sdbと/dev/sdc)に対して行います
[root@rockylinux9 ~]# mkfs.btrfs /dev/sdb [root@rockylinux9 ~]# mkfs.btrfs /dev/sdc
btrfs-progs v6.3.3 btrfs-progs v6.3.3
See https://btrfs.readthedocs.io for more information. See https://btrfs.readthedocs.io for more information.
NOTE: several default settings have changed in version 5.15, please make sure NOTE: several default settings have changed in version 5.15, please make sure
this does not affect your deployments: this does not affect your deployments:
- DUP for metadata (-m dup) - DUP for metadata (-m dup)
- enabled no-holes (-O no-holes) - enabled no-holes (-O no-holes)
- enabled free-space-tree (-R free-space-tree) - enabled free-space-tree (-R free-space-tree)
Label: (null) Label: (null)
UUID: 9218bf09-f3a0-4587-8431-e966c147a721 UUID: ed03deed-e484-49ad-a101-352c6bb91583
Node size: 16384 Node size: 16384
Sector size: 4096 Sector size: 4096
Filesystem size: 32.00GiB Filesystem size: 64.00GiB
Block group profiles: Block group profiles:
Data: single 8.00MiB Data: single 8.00MiB
Metadata: DUP 256.00MiB Metadata: DUP 1.00GiB
System: DUP 8.00MiB System: DUP 8.00MiB
SSD detected: yes SSD detected: yes
Zoned device: no Zoned device: no
Incompat features: extref, skinny-metadata, no-holes, free-space-tree Incompat features: extref, skinny-metadata, no-holes, free-space-tree
Runtime features: free-space-tree Runtime features: free-space-tree
Checksum: crc32c Checksum: crc32c
Number of devices: 1 Number of devices: 1
Devices: Devices:
ID SIZE PATH ID SIZE PATH
1 32.00GiB /dev/sdb 1 64.00GiB /dev/sdc
[root@rockylinux9 ~]# [root@rockylinux9 ~]#
ストレージのサイズの違いで、「Metadata」のサイズが異なるようです.
次はmount操作