[Pkg-sysvinit-devel] Bug#697002: Bug#763157: initramfs-tools: Mounting /usr by initramfs-tools breaks checkfs.sh

Ben Hutchings ben at decadent.org.uk
Sun Sep 28 21:28:32 UTC 2014


On Sun, 2014-09-28 at 21:35 +0100, Roger Leigh wrote:
> On Sun, Sep 28, 2014 at 08:20:52PM +0100, Ben Hutchings wrote:
> > On Sun, 2014-09-28 at 19:44 +0100, Roger Leigh wrote:
> > > On Sun, Sep 28, 2014 at 06:49:49PM +0100, Ben Hutchings wrote:
> > > > Roger, please can you look at this?
> > > > 
> > > > Ben.
> > > > 
> > > > On Sun, 2014-09-28 at 11:41 +0200, Robert Luberda wrote:
> > > > > Package: initramfs-tools
> > > > > Version: 0.117
> > > > > Severity: critical
> > > > > Justification: breaks the whole system
> > > > > 
> > > > > Hi
> > > > > 
> > > > > After /usr is being mounted from initramfs, system is no longer
> > > > > bootable, because checkfs.sh script fails with:
> > > > > 
> > > > >   [....] Checking file systems...fsck from util-linux 2.20.1
> > > > >   /home2: clean, 166826/610800 files, 2350575/2441880 blocks
> > > > >   /home: clean, 120720/1831424 files, 3611320/3662820 blocks
> > > > >   /dev/sda5 is mounted.
> > > > >   e2fsck: Cannot continue, aborting.
> > > > > 
> > > > > 
> > > > >   fsck exited with status code 8
> > > > >   [....] File system check failed. A log is being saved in
> > > > >   /var/log/fsck/checkfs if that location is writable. Please repair the
> > > > >   f[FAILystem manually. ... failed!
> > > > >
> > > > > The contents of /var/log/fsck/checkfs is:
> > > > > 
> > > > >   Log of fsck -C -R -A -a 
> > > 
> > > Has there been an update to util-linux to make the above -R option
> > > skip checking /usr in addition to the rootfs?  That was a
> > > prerequisite for mounting /usr in the initramfs.
> > 
> > Aaaaaaaaargh.  No.  And that doesn't fix the problem because we have to
> > support partial upgrades.
> > 
> > Where is the bug report on util-linux?
> 
> Ah, found it as:
> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=697002
> 
> For some reason it's been reassigned to initscripts.  Not sure I
> agree with the rationale of not patching util-linux; this looks
> like it breaks the non-initramfs boot case since it won't fsck
> a mounted rootfs with -M?  It was never the intention of this
> work to make an initramfs mandatory.

I've tested this patch against util-linux/unstable:

---
fsck: Skip mounted /usr if skipping root

sysvinit runs 'fsck -R -A' at boot time to check all filesystems
except root.  However, /usr may also have been mounted (and fscked) by
the initramfs.  In this case we should quietly skip /usr as well as
root.

--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -1131,12 +1131,18 @@ static int check_all(void)
 		}
 	}
 	/*
-	 * This is for the bone-headed user who enters the root
-	 * filesystem twice.  Skip root will skep all root entries.
+	 * If skip_root is set, mark all root entries as done in case
+	 * the root filesystem is listed twice.
+	 *
+	 * If an initramfs has been used, it may have mounted and
+	 * fscked both root and /usr to avoid dependency loops later
+	 * on.  So also skip /usr if it is already mounted.
 	 */
 	if (skip_root)
 		for (fs = filesys_info; fs; fs = fs->next)
-			if (!strcmp(fs->mountpt, "/"))
+			if (strcmp(fs->mountpt, "/") == 0 ||
+			    (strcmp(fs->mountpt, "/usr") == 0 &&
+			     is_mounted(fs->device)))
 				fs->flags |= FLAG_DONE;
 
 	while (not_done_yet) {
--- END ---

(The manual page should also be updated.)

A similar patch should be applicable to util-linux 2.25, so I don't
believe this increases the work for util-linux maintenance:

---
fsck: Skip mounted /usr if skipping root

sysvinit runs 'fsck -R -A' at boot time to check all filesystems
except root.  However, /usr may also have been mounted (and fscked) by
the initramfs.  In this case we should quietly skip /usr as well as
root.

--- a/disk-utils/fsck.c
+++ b/disk-utils/fsck.c
@@ -1259,8 +1259,12 @@ static int check_all(void)
 	}
 
 	/*
-	 * This is for the bone-headed user who enters the root
-	 * filesystem twice.  Skip root will skep all root entries.
+	 * If skip_root is set, mark all root entries as done in case
+	 * the root filesystem is listed twice.
+	 *
+	 * If an initramfs has been used, it may have mounted and
+	 * fscked both root and /usr to avoid dependency loops later
+	 * on.  So also skip /usr if it is already mounted.
 	 */
 	if (skip_root) {
 		mnt_reset_iter(itr, MNT_ITER_FORWARD);
@@ -1268,7 +1272,9 @@ static int check_all(void)
 		while(mnt_table_next_fs(fstab, itr, &fs) == 0) {
 			const char *tgt = mnt_fs_get_target(fs);
 
-			if (tgt && strcmp(tgt, "/") == 0)
+			if (tgt &&
+			    (strcmp(tgt, "/") == 0 ||
+			     (strcmp(tgt, "/usr") == 0 && is_mounted(fs))))
 				fs_set_done(fs);
 		}
 	}
--- END ---

Anyway, we'll still need some way for the initramfs to work out whether
fsck or initscripts is fixed and avoid mounting /usr if not.

Ben.

-- 
Ben Hutchings
This sentence contradicts itself - no actually it doesn't.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 811 bytes
Desc: This is a digitally signed message part
URL: <http://lists.alioth.debian.org/pipermail/pkg-sysvinit-devel/attachments/20140928/3b7d63e0/attachment.sig>


More information about the Pkg-sysvinit-devel mailing list