[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#468112: Initramfs generation reliability fixes.

Sorry I haven't gotten back to you until now.

On Tue, Apr 01, 2008 at 07:53:44AM EST, maximilian attems wrote:
> On Wed, 27 Feb 2008, Luke Yelavich wrote:
> > 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
> okay,
> i still don't understands belows patch.

Gah the patch is the wrong way around. here is a corrected patch, along with another change we've introduced since I originally filed the bug.

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.

Hope this makes sense now. :)

--- initramfs-tools/update-initramfs	2008-04-08 16:23:29.209995377 +1000
+++ initramfs-tools/update-initramfs	2008-04-08 16:42:25.861995377 +1000
@@ -100,7 +85,7 @@
 	[ ! -r "${initramfs}" ] && return 0
 	[ -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 +128,8 @@
 	[ -z "${initramfs_bak}" ] && return 0
+	rm -f "${initramfs_bak}"
 	verbose "Restoring ${initramfs_bak}"
-	mv -f "${initramfs_bak}" "${initramfs}"
@@ -155,11 +140,13 @@
 	if [ "${verbose}" = 1 ]; then
 		OPTS="-v ${OPTS}"
-	if mkinitramfs ${OPTS} "${initramfs}" "${version}"; then
+	if mkinitramfs ${OPTS} "${initramfs}.new" "${version}"; then
+		mv -f "${initramfs}.new" "${initramfs}"
+		rm -f "${initramfs}.new"
 		if [ "$mkinitramfs_return" = "2" ]; then
 			# minversion wasn't met, exit 0
 			exit 0

Attachment: signature.asc
Description: Digital signature

Reply to: