mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-28 17:11:34 +02:00
Merge pull request #2456 from flatcar/chewi/grub-mod
Free up /boot space with some GRUB module changes
This commit is contained in:
commit
ee027189d9
@ -41,7 +41,7 @@ switch_to_strict_mode
|
|||||||
GRUB_DIR="flatcar/grub/${FLAGS_target}"
|
GRUB_DIR="flatcar/grub/${FLAGS_target}"
|
||||||
|
|
||||||
# Modules required to boot a standard CoreOS configuration
|
# Modules required to boot a standard CoreOS configuration
|
||||||
CORE_MODULES=( normal search test fat part_gpt search_fs_uuid gzio search_part_label terminal gptprio configfile memdisk tar echo read btrfs )
|
CORE_MODULES=( normal search test fat part_gpt search_fs_uuid xzio search_part_label terminal gptprio configfile memdisk tar echo read btrfs )
|
||||||
|
|
||||||
SBAT_ARG=()
|
SBAT_ARG=()
|
||||||
|
|
||||||
@ -126,11 +126,21 @@ if [[ -z ${MOUNTED} ]]; then
|
|||||||
fi
|
fi
|
||||||
sudo mkdir -p "${ESP_DIR}/${GRUB_DIR}" "${ESP_DIR}/${GRUB_IMAGE%/*}"
|
sudo mkdir -p "${ESP_DIR}/${GRUB_DIR}" "${ESP_DIR}/${GRUB_IMAGE%/*}"
|
||||||
|
|
||||||
info "Compressing modules in ${GRUB_DIR}"
|
# Additional GRUB modules cannot be loaded with Secure Boot enabled, so only
|
||||||
for file in "${GRUB_SRC}"/*{.lst,.mod}; do
|
# copy and compress these for target that don't support it.
|
||||||
|
case "${FLAGS_target}" in
|
||||||
|
x86_64-efi|arm64-efi) : ;;
|
||||||
|
*)
|
||||||
|
info "Compressing modules in ${GRUB_DIR}"
|
||||||
|
for file in "${GRUB_SRC}"/*{.lst,.mod}; do
|
||||||
|
for core_mod in "${CORE_MODULES[@]}"; do
|
||||||
|
[[ ${file} == ${GRUB_SRC}/${core_mod}.mod ]] && continue 2
|
||||||
|
done
|
||||||
out="${ESP_DIR}/${GRUB_DIR}/${file##*/}"
|
out="${ESP_DIR}/${GRUB_DIR}/${file##*/}"
|
||||||
gzip --best --stdout "${file}" | sudo_clobber "${out}"
|
xz --stdout "${file}" | sudo_clobber "${out}"
|
||||||
done
|
done
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
info "Generating ${GRUB_DIR}/load.cfg"
|
info "Generating ${GRUB_DIR}/load.cfg"
|
||||||
# Include a small initial config in the core image to search for the ESP
|
# Include a small initial config in the core image to search for the ESP
|
||||||
@ -168,7 +178,7 @@ fi
|
|||||||
|
|
||||||
info "Generating ${GRUB_IMAGE}"
|
info "Generating ${GRUB_IMAGE}"
|
||||||
sudo grub-mkimage \
|
sudo grub-mkimage \
|
||||||
--compression=auto \
|
--compression=xz \
|
||||||
--format "${FLAGS_target}" \
|
--format "${FLAGS_target}" \
|
||||||
--directory "${GRUB_SRC}" \
|
--directory "${GRUB_SRC}" \
|
||||||
--config "${ESP_DIR}/${GRUB_DIR}/load.cfg" \
|
--config "${ESP_DIR}/${GRUB_DIR}/load.cfg" \
|
||||||
@ -177,10 +187,6 @@ sudo grub-mkimage \
|
|||||||
--output "${ESP_DIR}/${GRUB_IMAGE}" \
|
--output "${ESP_DIR}/${GRUB_IMAGE}" \
|
||||||
"${CORE_MODULES[@]}"
|
"${CORE_MODULES[@]}"
|
||||||
|
|
||||||
for mod in "${CORE_MODULES[@]}"; do
|
|
||||||
sudo rm "${ESP_DIR}/${GRUB_DIR}/${mod}.mod"
|
|
||||||
done
|
|
||||||
|
|
||||||
# Now target specific steps to make the system bootable
|
# Now target specific steps to make the system bootable
|
||||||
case "${FLAGS_target}" in
|
case "${FLAGS_target}" in
|
||||||
x86_64-efi|arm64-efi)
|
x86_64-efi|arm64-efi)
|
||||||
|
2
changelog/changes/2024-11-18-grub-modules.md
Normal file
2
changelog/changes/2024-11-18-grub-modules.md
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
- Additional GRUB modules are no longer installed for UEFI platforms to save space and also because they cannot be loaded with Secure Boot enabled. This does not affect existing installations.
|
||||||
|
- The GRUB modules on non-UEFI platforms are now compressed with xz rather than gzip to save even more space. This does not affect existing installations.
|
@ -12,6 +12,32 @@ cros_pre_src_prepare_adjust_version() {
|
|||||||
sed -i "/AC_INIT/s/\b${PV//./\\.}\b/\0-${FLATCAR_VERSION}/g" configure.ac || die
|
sed -i "/AC_INIT/s/\b${PV//./\\.}\b/\0-${FLATCAR_VERSION}/g" configure.ac || die
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Prevent developer test modules from being built. These are normally always
|
||||||
|
# installed, even by grub-install, but they have no use outside of testing and
|
||||||
|
# take up valuable space in /boot. The best way to identify these is to look for
|
||||||
|
# references to the tests/ directory.
|
||||||
|
cros_post_src_prepare_drop_tests() {
|
||||||
|
gawk -i inplace '
|
||||||
|
/^module = \{/ {
|
||||||
|
in_mod = 1
|
||||||
|
}
|
||||||
|
in_mod {
|
||||||
|
block = block $0 "\n"
|
||||||
|
}
|
||||||
|
/^\};/ && in_mod {
|
||||||
|
if (block !~ /\<tests\//) {
|
||||||
|
printf "%s", block
|
||||||
|
}
|
||||||
|
in_mod = 0
|
||||||
|
block = ""
|
||||||
|
next
|
||||||
|
}
|
||||||
|
!in_mod {
|
||||||
|
print
|
||||||
|
}
|
||||||
|
' grub-core/Makefile.core.def || die
|
||||||
|
}
|
||||||
|
|
||||||
# Replace Gentoo's SBAT with Flatcar's.
|
# Replace Gentoo's SBAT with Flatcar's.
|
||||||
cros_post_src_install_sbat() {
|
cros_post_src_install_sbat() {
|
||||||
insinto /usr/share/grub
|
insinto /usr/share/grub
|
||||||
|
Loading…
x
Reference in New Issue
Block a user