mirror of
https://github.com/Antynea/grub-btrfs.git
synced 2026-10-20 02:42:03 +08:00
add support for booting snapshots on LUKS encrypted disk (#333)
* add support for booting snapshots on LUKS encrypted disk * documentation for booting from LUKS encrypted devices * better detecting cryptdevice UUID
This commit is contained in:
+26
-2
@@ -122,6 +122,25 @@ boot_uuid_subvolume=$(awk -F":" 'match($1, /(^[ \t]+UUID)/) {sub(/^[ \t]+/, "",
|
||||
boot_hs=$(${grub_probe} --device ${boot_device} --target="hints_string" 2>/dev/null) # hints string
|
||||
boot_fs=$(${grub_probe} --device ${boot_device} --target="fs" 2>/dev/null) # Type filesystem of boot device
|
||||
|
||||
# Enable LUKS encrypted devices support
|
||||
case "$(echo "$GRUB_BTRFS_ENABLE_CRYPTODISK" | tr '[:upper:]' '[:lower:]')" in
|
||||
true)
|
||||
list_insmods=()
|
||||
list_insmods+=("insmod gzio")
|
||||
list_insmods+=("insmod part_gpt")
|
||||
list_insmods+=("insmod cryptodisk")
|
||||
list_insmods+=("insmod luks")
|
||||
list_insmods+=("insmod gcry_rijndael")
|
||||
list_insmods+=("insmod gcry_rijndael")
|
||||
list_insmods+=("insmod gcry_sha256")
|
||||
list_insmods+=("insmod ${boot_fs}")
|
||||
list_insmods+=("cryptomount -u $(echo $GRUB_CMDLINE_LINUX_DEFAULT | grep -o -P '(?<=cryptdevice=UUID=).*(?=:cryptdev)')")
|
||||
;;
|
||||
*)
|
||||
list_insmods=("insmod ${boot_fs}")
|
||||
;;
|
||||
esac
|
||||
|
||||
## Parameters passed to the kernel
|
||||
kernel_parameters="$GRUB_CMDLINE_LINUX $GRUB_CMDLINE_LINUX_DEFAULT $GRUB_BTRFS_SNAPSHOT_KERNEL_PARAMETERS"
|
||||
## Mount point location
|
||||
@@ -218,8 +237,12 @@ make_menu_entries()
|
||||
if [ x\$feature_all_video_module = xy ]; then
|
||||
insmod all_video
|
||||
fi
|
||||
set gfxpayload=keep
|
||||
insmod ${boot_fs}
|
||||
set gfxpayload=keep"
|
||||
for j in "${insmods[@]}"; do
|
||||
entry "\
|
||||
${j}"
|
||||
done
|
||||
entry "\
|
||||
if [ x\$feature_platform_search_hint = xy ]; then
|
||||
search --no-floppy --fs-uuid --set=root ${boot_hs} ${boot_uuid}
|
||||
else
|
||||
@@ -541,6 +564,7 @@ boot_bounded()
|
||||
detect_rootflags
|
||||
title_format
|
||||
boot_dir_root_grub="$(make_system_path_relative_to_its_root "${boot_dir}")" # convert "boot_directory" to root of GRUB (e.g /boot become /)
|
||||
insmods=("${list_insmods[@]##*"/"}")
|
||||
make_menu_entries
|
||||
# show snapshot found during run "grub-mkconfig"
|
||||
if [ "${GRUB_BTRFS_SHOW_SNAPSHOTS_FOUND:-"true"}" = "true" ]; then
|
||||
|
||||
Reference in New Issue
Block a user