From: Lars R. Damerow Date: Thu, 21 Feb 2013 21:40:23 +0000 (-0800) Subject: dracut: write initramfs to temp file then move into place X-Git-Tag: 026~51 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9a9c6e1256c7185630fa94bb63ac0bb666a5af34;p=thirdparty%2Fdracut.git dracut: write initramfs to temp file then move into place We've been finding cases where multiple instances of dracut can be launched simultaneously, resulting in a corrupted initramfs file. This patch makes dracut write the initramfs to a new file, then move it into place atomically. --- diff --git a/dracut.sh b/dracut.sh index 31cf2a5fc..da96aaa52 100755 --- a/dracut.sh +++ b/dracut.sh @@ -1103,10 +1103,11 @@ fi rm -f "$outfile" dinfo "*** Creating image file ***" if ! ( umask 077; cd "$initdir"; find . |cpio -R 0:0 -H newc -o --quiet| \ - $compress > "$outfile"; ); then - dfatal "dracut: creation of $outfile failed" + $compress > "$outfile.$$"; ); then + dfatal "dracut: creation of $outfile.$$ failed" exit 1 fi +mv $outfile.$$ $outfile dinfo "*** Creating image file done ***" dinfo "Wrote $outfile:"