root: auto detect root subvolume
This commit is contained in:
parent
c904253bbf
commit
9ad6441b3a
|
@ -43,8 +43,7 @@ variables:
|
|||
zram: true
|
||||
filesystem:
|
||||
partitions:
|
||||
"/": /btrfs
|
||||
"/@root": /
|
||||
"/": /mnt/btrfs-root
|
||||
"/@home": /home
|
||||
"/@sql": /var/lib/mysql
|
||||
"/@swap": /swap
|
||||
|
@ -206,6 +205,7 @@ dynvariables:
|
|||
phisical_uuid: sudo blkid /dev/sda2 -s UUID -o value
|
||||
decrypted_uuid: sudo blkid /dev/mapper/main -s UUID -o value
|
||||
boot_uuid: sudo blkid /dev/sda1 -s UUID -o value
|
||||
root_subvol: echo "/@$(lsb_release -i | cut -f 2)-root"
|
||||
nproc: nproc
|
||||
memory_size: env LC_ALL=C free -b | awk '/^Mem:/ {print $2}'
|
||||
deezer_arl: pass show Entertainment/Deezer | awk '/^arl:/ {print $2}'
|
||||
|
|
|
@ -18,7 +18,7 @@ abbr -g mpn ncmpcpp
|
|||
abbr -g dot "dotdrop install -f"
|
||||
|
||||
set -l root_cfg (dirname $DOTDROP_CONFIG)/root
|
||||
alias rootdrop 'dotdrop install -f -c "$root_cfg"'
|
||||
alias rootdrop 'sudo dotdrop install -f -c "$root_cfg"'
|
||||
|
||||
cabbr p emerge
|
||||
|
||||
|
|
|
@ -1,12 +1,18 @@
|
|||
#!/bin/sh
|
||||
|
||||
if ! mountpoint /mnt/btrfs-root
|
||||
then
|
||||
mkdir /mnt/btrfs-root
|
||||
mount /mnt/btrfs-root
|
||||
fi
|
||||
cd /mnt/btrfs-root
|
||||
set -e
|
||||
|
||||
BTRFS_ROOT="{{@@ filesystem.partitions['/'] @@}}"
|
||||
|
||||
if ! mountpoint "$BTRFS_ROOT"
|
||||
then
|
||||
mkdir -p "$BTRFS_ROOT"
|
||||
mount "$BTRFS_ROOT"
|
||||
fi
|
||||
cd "$BTRFS_ROOT"
|
||||
|
||||
|
||||
{%@@ set new_partitions = filesystem.partitions.update({root_subvol: '/'}) @@%}
|
||||
{%@@ for name, path in filesystem.partitions.items() @@%}
|
||||
test -e "./{{@@ name @@}}" ||
|
||||
btrfs subvolume create "./{{@@ name @@}}"
|
||||
|
|
17
root/fstab
17
root/fstab
|
@ -1,12 +1,23 @@
|
|||
{{@@ 'non_templated(_dotfile_abs_dst)' | var @@}}
|
||||
##### Dotdrop-start #####
|
||||
|
||||
{#@@<filesystem> <dir> <type> <options> <dump> <pass> @@#}
|
||||
|
||||
{%@@ set btrfs_opt_t = "rw,noatime,compress=zstd:3,subvol={}" @@%}
|
||||
{%@@ set entry_t = "UUID={uuid} {path} {fs} {opts} {dump} {pass}" @@%}
|
||||
|
||||
UUID={{@@ boot_uuid @@}} /boot vfat rw,errors=remount-ro 0 2
|
||||
|
||||
{%@@ set new_partitions = filesystem.partitions.update({root_subvol: '/'}) @@%}
|
||||
{%@@ for name, path in filesystem.partitions.items() @@%}
|
||||
{#@@<filesystem> <dir> <type> <options> <dump> <pass> @@#}
|
||||
{%@@ set options = "rw,noatime,compress=zstd:3,subvol={}".format(name) @@%}
|
||||
UUID={{@@ decrypted_uuid @@}} {{@@ path @@}} btrfs {{@@ options @@}} 0 {{@@ ("root" in name) | int@@}}
|
||||
{{@@ entry_t.format(
|
||||
uuid= decrypted_uuid ,
|
||||
path= path ,
|
||||
fs= "btrfs",
|
||||
opts= btrfs_opt_t.format(name),
|
||||
dump= "0",
|
||||
pass= ("root" in name) | int,
|
||||
) @@}}
|
||||
{%@@ endfor @@%}
|
||||
|
||||
/swap/swapfile none swap defaults 0 0
|
||||
|
|
|
@ -11,7 +11,7 @@ GRUB_DISTRIBUTOR="Artix"
|
|||
|
||||
GRUB_CMDLINE_LINUX_DEFAULT=""
|
||||
GRUB_CMDLINE_LINUX=" cryptdevice=UUID={{@@ phisical_uuid @@}}:main "
|
||||
GRUB_CMDLINE_LINUX+=" root=/dev/mapper/main rootflags=rw,noatime,compress=zstd,subvol=/@root "
|
||||
GRUB_CMDLINE_LINUX+=" root=/dev/mapper/main rootflags=rw,noatime,compress=zstd,subvol=/{{@@ root_subvol @@}} "
|
||||
|
||||
# Preload both GPT and MBR modules so that they are not missed
|
||||
GRUB_PRELOAD_MODULES="part_gpt part_msdos"
|
||||
|
|
Reference in New Issue