Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
113-Btrfsのスナップショット.pdf
Search
Satoru Takeuchi
PRO
May 25, 2026
23
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
113-Btrfsのスナップショット.pdf
Satoru Takeuchi
PRO
May 25, 2026
More Decks by Satoru Takeuchi
See All by Satoru Takeuchi
Rook: Intro and Deep Dive with Ceph
sat
PRO
1
41
Machine Check Exception
sat
PRO
2
51
バイナリダンプの模様を読む
sat
PRO
0
71
cpコマンドはディスク上でデータを コピーしないことがある
sat
PRO
3
57
114-ファイルのshallow_copy.pdf
sat
PRO
2
41
システム強制終了時にファイルシステムの整合性を保つ~ コピーオンライト編 ~
sat
PRO
0
63
システム強制終了時に ファイルシステムの整合性を保つ ~ ジャーナリング編 ~
sat
PRO
2
68
ファイルシステムの整合性を回復するfsck
sat
PRO
1
74
小学校5,6年生向けキャリア教育 大人になるまでの道
sat
PRO
8
5.7k
Featured
See All Featured
Site-Speed That Sticks
csswizardry
13
1.4k
The Cult of Friendly URLs
andyhume
79
7k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3k
Statistics for Hackers
jakevdp
799
230k
Building Applications with DynamoDB
mza
96
7.2k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
10k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
330
Marketing to machines
jonoalderson
1
5.6k
Chasing Engaging Ingredients in Design
codingconduct
0
260
How to train your dragon (web standard)
notwaldorf
97
6.7k
Transcript
Btrfsのスナップショット May. 25th, 2026 Satoru Takeuchi X: satoru_takeuchi 1
• Btrfsがサポートしているファイルシステムレベルでのスナップショット • CoW(Copy-on-Write)機能を利用して実現 ◦ 📝 過去動画: その112 システム強制終了時にファイルシステムの整合性を保つ ~
コピーオンライト 編 ~ • スナップショットそのものが何かについては過去動画を参照 ◦ 📝 過去動画: その29 スナップショット はなすこと 2
サブボリューム • Btrfsでsnapshotを作成する単位(ここでは/mntにbtrfsをmountしている) • ファイルシステム上はディレクトリに見える 3 # btrfs subvolume create
/mnt/foo # 作成 Create subvolume '/mnt/foo' # ls /mnt # ディレクトリに見える foo # ls /mnt/foo # 中でlsもできる #
snahshot • foo以下に適当にファイルを作る • fooのsnapshot作成 4 # echo bar >/mnt/foo/bar
# echo baz >/mnt/foo/baz # ls /mnt/foo/ bar baz # btrfs subvolume snapshot /mnt/foo /mnt/hoge Create a snapshot of '/mnt/foo' in '/mnt/hoge' # ls /mnt/hoge/ bar baz # cat /mnt/hoge/bar bar # cat /mnt/hoge/baz baz #
snahshot • foo以下に適当にファイルを作る • fooのsnapshot作成 5 # echo bar >/mnt/foo/bar
# echo baz >/mnt/foo/baz # ls /mnt/foo/ bar baz # btrfs subvolume snapshot /mnt/foo /mnt/hoge Create a snapshot of '/mnt/foo' in '/mnt/hoge' # ls /mnt/hoge/ bar baz # cat /mnt/hoge/bar bar # cat /mnt/hoge/baz baz # “cp -r /mnt/foo /mnt/hoge”との違い • foo以下に大量のデータがあっても短 時間(多くはほぼ一瞬)で終わる • 追加容量をほぼ必要としない
btrfsのsnapshot作成が高速な理由を説明 • 初期状態 ◦ サブボリュームfooの下にbar,bazというファイルが存在する ◦ bar,bazはものすごく大きいとする (例: 数TiB) /
foo bazのメタデータ barのメタデータ barのデータ bazのデータ
fooのsnapshotであるhogeを作成すると… • barとbazを参照するhogeを作る • fooとhogeを参照するrootを作る / foo bazのメタデータ barのメタデータ barのデータ
bazのデータ / hoge
最後にrootを差し替え • これで終わり • barとbazには一切触っていないので高速 • 後でbarやbazを更新するときはメタデータ/データをCoWする / foo bazのメタデータ
barのメタデータ barのデータ bazのデータ / hoge
まとめ • Btrfsはbtrfs subvolume createコマンドでsubvolumeを使える • btrfs subvolume snapshotコマンドでsubvolumeのsnapshotを作成できる •
snapshotの利点 ◦ コピーに比べて高速で完了するし容量もほとんど消費しない ◦ readonlyでsnapshotを作成して、そのデータをコピーによりバックアップを作成するといった使い方 ができる ◦ かっこいい • snapshotの注意点(過去動画と一部同じ) ◦ データは冗長化されず、あくまで参照をコピーするだけなので、 snapshotそのものはバックアップに はならない ◦ snapshotを読み書き可能状態で作成すると後から使用量が CoWで予測しづらい形で増える ▪ ファイルの新規作成やファイルサイズの拡張をしていないのに使用量が増える 9