yum install btrfs-progs
# mkfs.btrfs /dev/sdb1
指定卷標
# mkfs.btrfs /dev/sdb2 -L /backup
# mkdir /mnt/btrfs # mount /dev/sdb1 /mnt/btrfs
查看掛載是否成功
# df -Th Filesystem Type Size Used Avail Use% Mounted on /dev/sda1 ext4 49G 15G 32G 32% / tmpfs tmpfs 32G 264K 32G 1% /dev/shm /dev/sda3 ext4 52G 1.3G 48G 3% /var /dev/sdb1 btrfs 2.0T 14G 2.0T 1% /mnt/btrfs
針對 SSD 的優化: # mount –t btrfs –o SSD /dev/sda5 /btrfsdisk 打開壓縮功能: # mount –t btrfs –o compress /dev/sda5 /btrfsdisk
mount -t btrfs -o subvol=your_snapshot /dev/sdb2 /mnt/snap
mount -t btrfs -o subvol=aaa /dev/md127p5 /mnt/snap
[root@r610 ~]# btrfs-show Label: none uuid: 0b097eeb-1f0b-476a-955b-52122ef42bfc Total devices 1 FS bytes used 13.03GB devid 1 size 2.00TB used 24.04GB path /dev/sdb1 Btrfs Btrfs v0.19
# df -T Filesystem Type 1K-blocks Used Available Use% Mounted on /dev/md126p2 ext4 50395844 19952780 27883064 42% / tmpfs tmpfs 4024944 800 4024144 1% /dev/shm /dev/md126p1 ext4 495844 172140 298104 37% /boot /dev/md126p6 btrfs 500084736 360835636 119893924 76% /opt /dev/md126p5 btrfs 409600000 24927332 368284612 7% /www # btrfs subvolume create /www/git Create subvolume '/www/git' # btrfs subvolume list /www ID 641 gen 21351 top level 5 path git
fstab 掛在子卷
$ cat /etc/fstab # # /etc/fstab # Created by anaconda on Thu Oct 18 13:53:45 2012 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # UUID=88ec1ccf-7d8d-4107-a143-1ed0ec64a572 / ext4 defaults 1 1 UUID=c0786771-1c85-45be-a9ab-ef3ee16fccb4 /boot ext4 defaults 1 2 UUID=e1b89740-21f0-4507-97e9-a658cd7d3716 /opt btrfs defaults 1 2 UUID=76e46795-ebaf-4d2d-8996-1e15979bf3c8 /www btrfs defaults 1 2 UUID=76e46795-ebaf-4d2d-8996-1e15979bf3c8 /home/git btrfs defaults,subvol=git 1 2 UUID=c578f1b3-4bbe-4f48-b3d3-3929c65cb99c swap swap defaults 0 0 tmpfs /dev/shm tmpfs defaults 0 0 devpts /dev/pts devpts gid=5,mode=620 0 0 sysfs /sys sysfs defaults 0 0 proc /proc proc defaults 0 0
# btrfsck /dev/sdb1 found 13994164224 bytes used err is 0 total csum bytes: 13588316 total tree bytes: 79728640 total fs tree bytes: 28860416 btree space waste bytes: 10282024 file data blocks allocated: 13931024384 referenced 13906980864 Btrfs Btrfs v0.19
[root@r610 ~]# btrfs-debug-tree /dev/sdb1 |head root tree leaf 49463296 items 9 free space 2349 generation 298 owner 1 fs uuid 0b097eeb-1f0b-476a-955b-52122ef42bfc chunk uuid 2826f868-c775-4835-8690-1020a2a9fbf5 item 0 key (EXTENT_TREE ROOT_ITEM 0) itemoff 3756 itemsize 239 root data bytenr 49446912 level 2 dirid 0 refs 1 item 1 key (DEV_TREE ROOT_ITEM 0) itemoff 3517 itemsize 239 root data bytenr 36139008 level 0 dirid 0 refs 1 item 2 key (FS_TREE INODE_REF 6) itemoff 3500 itemsize 17 inode ref index 0 namelen 7 name: default