45
Btrfs and Snapper The Next Steps From Pure Filesystem Features to Management Integration and Compliance SUSECon 2013, Orlando, Florida Gábor Nyers Sr. System Engineer @SUSE [email protected] Arvin Schnell Sr. Software Developer [email protected]

Btrfs and Snapper - The Next Steps from Pure Filesystem Features to Integration and Compliance

Embed Size (px)

DESCRIPTION

These are the slides of our SUSECon 2013 presentation with Arvin (the inventor of Snapper) Btrfs as technology has been getting a lot of attention over the past few years. While interesting for its feature set alone, like checksums, copy on write, snapshots and built-in device management, without proper management tooling and integration with other parts of the operating system, it is difficult for the average user to use Btrfs to its full potential. This session will help you understand the features of Btrfs and how Snapper can be used for snapshot management in SUSE Linux Enterprise. We also will provide use cases and an outlook for future functionality.

Citation preview

Page 1: Btrfs and Snapper - The Next Steps from Pure Filesystem Features to Integration and Compliance

Btrfs and SnapperThe Next Steps From Pure FilesystemFeatures to Management Integration and Compliance

SUSECon 2013, Orlando, Florida

Gábor NyersSr. System Engineer @SUSE

[email protected]

Arvin SchnellSr. Software Developer

[email protected]

Page 2: Btrfs and Snapper - The Next Steps from Pure Filesystem Features to Integration and Compliance

2

Abstract

Btrfs as technology has been getting a lot of attention over the past few years. While interesting for its feature set alone, like checksums, copy on write, snapshots and built-in device management, without proper management tooling and integration with other parts of the operating system, it is difficult for the average user to use Btrfs to its full potential.

This session will help you understand the features of Btrfs and how Snapper can be used for snapshot management in SUSE Linux Enterprise. We also will provide an outlook for future functionality.

Page 3: Btrfs and Snapper - The Next Steps from Pure Filesystem Features to Integration and Compliance

3

Introduction to Btrfs

Agenda

Btrfs in SUSE distro's Snapper

Summary and Questions

• Btrfs specs

• Features and Concepts

• Current limitations

• Support from distributions

• Demo1: Convert and ResizeBtrfs Use cases

Page 4: Btrfs and Snapper - The Next Steps from Pure Filesystem Features to Integration and Compliance

4

Prelude: Growth of storage

Can traditional filesystems keep up with this growth?

Page 5: Btrfs and Snapper - The Next Steps from Pure Filesystem Features to Integration and Compliance

5

What People Say About Btrfs...

Chris Mason (lead developer Btrfs)‒ General purpose filesystem that scales to very large storage

‒ Focused on features that no other Linux filesystems have

‒ Easy administration and fault tolerant operation

Ted Tso (lead developer Ext4)‒ (Btrfs is) “... the way forward”

Others:‒ “Next generation Linux filesystem”

‒ “Btrfs is the Linux answer to ZFS”

Page 6: Btrfs and Snapper - The Next Steps from Pure Filesystem Features to Integration and Compliance

6

Why Another Linux filesystem?

• Solve Storage Challenges‒ Scalability

‒ Data Integrity

‒ Dynamic Resources (expand and shrink)

‒ Storage Management

‒ Server, Cloud – Desktop, Mobile

• Compete with and exceed the filesystem capabilities of other Operating Systems

Page 7: Btrfs and Snapper - The Next Steps from Pure Filesystem Features to Integration and Compliance

7

Btrfs Specs

• Max volume size : 16 EB (2^64 byte)

• Max file size : 16 EB

• Max file name size : 255 bytes

• Characters in file name : any, except 0x00

• Directory lookup algorithm : B-Tree

• Filesystem check : on- and off-line

• Compatibility‒ POSIX file owner/permission Hard- and symbolic links,

Access Control Lists (ACLs) Extended Attributes (xattrs), Asynchronous and Direct I/O Sparse files

Page 8: Btrfs and Snapper - The Next Steps from Pure Filesystem Features to Integration and Compliance

8

Btrfs Feature Summary 1/2

• Copy-on-write‒ Never overwrite data!

• Snapshots‒ Light weight

‒ At file system level

‒ RO / RW

• In-place conversion from Ext[234] to Btrfs

• Multi-device Management‒ mixed size and speed

‒ on-line add and remove of devices

• Object level RAID:‒ 0, 1, 10

• SSD support (optimizations, trim)

