Home | Mirror | Search

4. btrfs

yum install btrfs-progs
		
# mkfs.btrfs /dev/sdb1
		

指定卷標

# mkfs.btrfs /dev/sdb2 -L /backup
		

4.1. Mount Btrfs

# 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
			

4.1.1. Mount Snap

mount -t btrfs -o subvol=your_snapshot /dev/sdb2 /mnt/snap
				

4.1.2. fstab

4.1.2.1. btrfs-show
[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
					
4.1.2.2. /etc/fstab
UUID=0b097eeb-1f0b-476a-955b-52122ef42bfc /opt    btrfs   defaults 1 2
					

4.2. btrfsctl

4.2.1. Resizes the filesystem


				

4.2.2. Snapshot

# touch /mnt/btrfs/test1
# touch /mnt/btrfs/test2
# ls /mnt/btrfs/test?
/mnt/btrfs/test1  /mnt/btrfs/test2
				
# echo 'This is a test' > /mnt/btrfs/test1
# btrfsctl – s snap1 /mnt/btrfs
#vi test1
 Test1 is modified
#cd /mnt/btrfs/snap1
#cat test1
 This is a test
				

4.3. btrfs-vol

# btrfs-vol –a /dev/sdc1 /mnt/btrfs
			

4.4. btrfs-convert

btrfs-convert /dev/sdb1
			

4.5. btrfsck

# 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
			

4.6. btrfs-debug-tree

[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

			
comments powered by Disqus