mount /tmp as tmpfs && Use /tmp when update-initramfs (#4185)

* mount `/tmp` as `tmpfs` when chroot

* Use `/tmp` instand of `/var/tmp` when `update-initramfs`
This commit is contained in:
hzyitc 2022-09-14 23:21:37 +08:00 committed by GitHub
parent 1ad2e6aeb0
commit d54ebcbab4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 3 deletions

View File

@ -101,7 +101,7 @@ pre_umount_final_image__install_grub() {
}
fi
local install_grub_cmdline="update-initramfs -c -k all && update-grub && grub-install --verbose --target=${UEFI_GRUB_TARGET} --no-nvram --removable" # nvram is global to the host, even across chroot. take care.
local install_grub_cmdline="update-grub && grub-install --verbose --target=${UEFI_GRUB_TARGET} --no-nvram --removable" # nvram is global to the host, even across chroot. take care.
display_alert "Installing GRUB EFI..." "${UEFI_GRUB_TARGET}" ""
chroot "$chroot_target" /bin/bash -c "$install_grub_cmdline" >>"$DEST"/"${LOG_SUBPATH}"/install.log 2>&1 || {
exit_with_error "${install_grub_cmdline} failed!"

View File

@ -763,7 +763,7 @@ update_initramfs()
find ${chroot_target}/lib/modules/ -maxdepth 1 -type d -name "*${VER}*"
)
if [ "$target_dir" != "" ]; then
update_initramfs_cmd="update-initramfs -uv -k $(basename $target_dir)"
update_initramfs_cmd="TMPDIR=/tmp update-initramfs -uv -k $(basename $target_dir)"
else
exit_with_error "No kernel installed for the version" "${VER}"
fi

View File

@ -33,6 +33,7 @@ mount_chroot()
{
local target=$1
mount -t tmpfs tmpfs "${target}/tmp"
mount -t proc chproc "${target}"/proc
mount -t sysfs chsys "${target}"/sys
mount -t devtmpfs chdev "${target}"/dev || mount --bind /dev "${target}"/dev
@ -52,11 +53,12 @@ umount_chroot()
local target=$1
display_alert "Unmounting" "$target" "info"
while grep -Eq "${target}.*(dev|proc|sys)" /proc/mounts
while grep -Eq "${target}/*(dev|proc|sys|tmp)" /proc/mounts
do
umount -l --recursive "${target}"/dev >/dev/null 2>&1
umount -l "${target}"/proc >/dev/null 2>&1
umount -l "${target}"/sys >/dev/null 2>&1
umount -l "${target}"/tmp >/dev/null 2>&1
sleep 5
done