Bug#603944: retry mounting of root
Package: initramfs-tools
Version: 0.98
When using multipath, it is possible that mountroot() will race with
udev's renaming of /dev/disk/by-uuid/{rootfs-uuid} from /dev/sd?? to
/dev/mapper/something. After multipath has grabbed the /dev/sd?? and
until udev completes the rename, mounting
/dev/disk/by-uuid/{rootfs-uuid} will fail with -EBUSY.
Here is a patch I've been using successfully for awhile. Colin Watson
has suggested that:
> A poll/retry loop is generally a suboptimal way to do this kind of
> thing; what we really want is to wait for udev to tell us that it has
> finished with the event that triggered renaming of the device.
which does seem cleaner.
thanks,
-serge
diff -Nru initramfs-tools-0.98ubuntu2/debian/changelog initramfs-tools-0.98ubuntu3/debian/changelog
--- initramfs-tools-0.98ubuntu2/debian/changelog 2010-08-20 03:48:58.000000000 -0500
+++ initramfs-tools-0.98ubuntu3/debian/changelog 2010-08-24 22:31:31.000000000 -0500
@@ -1,3 +1,14 @@
+initramfs-tools (0.98ubuntu3) maverick; urgency=low
+
+ * Add retries to mountroot(). This is particularly needed when we
+ use multipath, because it is possible that mountroot() will race
+ with udev's renaming of /dev/disk/by-uuid/{rootfs-uuid} from
+ /dev/sd?? to /dev/mapper/something. After multipath has grabbed
+ the /dev/sd?? and until udev completes the rename, mounting
+ /dev/disk/by-uuid/{rootfs-uuid} will fail with -EBUSY.
+
+ -- Serge Hallyn <serge.hallyn@canonical.com> Tue, 24 Aug 2010 22:17:57 -0500
+
initramfs-tools (0.98ubuntu2) maverick; urgency=low
* The ramzswap device changed its interface so that the disk size needs to
diff -Nru initramfs-tools-0.98ubuntu2/scripts/local initramfs-tools-0.98ubuntu3/scripts/local
--- initramfs-tools-0.98ubuntu2/scripts/local 2010-08-20 03:48:58.000000000 -0500
+++ initramfs-tools-0.98ubuntu3/scripts/local 2010-08-24 22:16:17.000000000 -0500
@@ -86,10 +86,19 @@
# FIXME This has no error checking
[ -n "${FSTYPE}" ] && modprobe ${FSTYPE}
- # FIXME This has no error checking
# Mount root
- mount ${roflag} ${FSTYPE:+-t ${FSTYPE} }${ROOTFLAGS} ${ROOT} ${rootmnt}
- mountroot_status="$?"
+ tries=0
+ ret=1
+ while [ $tries -lt 10 -a $ret -ne 0 ]; do
+ mount ${roflag} ${FSTYPE:+-t ${FSTYPE} }${ROOTFLAGS} ${ROOT} ${rootmnt}
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ echo "failed attempt $tries to mount $ROOT as root"
+ sleep 1
+ tries=$((tries+1))
+ fi
+ done
+ mountroot_status=$ret
if [ "$LOOP" ]; then
if [ "$mountroot_status" != 0 ]; then
if [ ${FSTYPE} = ntfs ] || [ ${FSTYPE} = vfat ]; then
Reply to: