btrfs をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
&color(red){せいさくちゅう};
btrfsの本家様 [[https://btrfs.readthedocs.io/en/latest/>+...
透過的ファイル圧縮やスナップショット機能を有するファイル...
&size(10){LVMでも同様だけどファイルシステム自体で行うこと...
ここでは &color(orangered){''RockyLinux 9''}; btrfsのボリ...
***RockyLinuxで btrfs [#n4d585b3]
CentOS7の場合は追加パッケージで使えてたのですが、RockyLin...
なのでカーネルから調整するとかになる. ここでは ELRepo リ...
#code(nonumber){{
[root@rockylinux9 ~]# rpm --import https://www.elrepo.org...
[root@rockylinux9 ~]# dnf install https://www.elrepo.org/...
[root@rockylinux9 ~]# dnf --enablerepo=elrepo-kernel inst...
[root@rockylinux9 ~]# reboot
}}
これでOSのupdateは完了
次にbtrfsの関連コマンドを入れます. こちらはコンパイルです...
#code(nonumber){{
[root@rockylinux9 ~]# git clone https://github.com/kdave/...
[root@rockylinux9 ~]# dnf --enablerepo=crb,devel install ...
[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.5.2
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_SOURC...
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 ins...
}}
***mkfs.btrfs [#te10eee2]
可能ならばOSのsystem領域から btrfs にしてみたいが、ここら...
なので追加したストレージデバイスに対して btrfs でフォーマ...
#code(nonumber){{
[root@rockylinux9 ~]# cat /etc/redhat-release
Rocky Linux release 9.2 (Blue Onyx)
[root@rockylinux9 ~]# cat /proc/version
Linux version 6.5.5-1.el9.elrepo.x86_64 (mockbuild@391cbd...
[root@rockylinux9 ~]# cat /proc/partitions
major minor #blocks name
8 0 167772160 sda
8 1 51200 sda1
8 2 2097152 sda2
8 3 524288 sda3
8 4 165097472 sda4
8 16 33554432 sdb
8 32 67108864 sdc
11 0 9234624 sr0
[root@rockylinux9 ~]#
}}
使うコマンドは mkfs.btrfs です. デバイスのパーティション...
#code(nonumber){{
[root@rockylinux9 ~]# mkfs.btrfs /dev/sdb ...
btrfs-progs v6.5.2 ...
See https://btrfs.readthedocs.io for more information. ...
...
NOTE: several default settings have changed in version 5....
this does not affect your deployments: ...
- DUP for metadata (-m dup) ...
- enabled no-holes (-O no-holes) ...
- enabled free-space-tree (-R free-space-tree) ...
...
Label: (null) ...
UUID: cc0a221b-f8bf-4b28-83dc-bc4d150744f3 ...
Node size: 16384 ...
Sector size: 4096 ...
Filesystem size: 64.00GiB ...
Block group profiles: ...
Data: single 8.00MiB ...
Metadata: DUP 1.00GiB ...
System: DUP 8.00MiB ...
SSD detected: yes ...
Zoned device: no ...
Incompat features: extref, skinny-metadata, no-holes, fr...
Runtime features: free-space-tree ...
Checksum: crc32c ...
Number of devices: 1 ...
Devices: ...
ID SIZE PATH ...
1 64.00GiB /dev/sdb ...
...
[root@rockylinux9 ~]# ...
}}
&size(10){UUIDは「btrfs filesystem show /dev/sdb」とかで...
ストレージのサイズの違いで、「Metadata」のサイズが異なる...
***LABEL [#m5a0690c]
ext4なら e2label、xfsなら xfs_admin で設けられるが、btrfs...
#code(nonumber){{
[root@rockylinux9 ~]# btrfs filesystem label /dev/sdb cryo
[root@rockylinux9 ~]# btrfs filesystem show
Label: 'cryo' uuid: cc0a221b-f8bf-4b28-83dc-bc4d150744f3
Total devices 1 FS bytes used 144.00KiB
devid 1 size 64.00GiB used 2.02GiB path /dev/sdb
Label: none uuid: 76136264-670c-45da-a597-3cb6bcdd7286
Total devices 1 FS bytes used 144.00KiB
devid 1 size 32.00GiB used 536.00MiB path /dev...
[root@rockylinux9 ~]#
}}
***mount [#l77244be]
mkfs.btrfsでフォーマットしたHDDをシステムにマウントします。
透過的圧縮を使うなら「-o compress=」を使います. 圧縮アル...
参照先: [[https://btrfs.readthedocs.io/en/latest/Compress...
#code(nonumber){{
[root@rockylinux9 ~]# mkdir /cryo
[root@rockylinux9 ~]# mount -t btrfs -o compress=zstd:3 /...
(あるいは)
[root@rockylinux9 ~]# mount -t btrfs -o compress=zstd:3 L...
[root@rockylinux9 ~]# mount |grep "/dev/sdb"
/dev/sdb on /cryo type btrfs (rw,relatime,seclabel,compre...
[root@rockylinux9 ~]#
}}
***サブボリューム [#o04bdf78]
後述のスナップショットを作成する際に便利かな
/cryoの中に raw と progress のディレクトリを生やします. ...
#code(nonumber){{
[root@rockylinux9 ~]# btrfs subvolume create /cryo/raw
Create subvolume '/cryo/raw'
[root@rockylinux9 ~]# btrfs subvolume create /cryo/progress
Create subvolume '/cryo/progress'
[root@rockylinux9 ~]# df -t btrfs
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sdb 33554432 5952 33012736 1% /cryo
[root@rockylinux9 ~]# ls -l /cryo/
total 0
drwxr-xr-x. 1 root root 0 Oct 5 10:18 progress
drwxr-xr-x. 1 root root 0 Oct 5 10:18 raw
[root@rockylinux9 ~]# btrfs subvolume list /cryo -t
ID gen top level path
-- --- --------- ----
257 17 5 raw
258 17 5 progress
[root@rockylinux9 ~]#
}}
削除はdeleteを交えて行う. 削除対象のsubvolumeにデータが...
#code(nonumber){{
[root@rockylinux9 ~]# btrfs subvolume create /cryo/sample
Create subvolume '/cryo/sample'
[root@rockylinux9 ~]# btrfs subvolume delete /cryo/sample
Delete subvolume (no-commit): '/cryo/sample'
[root@rockylinux9 ~]#
}}
***スナップショット [#kb731030]
前段のサブボリュームは単にmkdirでフォルダを作っているよう...
#code(nonumber){{
[root@rockylinux9 ~]# echo abc > /cryo/progress/proteinA
[root@rockylinux9 ~]# btrfs subvolume snapshot /cryo/prog...
Create a snapshot of '/cryo/progress' in '/cryo/progress/...
[root@rockylinux9 ~]#
[root@rockylinux9 ~]# echo def >> /cryo/progress/proteinA
}}
そうしてproteinAの中身をチェック
#code(nonumber){{
[root@rockylinux9 ~]# cat /cryo/progress/proteinA
abc
def
[root@rockylinux9 ~]#
[root@rockylinux9 ~]# cat /cryo/progress/@GMT-2023.10.05-...
abc
[root@rockylinux9 ~]#
}}
スナップショットの削除
#code(nonumber){{
[root@rockylinux9 ~]# btrfs subvolume delete /cryo/progre...
Delete subvolume (no-commit): '/cryo/progress/@GMT-2023.1...
[root@rockylinux9 ~]#
}}
このスナップショットとsambaのshadow_copy機能を組み合わせ...
終了行:
&color(red){せいさくちゅう};
btrfsの本家様 [[https://btrfs.readthedocs.io/en/latest/>+...
透過的ファイル圧縮やスナップショット機能を有するファイル...
&size(10){LVMでも同様だけどファイルシステム自体で行うこと...
ここでは &color(orangered){''RockyLinux 9''}; btrfsのボリ...
***RockyLinuxで btrfs [#n4d585b3]
CentOS7の場合は追加パッケージで使えてたのですが、RockyLin...
なのでカーネルから調整するとかになる. ここでは ELRepo リ...
#code(nonumber){{
[root@rockylinux9 ~]# rpm --import https://www.elrepo.org...
[root@rockylinux9 ~]# dnf install https://www.elrepo.org/...
[root@rockylinux9 ~]# dnf --enablerepo=elrepo-kernel inst...
[root@rockylinux9 ~]# reboot
}}
これでOSのupdateは完了
次にbtrfsの関連コマンドを入れます. こちらはコンパイルです...
#code(nonumber){{
[root@rockylinux9 ~]# git clone https://github.com/kdave/...
[root@rockylinux9 ~]# dnf --enablerepo=crb,devel install ...
[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.5.2
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_SOURC...
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 ins...
}}
***mkfs.btrfs [#te10eee2]
可能ならばOSのsystem領域から btrfs にしてみたいが、ここら...
なので追加したストレージデバイスに対して btrfs でフォーマ...
#code(nonumber){{
[root@rockylinux9 ~]# cat /etc/redhat-release
Rocky Linux release 9.2 (Blue Onyx)
[root@rockylinux9 ~]# cat /proc/version
Linux version 6.5.5-1.el9.elrepo.x86_64 (mockbuild@391cbd...
[root@rockylinux9 ~]# cat /proc/partitions
major minor #blocks name
8 0 167772160 sda
8 1 51200 sda1
8 2 2097152 sda2
8 3 524288 sda3
8 4 165097472 sda4
8 16 33554432 sdb
8 32 67108864 sdc
11 0 9234624 sr0
[root@rockylinux9 ~]#
}}
使うコマンドは mkfs.btrfs です. デバイスのパーティション...
#code(nonumber){{
[root@rockylinux9 ~]# mkfs.btrfs /dev/sdb ...
btrfs-progs v6.5.2 ...
See https://btrfs.readthedocs.io for more information. ...
...
NOTE: several default settings have changed in version 5....
this does not affect your deployments: ...
- DUP for metadata (-m dup) ...
- enabled no-holes (-O no-holes) ...
- enabled free-space-tree (-R free-space-tree) ...
...
Label: (null) ...
UUID: cc0a221b-f8bf-4b28-83dc-bc4d150744f3 ...
Node size: 16384 ...
Sector size: 4096 ...
Filesystem size: 64.00GiB ...
Block group profiles: ...
Data: single 8.00MiB ...
Metadata: DUP 1.00GiB ...
System: DUP 8.00MiB ...
SSD detected: yes ...
Zoned device: no ...
Incompat features: extref, skinny-metadata, no-holes, fr...
Runtime features: free-space-tree ...
Checksum: crc32c ...
Number of devices: 1 ...
Devices: ...
ID SIZE PATH ...
1 64.00GiB /dev/sdb ...
...
[root@rockylinux9 ~]# ...
}}
&size(10){UUIDは「btrfs filesystem show /dev/sdb」とかで...
ストレージのサイズの違いで、「Metadata」のサイズが異なる...
***LABEL [#m5a0690c]
ext4なら e2label、xfsなら xfs_admin で設けられるが、btrfs...
#code(nonumber){{
[root@rockylinux9 ~]# btrfs filesystem label /dev/sdb cryo
[root@rockylinux9 ~]# btrfs filesystem show
Label: 'cryo' uuid: cc0a221b-f8bf-4b28-83dc-bc4d150744f3
Total devices 1 FS bytes used 144.00KiB
devid 1 size 64.00GiB used 2.02GiB path /dev/sdb
Label: none uuid: 76136264-670c-45da-a597-3cb6bcdd7286
Total devices 1 FS bytes used 144.00KiB
devid 1 size 32.00GiB used 536.00MiB path /dev...
[root@rockylinux9 ~]#
}}
***mount [#l77244be]
mkfs.btrfsでフォーマットしたHDDをシステムにマウントします。
透過的圧縮を使うなら「-o compress=」を使います. 圧縮アル...
参照先: [[https://btrfs.readthedocs.io/en/latest/Compress...
#code(nonumber){{
[root@rockylinux9 ~]# mkdir /cryo
[root@rockylinux9 ~]# mount -t btrfs -o compress=zstd:3 /...
(あるいは)
[root@rockylinux9 ~]# mount -t btrfs -o compress=zstd:3 L...
[root@rockylinux9 ~]# mount |grep "/dev/sdb"
/dev/sdb on /cryo type btrfs (rw,relatime,seclabel,compre...
[root@rockylinux9 ~]#
}}
***サブボリューム [#o04bdf78]
後述のスナップショットを作成する際に便利かな
/cryoの中に raw と progress のディレクトリを生やします. ...
#code(nonumber){{
[root@rockylinux9 ~]# btrfs subvolume create /cryo/raw
Create subvolume '/cryo/raw'
[root@rockylinux9 ~]# btrfs subvolume create /cryo/progress
Create subvolume '/cryo/progress'
[root@rockylinux9 ~]# df -t btrfs
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sdb 33554432 5952 33012736 1% /cryo
[root@rockylinux9 ~]# ls -l /cryo/
total 0
drwxr-xr-x. 1 root root 0 Oct 5 10:18 progress
drwxr-xr-x. 1 root root 0 Oct 5 10:18 raw
[root@rockylinux9 ~]# btrfs subvolume list /cryo -t
ID gen top level path
-- --- --------- ----
257 17 5 raw
258 17 5 progress
[root@rockylinux9 ~]#
}}
削除はdeleteを交えて行う. 削除対象のsubvolumeにデータが...
#code(nonumber){{
[root@rockylinux9 ~]# btrfs subvolume create /cryo/sample
Create subvolume '/cryo/sample'
[root@rockylinux9 ~]# btrfs subvolume delete /cryo/sample
Delete subvolume (no-commit): '/cryo/sample'
[root@rockylinux9 ~]#
}}
***スナップショット [#kb731030]
前段のサブボリュームは単にmkdirでフォルダを作っているよう...
#code(nonumber){{
[root@rockylinux9 ~]# echo abc > /cryo/progress/proteinA
[root@rockylinux9 ~]# btrfs subvolume snapshot /cryo/prog...
Create a snapshot of '/cryo/progress' in '/cryo/progress/...
[root@rockylinux9 ~]#
[root@rockylinux9 ~]# echo def >> /cryo/progress/proteinA
}}
そうしてproteinAの中身をチェック
#code(nonumber){{
[root@rockylinux9 ~]# cat /cryo/progress/proteinA
abc
def
[root@rockylinux9 ~]#
[root@rockylinux9 ~]# cat /cryo/progress/@GMT-2023.10.05-...
abc
[root@rockylinux9 ~]#
}}
スナップショットの削除
#code(nonumber){{
[root@rockylinux9 ~]# btrfs subvolume delete /cryo/progre...
Delete subvolume (no-commit): '/cryo/progress/@GMT-2023.1...
[root@rockylinux9 ~]#
}}
このスナップショットとsambaのshadow_copy機能を組み合わせ...
ページ名:
1