Skip to contentSkip to conversation

- ignore bind mounts in fsck

PATCH In review Eric Sandeen 2 participants 7 messages Sep 19, 2007 – Sep 20, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 - ignore bind mounts in fsck

An entry like this in /etc/fstab:

/foo /bar ext3 bind,defaults 1 3

will stop boot, as fsck.ext3 tries to check it and fails:

e2fsck 1.40.2 (12-Jul-2007)
fsck.ext3: Is a directory while trying to open /foo

The superblock could not be read or does not describe a correct ext2 filesystem. ...

Granted, asking for fsck of a bind mount in the fstab is a bit odd, but it doesn't seem like it should stop the boot process if you make this mistake.

misc/fsck.c +6 -0
Index: e2fsprogs-1.40.2/misc/fsck.c
===================================================================
@@ -867,6 +867,12 @@ static int ignore(struct fs_info *fs)
 	if (fs->passno == 0)
 		return 1;
 
+	/*
+	 * If this is a bind mount, ignore it.
+	 */
+	if (opt_in_list("bind", fs->opts))
+		return 1;
+
 	interpret_type(fs);
 
 	/*
#1 lore raw
Quoted 9 lines · Eric Sandeen

An entry like this in /etc/fstab:

/foo /bar ext3 bind,defaults 1 3

will stop boot, as fsck.ext3 tries to check it and fails:

e2fsck 1.40.2 (12-Jul-2007)
fsck.ext3: Is a directory while trying to open /foo

Quoted 6 lines

The superblock could not be read or does not describe a correct ext2 filesystem. ...

Granted, asking for fsck of a bind mount in the fstab is a bit odd, but it doesn't seem like it should stop the boot process if you make this mistake.

That's fair, but note that the dump number and fsck pass number really should be zero in the fstab entry. i.e., it really should be "0 0", or just plain ommitted.

- Ted

#2 lore raw
Quoted 13 lines · Theodore Tso
Quoted 12 lines · Eric Sandeen

An entry like this in /etc/fstab:

/foo /bar ext3 bind,defaults 1 3

will stop boot, as fsck.ext3 tries to check it and fails:

e2fsck 1.40.2 (12-Jul-2007)
fsck.ext3: Is a directory while trying to open /foo

The superblock could not be read or does not describe a correct ext2 filesystem. ...

Quoted 7 lines
Quoted 3 lines

Granted, asking for fsck of a bind mount in the fstab is a bit odd, but it doesn't seem like it should stop the boot process if you make this mistake.

That's fair, but note that the dump number and fsck pass number really should be zero in the fstab entry. i.e., it really should be "0 0", or just plain ommitted.

Agreed. If you think fsck shouldn't silently cope with this mistake, and instead punish the user for it (it is what they asked for, after all), I'm ok with that too. I'm willing to close my end as NOTABUG if you don't want to take this patch. :)

(FWIW, this is RH bug #151533)

-Eric

#3 lore raw
Quoted 4 lines · Eric Sandeen

Agreed. If you think fsck shouldn't silently cope with this mistake, and instead punish the user for it (it is what they asked for, after all), I'm ok with that too. I'm willing to close my end as NOTABUG if you don't want to take this patch. :)

I'm willing to take the patch, although I am thinking that it might be appropriate for fsck to print a warning message --- "Bind mount with non-zero fsck pass, skipping", or some such.

What do you think?

- Ted

#4 lore raw
Quoted 8 lines · Theodore Tso
Quoted 5 lines · Eric Sandeen

Agreed. If you think fsck shouldn't silently cope with this mistake, and instead punish the user for it (it is what they asked for, after all), I'm ok with that too. I'm willing to close my end as NOTABUG if you don't want to take this patch. :)

Quoted 8 lines

I'm willing to take the patch, although I am thinking that it might be appropriate for fsck to print a warning message --- "Bind mount with non-zero fsck pass, skipping", or some such.

What do you think?

- Ted

Yup, was thinking the same.

----------------

An entry like this in /etc/fstab:

/foo /bar ext3 bind,defaults 1 3

will stop boot, as fsck.ext3 tries to check it and fails:

e2fsck 1.40.2 (12-Jul-2007)
fsck.ext3: Is a directory while trying to open /foo

The superblock could not be read or does not describe a correct ext2 filesystem. ...

Granted, asking for fsck of a bind mount in the fstab is a bit odd, but it doesn't seem like it should stop the boot process if you make this mistake.

misc/fsck.c +10 -0
Index: e2fsprogs-1.40.2/misc/fsck.c
===================================================================
@@ -867,6 +867,16 @@ static int ignore(struct fs_info *fs)
 	if (fs->passno == 0)
 		return 1;
 
+	/*
+	 * If this is a bind mount, ignore it.
+	 */
+	if (opt_in_list("bind", fs->opts)) {
+		fprintf(stderr,
+			_("Skipping bind mount on %s with nonzero fsck pass\n"),
+			fs->mountpt);
+		return 1;
+	}
+
 	interpret_type(fs);
 
 	/*
#5 lore raw

It might also be worthwhile to file a documentation bug against the mount and fstab man pages, since it doesn't currently seem to specify (at least on my Ubuntu system; maybe it's been fixed in newer upstream packages) that you can specify the bind option in the fstab file.

/src /dest ext3 bind,default

It's not clear to me that this should be the preferred form. Why not?

/src /dest bind defaults

or

/src /dest none bind,defaults

instead? In any case, how bind mounts are supposed to be specified in fstab is not documented, and it really should be.

- Ted

#6 lore raw
In reply to Eric Sandeen

This is what I actually committed into e2fsprogs git, in the maint branch. Note the one-line summary at the beginning of the patch description, and the Addresses-Red-Hat-Bugzilla line before the Signed-off-by lines.

- Ted

commit ed773a263829493e4e4bf612dbec2380cf09349f

Author: Theodore Ts'o <[email protected]>
Date:   Thu Sep 20 15:06:35 2007 -0400

fsck: Ignore /etc/fstab entries for bind mounts

If a user specifies a bind mount with a non-zero fsck pass number, for example:

/foo /bar ext3 bind,defaults 1 3

print a warning and ignore the fstab entry.

Addresses-Red-Hat-Bugzilla: #151533

misc/fsck.c +10 -0
index 1dcac25..108adf6 100644
@@ -867,6 +867,16 @@ static int ignore(struct fs_info *fs)
 	if (fs->passno == 0)
 		return 1;
 
+	/*
+	 * If this is a bind mount, ignore it.
+	 */
+	if (opt_in_list("bind", fs->opts)) {
+		fprintf(stderr,
+			_("%s: skipping bad line in /etc/fstab: bind mount with nonzero fsck pass number\n"),
+			fs->mountpt);
+		return 1;
+	}
+
 	interpret_type(fs);
 
 	/*