Page 9: Btrfs and Snapper - The Next Steps from Pure Filesystem Features to Integration and Compliance

9

Btrfs Feature Summary 2/2

• Checksums on data and meta data

• On-line filesystem management:‒ Balancing

‒ Grow and shrink(!)

‒ Scrub

‒ Defragmentation

• Transparent compression (gzip, lzo)

• Quota groups

• Send/Receive‒ Similar to ZFS' send/receive

function

• Seed devices‒ Overlay a RW file system

on top of an RO

• Data de-duplication:‒ Background de-dup

process (see also bedup)

Page 10: Btrfs and Snapper - The Next Steps from Pure Filesystem Features to Integration and Compliance

10

Supported Btrfs features in SLES 11 SP3

Supported‒ Snapshots

‒ Copy-on-Write

‒ Subvolumes

‒ Metadata Integrity

‒ Data Integrity

‒ Online scrubbing

‒ Manual defrag

‒ Multiple devices (using MD or LVM)

Unsupported‒ Auto Defrag

‒ Btrfs Built-in RAID

‒ Compression

‒ Send / Receive

‒ Hot add / remove disks

‒ Seeding devices

Page 11: Btrfs and Snapper - The Next Steps from Pure Filesystem Features to Integration and Compliance

11

Btrfs Planned Features

• Object-level RAID 5, 6

• Data de-duplication:‒ On-line de-dup during

writes

• Tiered storage‒ Frequently used “hot” data

on SDD(s)

‒ “Archive” on HDD(s)

ToDo:

Page 12: Btrfs and Snapper - The Next Steps from Pure Filesystem Features to Integration and Compliance

12

Demo: Btrfs Convert and Resize

• Convert existing Ext3 to Btrfs

• On-line re-size of Btrfs‒ Grow

‒ Shrink

Page 13: Btrfs and Snapper - The Next Steps from Pure Filesystem Features to Integration and Compliance

13

Btrfs Concepts

• Extents and Chunks

• B-Tree

• Subvolume

• Snapshot

Page 14: Btrfs and Snapper - The Next Steps from Pure Filesystem Features to Integration and Compliance

14

Btrfs Concepts:

Extents and Storage OrganizationB

lock

laye

rE

xten

ts

Blo

cks

HW

sdbmd0sda

sdc sdd

Chu

nks

M M D D D

# btrfs filesystem df /Data: total=14.50GB, used=12.20GBSystem, DUP: total=8.00MB, used=12.00KBSystem: total=4.00MB, used=0.00Metadata, DUP: total=1.75GB, used=904.11MB

# df -h /Filesystem Size Used Avail Use% Mounted on/dev/sda7 20G 14G 4.3G 77% /#

Disk utilization12,2GB + 2x 0,9GB + = 14 GB

512 byte

4 Kbyte

1 GB

Default sizes

Raw dataMetadata

Page 15: Btrfs and Snapper - The Next Steps from Pure Filesystem Features to Integration and Compliance

15

Btrfs Concepts:

Subvolumes

Subvolume(s)...:

… appear to be a directory

… start as an independent but empty root node

… are independently mountable

… are independently snapshotable

… are “equals” amongst each other, but there is a designated “default subvolume”

Subvol(B-Tree)

/

Subvol(B-Tree)

/home

/var/log

Subvolume Root node

SubvolumeRoot node

DefaultSubvolumeRoot node

Page 16: Btrfs and Snapper - The Next Steps from Pure Filesystem Features to Integration and Compliance

16

Btrfs Concepts:

Snapshots

Snapshot(s)...:

… are an independent clone of the state of a subvolume

… share all raw data with its ancestor after creation

… may be (practically) unlimited in number

… are either RO or RW

… may be “nested”, that is“snapshot of a snapshot”

Subvol(B-Tree)

/

/home

CloneB-Tree

CloneB-Tree

Page 17: Btrfs and Snapper - The Next Steps from Pure Filesystem Features to Integration and Compliance

17

Btrfs Features:

Current(*) limitations – real or perceived

• Full featured off-line fsck tool, however:‒ Implementation of

off-line fsck already available

‒ On-line repair options with btrfs scrub

‒ extended repair function with 'recovery' mount option

‒ `btrfs restore` tool

• Limited bootloader support (GRUB2 only)

• RAID 5 and 6 (patch available)

• Quality of technical documentation could be better

(*) as of Oct 2013

Page 18: Btrfs and Snapper - The Next Steps from Pure Filesystem Features to Integration and Compliance

