diff options
Diffstat (limited to 'files/firstboot/23-regenerate-initramfs.sh')
-rw-r--r-- | files/firstboot/23-regenerate-initramfs.sh | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/files/firstboot/23-regenerate-initramfs.sh b/files/firstboot/23-regenerate-initramfs.sh new file mode 100644 index 0000000..78e2922 --- /dev/null +++ b/files/firstboot/23-regenerate-initramfs.sh @@ -0,0 +1,31 @@ +logger -t "rc.firstboot" "Regenerating initramfs to remove encrypted root partition auto-expand" + +KERNEL_VERSION=$(uname -r) +KERNEL_ARCH=$(uname -m) +INITRAMFS="/boot/firmware/initramfs-${KERNEL_VERSION}" +INITRAMFS_UBOOT="${INITRAMFS}.uboot" + +# Extract kernel arch +case "${KERNEL_ARCH}" in + arm*) KERNEL_ARCH=arm ;; +esac + +# Regenerate initramfs +if [ -r "${INITRAMFS}" ] ; then + rm -f /etc/initramfs-tools/scripts/init-premount/expand_encrypted_rootfs + rm -f /etc/initramfs-tools/scripts/local-premount/expand-premount + rm -f /etc/initramfs-tools/hooks/expand-tools + rm -f "${INITRAMFS}" + mkinitramfs -o "${INITRAMFS}" "${KERNEL_VERSION}" +fi + +# Convert generated initramfs for U-Boot using mkimage +if [ -r "${INITRAMFS_UBOOT}" ] ; then + rm -f /etc/initramfs-tools/scripts/init-premount/expand_encrypted_rootfs + rm -f /etc/initramfs-tools/scripts/local-premount/expand-premount + rm -f /etc/initramfs-tools/hooks/expand-tools + rm -f "${INITRAMFS_UBOOT}" + mkinitramfs -o "${INITRAMFS}" "${KERNEL_VERSION}" + mkimage -A "${KERNEL_ARCH}" -T ramdisk -C none -n "initramfs-${KERNEL_VERSION}" -d "${INITRAMFS}" "${INITRAMFS_UBOOT}" + rm -f "${INITRAMFS}" +fi |