1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
df
umount /target/boot/efi/
# 可选
umount /target/boot/
umount /target/
# 根据df命令选择对应的分区
mount /dev/sda2 /mnt
cd /mnt
mv @rootfs @
# 创建其他子卷
btrfs su cr @snapshots
btrfs su cr @home
btrfs su cr @opt
btrfs su cr @log
btrfs su cr @cache
btrfs su cr @crash
btrfs su cr @tmp
btrfs su cr @spool
btrfs su cr @images
btrfs su cr @containers
# GNOME related subvolumes,如果不使用GNOME则不需要,在安装gnome桌面前不能挂载此2个子卷,否则会出现fstab挂载错误
btrfs su cr @AccountsService
btrfs su cr @gdm
# 挂载子卷
mount -o noatime,space_cache=v2,compress=zstd:1,ssd,discard=async,subvol=@ /dev/mapper/sda2 /target
# 创建其他子卷挂载目录
cd /target
mkdir -p .snapshots
mkdir -p home
mkdir -p opt
mkdir -p var/log
mkdir -p var/cache
mkdir -p var/crash
mkdir -p var/tmp
mkdir -p var/spool
mkdir -p var/lib/libvirt/images
mkdir -p var/lib/containers
# 如果不安装GNOME则不需要此步骤
mkdir -p var/lib/AccountsService
mkdir -p var/lib/gdm3
# 挂载子卷到指定目录
mount -o noatime,space_cache=v2,compress=zstd:1,ssd,discard=async,subvol=@snapshots /dev/mapper/sda2 /target/.snapshots
mount -o noatime,space_cache=v2,compress=zstd:1,ssd,discard=async,subvol=@home /dev/mapper/sda2 /target/home
mount -o noatime,space_cache=v2,compress=zstd:1,ssd,discard=async,subvol=@home /dev/mapper/sda2 /target/opt
mount -o noatime,space_cache=v2,compress=zstd:1,ssd,discard=async,subvol=@log /dev/mapper/sda2 /target/var/log
mount -o noatime,space_cache=v2,compress=zstd:1,ssd,discard=async,subvol=@cache /dev/mapper/sda2 /target/var/cache
mount -o noatime,space_cache=v2,compress=zstd:1,ssd,discard=async,subvol=@crash /dev/mapper/sda2 /target/var/crash
mount -o noatime,space_cache=v2,compress=zstd:1,ssd,discard=async,subvol=@tmp /dev/mapper/sda2 /target/var/tmp
mount -o noatime,space_cache=v2,compress=zstd:1,ssd,discard=async,subvol=@spool /dev/mapper/sda2 /target/var/spool
mount -o noatime,space_cache=v2,compress=zstd:1,ssd,discard=async,subvol=@images /dev/mapper/sda2 /target/var/lib/libvirt/images
mount -o noatime,space_cache=v2,compress=zstd:1,ssd,discard=async,subvol=@containers /dev/mapper/sda2 /target/var/lib/containers
# 下面两个步骤先不执行,等安装GNOME桌面后再执行
# mount -o noatime,space_cache=v2,compress=zstd:1,ssd,discard=async,subvol=@AccountsService /dev/mapper/sda2 /target/var/lib/AccountsService
# mount -o noatime,space_cache=v2,compress=zstd:1,ssd,discard=async,subvol=@gdm /dev/mapper/sda2 /target/var/lib/gdm3
# 再挂载BOOT分区,EFI分区
# mount /dev/sda2 boot
mount /dev/sda1 boot/efi
# 持久化挂载
nano etc/fstab
/dev/mapper/$VOLUME_GROUP / btrfs noatime,space_cache=v2,compress=zstd:1,ssd,discard=async,subvol=@ 0 0
/dev/mapper/$VOLUME_GROUP /.snapshots btrfs noatime,space_cache=v2,compress=zstd:1,ssd,discard=async,subvol=@snapshots 0 0
/dev/mapper/$VOLUME_GROUP /home btrfs noatime,space_cache=v2,compress=zstd:1,ssd,discard=async,subvol=@home 0 0
/dev/mapper/$VOLUME_GROUP /opt btrfs noatime,space_cache=v2,compress=zstd:1,ssd,discard=async,subvol=@opt 0 0
/dev/mapper/$VOLUME_GROUP /var/log btrfs noatime,space_cache=v2,compress=zstd:1,ssd,discard=async,subvol=@log 0 0
/dev/mapper/$VOLUME_GROUP /var/cache btrfs noatime,space_cache=v2,compress=zstd:1,ssd,discard=async,subvol=@cache 0 0
/dev/mapper/$VOLUME_GROUP /var/crash btrfs noatime,space_cache=v2,compress=zstd:1,ssd,discard=async,subvol=@crash 0 0
/dev/mapper/$VOLUME_GROUP /var/tmp btrfs noatime,space_cache=v2,compress=zstd:1,ssd,discard=async,subvol=@tmp 0 0
/dev/mapper/$VOLUME_GROUP /var/spool btrfs noatime,space_cache=v2,compress=zstd:1,ssd,discard=async,subvol=@spool 0 0
/dev/mapper/$VOLUME_GROUP /var/lib/libvirt/images btrfs noatime,space_cache=v2,compress=zstd:1,ssd,discard=async,subvol=@images 0 0
/dev/mapper/$VOLUME_GROUP /var/lib/containers btrfs noatime,space_cache=v2,compress=zstd:1,ssd,discard=async,subvol=@containers 0 0
# /dev/mapper/$VOLUME_GROUP /var/lib/AccountsService btrfs noatime,space_cache=v2,compress=zstd:1,ssd,discard=async,subvol=@AccountsService 0 0
# /dev/mapper/$VOLUME_GROUP /var/lib/gdm3 btrfs noatime,space_cache=v2,compress=zstd:1,ssd,discard=async,subvol=@gdm 0 0
# 卸载挂载
cd /
umount /mnt
exit
|