18

Btrfs Support Status – Distros

Support

• SUSE® Linux Enterprise Server 11 SP2+

• OpenSUSE 11.4+

• Oracle Linux 6 with UEK2+

• Debian 6+

• Ubuntu 11.04+

Technology Preview / unsupported

• Red Hat Enterprise Linux

• Fedora

• and others...

Page 19: Btrfs and Snapper - The Next Steps from Pure Filesystem Features to Integration and Compliance

19

Agenda

Introduction to Btrfs

Btrfs in SUSE distro's Snapper

Summary and Questions

• Btrfs integration in SLES and openSUSE

• Partitioner

• Planned features

• Filesystem recommendations

• DemosBtrfs Use cases

Page 20: Btrfs and Snapper - The Next Steps from Pure Filesystem Features to Integration and Compliance

20

Btrfs integration in SLE 11 SP3 and openSUSE 12.3 – 13.1

• Installer‒ Btrfs as root file system

‒ Recommendation for subvolume layout

‒ Btrfs support in AutoYaST

• Partitioner‒ Create Btrfs

‒ Create subvolumes

• Snapper‒ Manage snapshots

‒ Automatically create snapshots

‒ Display differences between snapshots

‒ Roll-back

Page 21: Btrfs and Snapper - The Next Steps from Pure Filesystem Features to Integration and Compliance

21

Btrfs integration in YaST Partitioner

Page 22: Btrfs and Snapper - The Next Steps from Pure Filesystem Features to Integration and Compliance

22

A Few Recommendations 1/3

Purpose driven filesystem choices, ie: what filesystems to choose for what use case?

Please see session TT1376

Matthias Eckermann (SUSE Product Management)

Jeff Mahoney (SUSE Kernel Team)

Page 23: Btrfs and Snapper - The Next Steps from Pure Filesystem Features to Integration and Compliance

23

A Few Recommendations 2/3

Free disk space:‒ Starting: ~30% filling

‒ Operation: <90% filling

Subvolumes layout‒ Directories containing logs

to avoid log roll-back

‒ Directories w/ high volume write I/O, like:

/tmp, /srv, /var/spool, /var/log, /var/run, /var/tmp, /opt:

should be on their own subvolumes, or a non-Btrfs filesystem; Especially on rotating disks!

Page 24: Btrfs and Snapper - The Next Steps from Pure Filesystem Features to Integration and Compliance

24

A Few Recommendations 3/3A proposed filesystem maintenance plan

• Preparations‒ Get a baseline on “Hot

zones” for a period of ca. 1 week – 1 month

• Daily maintenance‒ Monitor free space

‒ Monitor performance impact of “Hot zones”

‒ Scheduled Scrub

• Weekly maintenance‒ if Btrfs on / Manual defrag

(if Btrfs on HDD, instead of on SSD)

‒ Check / remove unneeded snapshots

• Monthly maintenance‒ re-evaluate need for

filesystem extension

‒ `btrfs file balance`

‒ re-evaluate subvolume layout

Page 25: Btrfs and Snapper - The Next Steps from Pure Filesystem Features to Integration and Compliance

25

Demo: Dealing with fragmentation

• Find the top 10 most fragmented files in the current directory:filefrag * | sort -nr -k 2 | head -10

• Defrag ‒ files:btrfs file defrag $file

‒ directories:btrfs file defrag /var/log/

‒ whole filesystem:btrfs file defrag /

• Hot zones:‒ system specific:

/var/log/journal//tmp

‒ user specific:/home/

Specifically for HDDs, file fragmentation caused by the CoW feature may impact disk I/O performance. To prevent performance degradation, regular de-fragmentation is advisable.

Page 26: Btrfs and Snapper - The Next Steps from Pure Filesystem Features to Integration and Compliance

26

Btrfs integration in SLE 11 and openSUSE

Future plans

• YaST partitioner support for:‒ Built-in multi-device

handling and RAID

‒ Transparent compression

• Bootloader support for /boot on btrfs (SLE12)

• Snapshot integration into bootloader

Page 27: Btrfs and Snapper - The Next Steps from Pure Filesystem Features to Integration and Compliance

27

Btrfs ReferencesPublications• Btrfs wiki (and mirror)

• Josef Bacik's article on Btrfs

• Arne Jansen's paper on qgroups (quota support)

• Oloh Rodeh - B-trees, Shadowing, and Clones, IBM Research paper

• LWN - “A short history of btrfs”article

