summaryrefslogtreecommitdiff
path: root/update-initramfs
diff options
context:
space:
mode:
authorLuke Yelavich <luke.yelavich@canonical.com>2008-04-08 16:52:23 +1000
committermaximilian attems <max@stro.at>2008-04-08 10:47:20 +0200
commitcf1cb624d74422f64fb68c28fa99039b9f716c9c (patch)
tree7c1fd76c9857ac987609c41376ee0d340e047c35 /update-initramfs
parentaaf9b600c8ed9055b4e283e6cf1394b6f9f6ac8e (diff)
downloadinitramfs-tools-cf1cb624d74422f64fb68c28fa99039b9f716c9c.tar.gz
initramfs-tools-cf1cb624d74422f64fb68c28fa99039b9f716c9c.zip
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 ]
Diffstat (limited to 'update-initramfs')
-rwxr-xr-xupdate-initramfs9
1 files changed, 6 insertions, 3 deletions
diff --git a/update-initramfs b/update-initramfs
index 6e8e7aa..a4947bf 100755
--- a/update-initramfs
+++ b/update-initramfs
@@ -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