mirror of
https://salsa.debian.org/kernel-team/initramfs-tools.git
synced 2026-01-26 15:39:08 +00:00
update-initramfs: Initramfs generation reliability fixes.
Attached is a patch to improve the way update-initramfs handles the generating of new or updated initramfs images for kernels. It puts in place a few measures to ensure that if there is not enough disk space on /boot, a previous initramfs is still in tact, to allow the booting of that kernel. The patch applies against current git head. See the Ubuntu specification found at the following URL for more information: https://wiki.ubuntu.com/HardyInitramfsErrorHandling This patch does the following: * When generating a new initramfs, instead of copying the old initramfs to a backup file, it hard links it instead, so no more space is used than necessary. it only copies to the backup file in the event that the filesystem on /boot doesn't support hard links, eg FAT32 partitions. * A new file is used to generate the initramfs. If the generation succeeds, it is moved to the original initramfs's location, ready to use. If it fails, the original initramfs is not affected, allowing it to be used at boot. [ wrap on long line -maks ]
This commit is contained in:
parent
aaf9b600c8
commit
cf1cb624d7
@ -100,7 +100,8 @@ backup_initramfs()
|
||||
[ ! -r "${initramfs}" ] && return 0
|
||||
initramfs_bak="${initramfs}.dpkg-bak"
|
||||
[ -r "${initramfs_bak}" ] && rm -f "${initramfs_bak}"
|
||||
mv -f "${initramfs}" "${initramfs_bak}"
|
||||
ln -f "${initramfs}" "${initramfs_bak}" \
|
||||
|| cp -a "${initramfs}" "${initramfs_bak}"
|
||||
verbose "Keeping ${initramfs_bak}"
|
||||
}
|
||||
|
||||
@ -143,8 +144,8 @@ backup_booted_initramfs()
|
||||
restore_initramfs()
|
||||
{
|
||||
[ -z "${initramfs_bak}" ] && return 0
|
||||
rm -f "${initramfs_bak}"
|
||||
verbose "Restoring ${initramfs_bak}"
|
||||
mv -f "${initramfs_bak}" "${initramfs}"
|
||||
}
|
||||
|
||||
|
||||
@ -155,11 +156,13 @@ generate_initramfs()
|
||||
if [ "${verbose}" = 1 ]; then
|
||||
OPTS="-v ${OPTS}"
|
||||
fi
|
||||
if mkinitramfs ${OPTS} "${initramfs}" "${version}"; then
|
||||
if mkinitramfs ${OPTS} "${initramfs}.new" "${version}"; then
|
||||
mv -f "${initramfs}.new" "${initramfs}"
|
||||
set_sha1
|
||||
else
|
||||
mkinitramfs_return="$?"
|
||||
restore_initramfs
|
||||
rm -f "${initramfs}.new"
|
||||
if [ "$mkinitramfs_return" = "2" ]; then
|
||||
# minversion wasn't met, exit 0
|
||||
exit 0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user