Skip to content

Commit

Permalink
Generate the default entry using gpt-auto
Browse files Browse the repository at this point in the history
Using gpt-auto will ensure that efi partition and swap partition will be automatically mounted even if fstab do not list them.

Move btrfs subvol id detection code and recursive umount of deployment earlier to greatly reduce likelihood of generating a non-working default entry: it will only happen if the default subvolume cannot change (severe error anyway).
  • Loading branch information
NeroReflex committed Aug 24, 2024
1 parent d47f199 commit b781f4e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 24 deletions.
21 changes: 12 additions & 9 deletions __frzr
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,8 @@ prepare_efi_partition() {

local default_config_entry=""

local default_frzr_default_entry_filename="frzr.conf"

# create /loader/entries in the EFI system partition (if it does not exists already)
mkdir -p ${efi_mount_path}/loader/entries

Expand Down Expand Up @@ -860,7 +862,14 @@ prepare_efi_partition() {
if echo "${systemd_boot_update_result}" | grep -q 'ERROR'; then
echo "ERROR: Could not add bootloader entry: ${systemd_boot_update_result}"
else
default_boot_cfg="${boot_entry}"
# Write "${EFI_MOUNT_PATH}/loader/entries/${default_frzr_default_entry_filename}" so that frzr will make use of the new kernel
# WARNING: btrfs_rootfs_uuid being empty means gpt-auto will be used
local default_boot_entry_generation_res=$(generate_systemd_boot_cfg "${version}" "${default_frzr_default_entry_filename}" "${version}" "${efi_mount_path}" "${amd_ucode}" "${intel_ucode}" "${vmlinuz_file}" "${initramfs_file}" "${additional_arguments}" "" "")
if echo "${boot_entry_generation_res}" | grep -Fq "ERROR"; then
echo "ERROR: Could not add bootloader entry: ${default_boot_entry_generation_res}"
else
default_boot_cfg="${boot_entry}"
fi
fi
else
echo "ERROR: Could not copy '${boot_dir}/${initramfs_file}' to '${efi_mount_path}/${version}/${initramfs_file}'"
Expand All @@ -872,21 +881,15 @@ prepare_efi_partition() {
done

# override the default deployment boot with the user-provided one
if [ -f "${efi_mount_path}/loader/entries/frzr_kernel.conf" ]; then
default_boot_cfg="frzr_kernel.conf"
if [ -f "${efi_mount_path}/loader/entries/${default_frzr_default_entry_filename}" ]; then
default_boot_cfg="${default_frzr_default_entry_filename}"
fi

# write the default boot entry
if [ -z "$default_boot_cfg" ]; then
echo "ERROR: no bootable kernel found"
else
echo "default ${default_boot_cfg}" > "${efi_mount_path}/loader/loader.conf"

# If frzr-kernel has been used this is a development machine: add a boot timeout so that different kernels can be used
if [ "${default_boot_cfg}" = "frzr_kernel.conf" ]; then
echo "timeout 3" >> "${efi_mount_path}/loader/loader.conf"
fi

echo "OK"
fi
fi
Expand Down
30 changes: 15 additions & 15 deletions __frzr-deploy
Original file line number Diff line number Diff line change
Expand Up @@ -512,20 +512,6 @@ frzr_deploy() {
TASK_STATE="CLEANUP"
send_data

# This is used to update the EFI partition: setting up systemd-boot (or whatever else bootlader might be supported) to boot the new deployment
local efi_update_result=$("${BASH_SOURCE%/*}/frzr-bootloader" "${NAME}")
if echo "${efi_update_result}" | grep -Fq 'ERROR'; then
# bootloader configuration could not be updated
TASK_ERROR=1
TASK_ERROR_MSG="Could not update the EFI partition: ${efi_update_result}"
STATE="FAIL"
send_data
continue
fi

# Remove download artifacts (if any)
rm -f ${MOUNT_PATH}/*.img.*

# Lazy umount the deployed system (find all mounted subdirectories under the parent directory and unmount the mounted subdirectories)
TASK_MSG="Post-install umount of '${SUBVOL}'"
send_data
Expand Down Expand Up @@ -556,6 +542,17 @@ frzr_deploy() {
continue
fi

# This is used to update the EFI partition: setting up systemd-boot (or whatever else bootlader might be supported) to boot the new deployment
local efi_update_result=$("${BASH_SOURCE%/*}/frzr-bootloader" "${NAME}")
if echo "${efi_update_result}" | grep -Fq 'ERROR'; then
# bootloader configuration could not be updated
TASK_ERROR=1
TASK_ERROR_MSG="Could not update the EFI partition: ${efi_update_result}"
STATE="FAIL"
send_data
continue
fi

# Activates the new deployed image by making it the default btrfs subvolume
# systemd-equipped initramfs images will automount the default subvolume as the rootfs
TASK_MSG="Activating the new deployment (subvolid=${subvolid}) as the default subvolume"
Expand All @@ -567,7 +564,10 @@ frzr_deploy() {
send_data
continue
fi


# Remove download artifacts (if any)
rm -f "${MOUNT_PATH}"/*.img*

STATE="SUCCESS"
;;
"SUCCESS")
Expand Down

0 comments on commit b781f4e

Please sign in to comment.