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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Satoru Takeuchi
PRO
May 25, 2026
28
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
あなたの知らないバージョン命名規則
sat
PRO
2
130
Rook: Intro and Deep Dive with Ceph
sat
PRO
1
59
Machine Check Exception
sat
PRO
2
54
バイナリダンプの模様を読む
sat
PRO
0
76
cpコマンドはディスク上でデータを コピーしないことがある
sat
PRO
3
64
114-ファイルのshallow_copy.pdf
sat
PRO
2
45
システム強制終了時にファイルシステムの整合性を保つ~ コピーオンライト編 ~
sat
PRO
0
66
システム強制終了時に ファイルシステムの整合性を保つ ~ ジャーナリング編 ~
sat
PRO
2
73
ファイルシステムの整合性を回復するfsck
sat
PRO
1
78
Featured
See All Featured
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3k
Faster Mobile Websites
deanohume
310
32k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
232
55k
Chasing Engaging Ingredients in Design
codingconduct
0
280
Un-Boring Meetings
codingconduct
0
390
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
490
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
Rails Girls Zürich Keynote
gr2m
96
14k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.5k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
220
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
4.4k
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