• Wikipedia - Btrfs article

Video's• Matthias Eckerman: Why btrfs is the

Bread and Butter of Filesystems, LinuxCon 2013, New Orleans (49min, link)

• Chris Mason: Introduction to Btrfs(26min, link)

• Chris Mason: Btrfs Filesystem: Status and New Features, (May 2012, link)

• Avi Miller's Btrfs talk at LinuxConf AU (49min, Jan 2012)

‒ Demo of “mount -o recovery”

‒ Animations of disk usage on Ext3, XFS and Btrfs

• Douglas Fuller's talk (24min, Apr 2011)

‒ Nice performance demo's

Page 28: Btrfs and Snapper - The Next Steps from Pure Filesystem Features to Integration and Compliance

28

Snapper: snapshot management

Functions

• Create / Delete snapshots‒ Manually

‒ Automated

‒ Also for non-root users through DBus

• Compare snapshots‒ List of files

‒ Content of files (diff)

• Store and manage additional snapshot related metadata

• Undo changes, ie: per file rollback

• Mount / Unmount snapshots

Page 29: Btrfs and Snapper - The Next Steps from Pure Filesystem Features to Integration and Compliance

29

Snapshot management with Snapper

Page 30: Btrfs and Snapper - The Next Steps from Pure Filesystem Features to Integration and Compliance

30

Snapper DBus support

dbus daemon

snapperd

Unprivileged user

Unprivileged user Privileged userPrivileged user

Privileged user

agent (snapper)

agent (yast)

agent (e.g.: custom script)

• Snapper is split up:‒ snapper (client)

‒ snapperd (server)

• Authorized users submit request through DBus

• snapperd performs actions on behalf of users

• Authorization scheme‒ Users

‒ Agents

Page 31: Btrfs and Snapper - The Next Steps from Pure Filesystem Features to Integration and Compliance

31

Snapper configuration

• YaST configures snapper for the root filesystem

• /etc/snapper/configs/ contains a file for each btrfs subvolume:‒ cleanup algorithms

‒ snapshot creating permissions

• Cleanup Algorithms:‒ NUMBER_LIMIT="10"

‒ TIMELINE_LIMIT_DAILY="5"

• Permissions:‒ ALLOW_USERS="tux"

‒ chgrp users /home/tux

Page 32: Btrfs and Snapper - The Next Steps from Pure Filesystem Features to Integration and Compliance

32

Snapper – Metadata

Meta information stored with each snapshot:‒ Type : [ Pre | Post | Single ]

‒ # : Nr of snapshot

‒ Pre # : Matching “Pre” number, if type is “Post”

‒ Date : Timestamp

‒ User : User who created the snapshot

‒ Cleanup : Cleanup algorithm for this snapshot

‒ Description : A fitting description of the snapshot (free text)

‒ Userdata : key=value pairs to record all sorts of useful information about the snapshot in an (e.g.: easily parsing from scripts)

Page 33: Btrfs and Snapper - The Next Steps from Pure Filesystem Features to Integration and Compliance

33

Distro Support Status - Snapper

Support

• SLES 11 SP2

• SLES 11 SP3

• openSUSE 12.1 - 13.1

• Fedora 19

Technology Preview / unsupported

• Red Hat Enterprise Linux

• Fedora

• and others...

Page 34: Btrfs and Snapper - The Next Steps from Pure Filesystem Features to Integration and Compliance

34

Snapper – Planned features

• Keep track of space usage by snapshots, utilizing qgroups;

In other words: how much space will be reclaimed when deleting a snapshot

• Integration points‒ Hooks for external scripts

‒ Snapshot create

‒ Snapshot delete

Page 35: Btrfs and Snapper - The Next Steps from Pure Filesystem Features to Integration and Compliance

35

Demo

Snapper

• Snapper module for YaST

• Snapper integration with YaST

• Snapper command line tool

• Snapper as non-root

Page 36: Btrfs and Snapper - The Next Steps from Pure Filesystem Features to Integration and Compliance

36

Agenda

Introduction to Btrfs

Btrfs in SUSE distro's Snapper

Btrfs Use cases

Summary and Questions

• Filesystem changes after software installation

• Server side copy with Samba4

• Automated Recovery Points with Samba4

• ITIL Change Management vs. DC reality

Page 37: Btrfs and Snapper - The Next Steps from Pure Filesystem Features to Integration and Compliance

37

Use Case: Filesystem changes after installation of some software

