Download - Introducing Btrfs
BTRFSFEB 2014
www.anubhaskar.name
Creative Commons Attribution-ShareAlike 3.0 Unported License.
2
1.Btrfs - Introduction2.Btrfs Architecture3.Prototype Architecture4.Install Btrfs5.Create Btrfs Volume6.Online resizing of Btrfs7.Add/Remove devices from Btrfs volume8.Create Btrfs sub volumes9.Delete Btrfs sub volumes10.Create Btrfs snapshots11.Rollback Btrfs snapshots
AGENDA
Creative Commons Attribution-ShareAlike 3.0 Unported License.
3
1.File system + Volume Manager2.Data integrity – File system checksum3.Snapshots and clones4.Send/receive snapshots5.Highly Scalable (Max vol size - 16EiB)6.Copy-on-write transactional model7.Background scrub process for finding and fixing errors on files with redundant copies
8.Based on B-tree data structure9.GPL licensed
BTRFS - INTRODUCTION
Creative Commons Attribution-ShareAlike 3.0 Unported License.
4
BTRFS ARCHITECTURE
Creative Commons Attribution-ShareAlike 3.0 Unported License.
sda sdesdcsdb
md0 md1
vg0
lv0 lv1 lv2
/usr /var/home
sda sdesdcsdb
Volume/sub-volume
/usr /var/homeFile Systems
Logical Volumes
Volume Group
Physical Volumes
Physical Disks
Physical Disks
Storage Volume
File systems (btrfs)
LVM Btrfs
5
PROTOTYPE ARCHITECTURE
Creative Commons Attribution-ShareAlike 3.0 Unported License.
server1Centos6
sda sddsdcsdb
For installing OSCentos 68GB disk
For Btrfs1GB Disks
6
Install Btrfs user space tools# yum install btrfs-progs
Create btrfs control node# mknod /dev/btrfs-control c 10 234
INSTALL BTRFS
Creative Commons Attribution-ShareAlike 3.0 Unported License.
7
Create a RAID1 btrfs volume# mkfs.btrfs -d raid1 -m raid1 /dev/sdb /dev/sdc
View btrfs volume details# btrfs filesystem show /dev/sdb
Mount btrfs volume# mkdir /mount1# mount /dev/sdb /mount1
View file system details# btrfs filesystem df /mount1
View the size difference reported by df command# df -h /mount1
Add files to the volume# echo “test1” > /mount1/testfile1# ls -l /mount1
CREATE BTRFS VOLUME
Creative Commons Attribution-ShareAlike 3.0 Unported License.
8
Shrink btrfs volumes online# df -h /mount1# btrfs filesystem resize -500m /mount1# df -h /mount1# ls -l /mount1# cat /mount1/testfile1
Expand btrfs volume online# df -h mount1# btrfs filesystem resize +250m /mount1# df -h mount1# btrfs filesystem resize max /mount1# df -h mount1# ls -l /mount1# cat /mount1/testfile1
ONLINE RESIZING OF BTRFS
Creative Commons Attribution-ShareAlike 3.0 Unported License.
9
Add a new device to btrfs volume# btrfs filesystem show /dev/sdb# btrfs device add /dev/sdd /mount1# btrfs filesystem show /dev/sdb
Mirror metadata and data to new device# btrfs filesystem balance /mount1# btrfs filesystem show /dev/sdb# ls -l /mount1# cat /mount1/testfile1
Remove a device from btrfs volume# btrfs device delete /dev/sdd /mount1# btrfs filesystem show /dev/sdb
Wait for 5min and issue above command again to see some device missing error message disappearing.
ADD/REMOVE DEVICES FROM BTRFS VOLUME
Creative Commons Attribution-ShareAlike 3.0 Unported License.
10
List subvolumes# cd /mount1# btrfs subvolume list /mount1# ls -l /mount1
Create a subvolume# btrfs subvolume create subvol1# btrfs subvolume list /mount1# ls -l /mount1
Create two more subvolumes# btrfs subvolume create subvol2# btrfs subvolume create subvol3# btrfs subvolume list /mount1#ls -l mount1
Mount subvol in a seperate directory# mkdir /mount2# mount -o subvol=subvol1 /dev/sdb /mount2# df -h /mount*
CREATE BTRFS SUB-VOLUMES
Creative Commons Attribution-ShareAlike 3.0 Unported License.
11
Create a file in subvol1# echo “test2” > /mount2/testfile2# ls -l /mount2# ls -l /mount1/subvol1# cat /mount2/testfile2# cat /mount1/subvol1/testfile2# umount /mount2
Delete a subvolume# cd /mount1# btrfs subvolume delete subvol3# btrfs subvolume list /mount1# ls -l /mount1
DELETE BTRFS SUB-VOLUMES
Creative Commons Attribution-ShareAlike 3.0 Unported License.
12
Add data to sub volume# echo “test3” > /mount1/subvol1/testfile3# ls -l /mount1/subvol1/# cat /mount1/subvol1/testfile3
Create a sub volume snapshot# btrfs subvolume list /mount1# btrfs subvolume snapshot /mount1/subvol1 /mount1/snapsubvol1# btrfs subvolume list /mount1# ls -l /mount1/snapsubvol1
Delete data from sub volume# rm /mount1/subvol1/testfile3# ls -l /mount1/subvol1/# ls -l /mount1/snapsubvol1
CREATE BTRFS SNAPSHOTS
Creative Commons Attribution-ShareAlike 3.0 Unported License.
13
Rollback sub volume to snapshot# btrfs subvolume list /mount1# btrfs subvolume delete /mount1/subvol1# btrfs subvolume list /mount1# mv /mount1/snapsubvol1 /mount1/subvol1# btrfs subvolume list mount1
View data# ls -l /mount1/subvol1# cat /mount1/subvol1/testfile3
ROLLBACK BTRFS SNAPSHOTS
Creative Commons Attribution-ShareAlike 3.0 Unported License.
14
THANK YOU
Creative Commons Attribution-ShareAlike 3.0 Unported License.