[filesystem][archlinux][disk encryption][btrfs] btrfs

 

fork from here http://www.cnblogs.com/hugetong/p/6914248.html php

boot分區,MBR加密:https://wiki.archlinux.org/index.php/Dm-crypt/Specialties#Securing_the_unencrypted_boot_partitionhtml

 

首先,我選擇在LUKS上建立btrfs。查看上述文檔的btrfs章節。linux

1. btrfs不支持swap file,必須使用swap分區 https://wiki.archlinux.org/index.php/Btrfs#Swap_fileapp

2. 不建議在裸盤直接使用btrfs文件系統。https://wiki.archlinux.org/index.php/Btrfs#Partitionless_Btrfs_diskless

3. btrfs帶壓縮會提升性能表現。https://wiki.archlinux.org/index.php/Btrfs#Compressionide

4. 新概念 subvolumes。 https://wiki.archlinux.org/index.php/Btrfs#Subvolumes性能

這個更詳細,講的更清楚,上邊那個講的很不清楚。。。:https://btrfs.wiki.kernel.org/index.php/SysadminGuide#Subvolumesui

 

btrfs文檔:https://wiki.archlinux.org/index.php/Btrfs (跟上邊那一堆,明明都是一個。。。)加密

多個磁盤的狀況下能夠組成一個pool,Btrfs支持 RAID0,1, 10, 5, 6。https://btrfs.wiki.kernel.org/index.php/Using_Btrfs_with_Multiple_Devicesspa

 

5.  不要使用btrfs 的 RAID5, RAID6模式。

6.  經常使用命令們

https://btrfs.wiki.kernel.org/index.php/Getting_started#Basic_Filesystem_Commands

7.  最大容量 70% ??

       Be aware that for that size, it will report full when reaching about 75%.

 

-----------------------------------------------------------

1.  初始化一個 btrfs 文件系統

1 root@archiso ~ # mkfs.btrfs -L vd_root -f /dev/mapper/vd_root                                                       :(
btrfs-progs v4.10.2
See http://btrfs.wiki.kernel.org for more information.

Label:              vd_root
UUID:               ba0b8b0b-8753-455b-90f6-422f61d59df1
Node size:          16384
Sector size:        4096
Filesystem size:    20.00GiB
Block group profiles:
  Data:             single            8.00MiB
  Metadata:         DUP               1.00GiB
  System:           DUP               8.00MiB
SSD detected:       no
Incompat features:  extref, skinny-metadata
Number of devices:  1
Devices:
   ID        SIZE  PATH
    1    20.00GiB  /dev/mapper/vd_root

root@archiso ~ # 

 

2.  建立一個 subvolume

root@archiso ~ # btrfs subvolume create mnt/real_root
Create subvolume 'mnt/real_root'

3.  建立快照(很顯然從命令來看,快照也是一個subvolume )

root@archiso ~ # btrfs subvolume snapshot mnt/real_root mnt/snapshot_of_real_root
Create a snapshot of 'mnt/real_root' in 'mnt/snapshot_of_real_root'

4.  設置default

root@archiso ~ # btrfs subvolume set-default 257 mnt                                      
root@archiso ~ # btrfs subvolume get-default mnt    
ID 257 gen 16 top level 5 path real_root

 

5.  刪除快照或subvolume

root@archiso ~ # btrfs subvolume list /root/mnt 
ID 257 gen 22 top level 5 path real_root
ID 258 gen 16 top level 5 path snapshot_of_real_root
ID 259 gen 22 top level 5 path snapshot/snapshot_of_real_root_2
root@archiso ~ # btrfs subvolume create mnt/test
Create subvolume 'mnt/test'
root@archiso ~ # btrfs subvolume list /root/mnt 
ID 257 gen 22 top level 5 path real_root
ID 258 gen 16 top level 5 path snapshot_of_real_root
ID 259 gen 22 top level 5 path snapshot/snapshot_of_real_root_2
ID 260 gen 24 top level 5 path test
root@archiso ~ # btrfs subvolume delete mnt/test 
Delete subvolume (no-commit): '/root/mnt/test'
root@archiso ~ # btrfs subvolume list /root/mnt 
ID 257 gen 22 top level 5 path real_root
ID 258 gen 16 top level 5 path snapshot_of_real_root
ID 259 gen 22 top level 5 path snapshot/snapshot_of_real_root_2
root@archiso ~ # 

 

6. 根據文檔裏的描述, 選用Flat方式建立subvolume

https://btrfs.wiki.kernel.org/index.php/SysadminGuide#Flat

root@archiso ~ # find mnt 
mnt
mnt/real_root
mnt/real_root/root
mnt/real_root/home
mnt/snapshot
root@archiso ~ # btrfs subvolume get-default mnt
ID 257 gen 30 top level 5 path real_root
root@archiso ~ # btrfs subvolume list mnt  
ID 257 gen 30 top level 5 path real_root
ID 261 gen 29 top level 257 path real_root/root
ID 262 gen 30 top level 257 path real_root/home
root@archiso ~ # 

 

7. 掛載指定的 subvolume

root@archiso ~ # btrfs subvolume list mnt                                                         
ID 257 gen 12 top level 5 path top
ID 258 gen 11 top level 257 path top/root
ID 259 gen 12 top level 257 path top/home
root@archiso ~ # mount -o subvol=top/root /dev/mapper/crypt_root mnt  
相關文章
相關標籤/搜索