• Step 1: Create “Pre” snapshotsnapper create --type pre --description "Before installation”

• Step 2: Install application

• Step 3: Create “Post” snapshotsnapper create --type post --pre-number $PreNR --description “After installation”

• Step 4: Compare “Pre” and “Post” situation

# snapper status $PreNR..$PostNrc... /etc/ld.so.cache+... /usr/lib/libXi.so.6+... /usr/lib/libXi.so.6.1.0c... /var/cache/ldconfig/aux-cache[...]

Page 38: Btrfs and Snapper - The Next Steps from Pure Filesystem Features to Integration and Compliance

38

Use Case: Server Side copy with Samba4

• Prolem:‒ Copying of large file(s)

initiated from workstation is slow and requires large bandwith

• Solution:‒ Clone file(s) on the server

• Required:‒ Samba 4.1

(supports Server side copy)

‒ Client: Windows Server 2012

Page 39: Btrfs and Snapper - The Next Steps from Pure Filesystem Features to Integration and Compliance

39

Use Case: Automated Recovery Points with Samba4

Fileshare

SLES 12

Windows 7, Vista or XP

Samba4service

File “test.txt” is changed

Scheduled snapshots by Snapper

File “test.txt” is created

Networkshare

Now

Available Recovery Points for “test.txt” in Explorer

Automatedsnapshots

Page 40: Btrfs and Snapper - The Next Steps from Pure Filesystem Features to Integration and Compliance

40

Use Case: ITIL Change Management vs. DC reality

• ITIL Change Management‒ What is the status of

planned changes?

‒ Are there any unplanned changes?

• DC reality

‒ Unplanned, unauthorized and ill-considered changes do happen

• Solution option‒ Use Btrfs snapshots to preserve states of systems

‒ Snapper integration with systems management tooling to track changes

‒ Record Change related information in snapshot metadata

‒ Automated interface from Snapper to ITIL tooling

Page 41: Btrfs and Snapper - The Next Steps from Pure Filesystem Features to Integration and Compliance

41

Use Case: ITIL Change Management vs. DC reality

# @Begin of implementation Change:snapper create \ --type pre \ --description "ChgMgt Work order: Upgrade syslog configuration to forward log entries to central log server" \ --userdata \"WorkOrder=201201253030000012-1, State=InProgress,[email protected]"

# @End of implementation Change:snapper create \ --type post --pre-number 240 \ --description "Done: ChgMgt Work order: Upgrade syslog configuration to forward log entries to central log server" \ --userdata "WorkOrder=201201253030000012-1, State=Closed, [email protected]"

Page 42: Btrfs and Snapper - The Next Steps from Pure Filesystem Features to Integration and Compliance

42

Agenda

Introduction to Btrfs

Btrfs in SUSE distro's Snapper

Summary and Questions

Summary

• Lots of desirable features

• Development is ongoing

• Distributions support is mounting

• Lots of practical applications yet to come

• Please direct your questions or remarks to Gábor Nyers <[email protected]>

Btrfs Use cases

Page 43: Btrfs and Snapper - The Next Steps from Pure Filesystem Features to Integration and Compliance

Thank you.

43

For more information please visit our website:www.suse.com

Page 44: Btrfs and Snapper - The Next Steps from Pure Filesystem Features to Integration and Compliance
Page 45: Btrfs and Snapper - The Next Steps from Pure Filesystem Features to Integration and Compliance

Unpublished Work of SUSE. All Rights Reserved.This work is an unpublished work and contains confidential, proprietary and trade secret information of SUSE. Access to this work is restricted to SUSE employees who have a need to know to perform tasks within the scope of their assignments. No part of this work may be practiced, performed, copied, distributed, revised, modified, translated, abridged, condensed, expanded, collected, or adapted without the prior written consent of SUSE. Any use or exploitation of this work without authorization could subject the perpetrator to criminal and civil liability.

General DisclaimerThis document is not to be construed as a promise by any participating company to develop, deliver, or market a product. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. SUSE makes no representations or warranties with respect to the contents of this document, and specifically disclaims any express or implied warranties of merchantability or fitness for any particular purpose. The development, release, and timing of features or functionality described for SUSE products remains at the sole discretion of SUSE. Further, SUSE reserves the right to revise this document and to make changes to its content, at any time, without obligation to notify any person or entity of such revisions or changes. All SUSE marks referenced in this presentation are trademarks or registered trademarks of Novell, Inc. in the United States and other countries. All third-party trademarks are the property of their respective owners.