Prev / Next

2010-04-28 / btrfs を試す

btrfs を触ってみたのでメモ.

環境は
- Momonga Linux trunk
- kernel 2.6.32
- btrfs-progs 0.19


ちょっと試すだけなので,file を loopback でマウント.

$ dd if=/dev/zero of=btrfs.img count=2097152
2097152+0 records in
2097152+0 records out
1073741824 bytes (1.1 GB) copied, 23.6347 s, 45.4 MB/s

$ mkfs.btrfs btrfs.img

WARNING! - Btrfs Btrfs v0.19 IS EXPERIMENTAL
WARNING! - see http://btrfs.wiki.kernel.org before using

fs created label (null) on btrfs.img
        nodesize 4096 leafsize 4096 sectorsize 4096 size 1.00GB
Btrfs Btrfs v0.19
$ sudo mount -t btrfs -o loop btrfs.img /mnt/btrfs




Subvolume

/ ではなく,ある特定の path を起点としてマウントする機能.

Subvolume としてマウントできる場所を設定

$ sudo btrfsctl -S test_volume /mnt/btrfs
operation complete
Btrfs Btrfs v0.19
$ sudo ls /mnt/btrfs
test_volume                  # test_volume が作られる


Subvolume (test_volume) をマウント.

$ sudo mount -t btrfs -o subvol=test_volume /dev/loop0 /mnt/btrfs_subvol


bind mount と変わらないように見えてしまうけど,
/mnt/btrfs へ btrfs.img をマウントしていなくても,
Subvolume で btrfs.img 内の特定の path を mount できる.
# ちょっと用途が思いつかないけど

Subvolume の削除

# btrfsctl -D test_volume /mnt/btrfs


手元の環境だと "-D" オプションがない.

ディレクトリとして見えているので,rm でも消せそうだけど,
メタ情報が残る?



snapshot

snapshot の作成

# btrfsctl -s /mnt/btrfs/snapshot /mnt/btrfs
operation complete
Btrfs Btrfs v0.19


/mnt/btrfs 以下の snapshot を /mnt/btrfs/snapshot に作成

snapshot の mount

snapshot は Subvolume として mount できる.

# mount -t btrfs -o subvol=snapshot /dev/loop0 /mnt/snapshot
[src]

snapshot の削除
[src]
# btrfsctl -D snapshot /mnt/btrfs




ファイルシステムのリサイズ

初期状態

$ df -h /dev/loop0
Filesystem            Size  Used Avail Use% マウント位置
/dev/loop0            1.0G   44K  1.0G   1% /mnt/btrfs


100M 減らす

$ sudo btrfsctl -r -100m /mnt/btrfs
operation complete
Btrfs Btrfs v0.19
$ df -h /dev/loop0
Filesystem            Size  Used Avail Use% マウント位置
/dev/loop0            924M   44K  924M   1% /mnt/btrfs


10M 増やす

$ sudo btrfsctl -r +10m /mnt/btrfs
operation complete
Btrfs Btrfs v0.19
$ df -h /dev/loop0
Filesystem            Size  Used Avail Use% マウント位置
/dev/loop0            934M   44K  934M   1% /mnt/btrfs


1G にする

$ sudo btrfsctl -r 1g /mnt/btrfs
operation complete
Btrfs Btrfs v0.19
$ df -h /dev/loop0
Filesystem            Size  Used Avail Use% マウント位置
/dev/loop0            1.0G   44K  1.0G   1% /mnt/btrfs




memo

btrfs-convert
ext2 から btrfs へ変換

btrfs-image
圧縮した image を作成.データは 0 で埋められ,メタデータは保持.

複数 device の扱いについては次([2010-04-28-2])で.



- https://btrfs.wiki.kernel.org/index.php/Main_Page
- https://btrfs.wiki.kernel.org/index.php/Getting_started

Referrer (Inside):
[2010-04-28-2] btrfs を試す 2 - Multiple Devices
comments powered by Disqus