Fixing RootPart for Encryption

This commit is contained in:
Eric Renfro 2024-06-23 19:49:06 -04:00
parent 95e09bcb32
commit 28d30d3700
Signed by: psi-jack
SSH key fingerprint: SHA256:1TKB8Z257L8EHK8GWNxKgMhD8a+FAR+f+j3nnlcuNVM

View file

@ -94,12 +94,18 @@ function create_subvolumes() {
subvols+=(${!SUBVOLS_DEFAULT[@]}) subvols+=(${!SUBVOLS_DEFAULT[@]})
${cmd} mount "$RootPart" /mnt if [[ "$ENCRYPTION" ]]; then
${cmd} mount "/dev/mapper/luksvol"
else
${cmd} mount "$RootPart" /mnt
fi
for subvol in "${subvols[@]}" for subvol in "${subvols[@]}"
do do
${cmd} btrfs subvolume create /mnt/"$subvol" ${cmd} btrfs subvolume create /mnt/"$subvol"
done done
${cmd} umount "$RootPart" /mnt
${cmd} mount /mnt
} }
function get_hibernate_size() { function get_hibernate_size() {
@ -108,6 +114,7 @@ function get_hibernate_size() {
function prepare_target() { function prepare_target() {
local subvol local subvol
local rootmount
if [[ "$DEBUG" ]]; then if [[ "$DEBUG" ]]; then
local cmd="echo" local cmd="echo"
@ -118,7 +125,14 @@ function prepare_target() {
fi fi
${cmd} mkdir /target ${cmd} mkdir /target
${cmd} mount -o noatime,space_cache=v2,ssd,subvol=@ "$RootPart" /target
if [[ "$ENCRYPTION" ]]; then
rootmount="/dev/mapper/luksvol"
else
rootmount="$RootPart"
fi
${cmd} mount -o noatime,space_cache=v2,ssd,subvol=@ "$rootmount" /target
for subvol in "${!SUBVOLS_DEFAULT[@]}" for subvol in "${!SUBVOLS_DEFAULT[@]}"
do do
@ -129,14 +143,14 @@ function prepare_target() {
#${cmd} mkdir -p /target/{var/cache,var/log,var/spool,var/tmp,var/www} #${cmd} mkdir -p /target/{var/cache,var/log,var/spool,var/tmp,var/www}
if [[ "$BootPart" == "@boot" ]]; then if [[ "$BootPart" == "@boot" ]]; then
${cmd} mount -o noatime,space_cache=v2,ssd,subvol=@boot "$RootPart" /target/boot ${cmd} mount -o noatime,space_cache=v2,ssd,subvol=@boot "$rootmount" /target/boot
else else
${cmd} mount "$BootPart" /target/boot ${cmd} mount "$BootPart" /target/boot
fi fi
for subvol in "${!SUBVOLS_DEFAULT[@]}" for subvol in "${!SUBVOLS_DEFAULT[@]}"
do do
${cmd} mount -o noatime,space_cache=v2,ssd,subvol="$subvol" "$RootPart" /target/"${SUBVOLS_DEFAULT[$subvol]}" ${cmd} mount -o noatime,space_cache=v2,ssd,subvol="$subvol" "$rootmount" /target/"${SUBVOLS_DEFAULT[$subvol]}"
done done
${cmd} mkdir -p /target/boot/efi ${cmd} mkdir -p /target/boot/efi
@ -144,7 +158,7 @@ function prepare_target() {
if [[ "$SWAP" ]]; then if [[ "$SWAP" ]]; then
${cmd} mkdir -p /target/swap ${cmd} mkdir -p /target/swap
${cmd} mount -o noatime,ssd,subvol=@swap "$RootPart" /target/swap ${cmd} mount -o noatime,ssd,subvol=@swap "$rootmount" /target/swap
${cmd} btrfs filesystem mkswapfile --size "$(get_hibernate_size)g" --uuid clear /target/swap/hibernate.swp ${cmd} btrfs filesystem mkswapfile --size "$(get_hibernate_size)g" --uuid clear /target/swap/hibernate.swp
fi fi
} }