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

 

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

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

 

首先,我选择在LUKS上创建btrfs。查看上述文档的btrfs章节。

1. btrfs不支持swap file,必须使用swap分区 https://wiki.archlinux.org/index.php/Btrfs#Swap_file

2. 不建议在裸盘直接使用btrfs文件系统。https://wiki.archlinux.org/index.php/Btrfs#Partitionless_Btrfs_disk

3. btrfs带压缩会提高性能表现。https://wiki.archlinux.org/index.php/Btrfs#Compression

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

这个更详细,讲的更清楚,上边那个讲的很不清楚。。。:https://btrfs.wiki.kernel.org/index.php/SysadminGuide#Subvolumes

 

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_Devices

 

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  

 

posted on 2017-06-02 20:52  toong  阅读(384)  评论(0编辑  收藏  举报