On Fri, Mar 01, 2013 at 07:50:37AM +0100, Daniel Baumann wrote:
> works with systemd, it's sysvinit specific.

Systemd skips the root file system check if the major device number of
the root file system is 0 (which is what btrfs reports):
http://cgit.freedesktop.org/systemd/systemd/tree/src/fsck/fsck.c#n297

The same could be done in sysvinit. Possible (untested) patch attached.
>From 70df7cd47d0950592ae95f61fa12ba066b36fd16 Mon Sep 17 00:00:00 2001
From: Nis Martensen <nis.marten...@web.de>
Date: Sun, 17 Mar 2013 13:28:16 +0100
Subject: [PATCH] Skip root filesystem check for btrfs file systems

For btrfs filesystems, checkroot.sh creates an invalid /run/rootdev
because btrfs reports an invalid device with stat(2). This is not a bug.
It results from the fact that btrfs filesystems can span multiple
devices, hence btrfs breaks the assumption that there is a one-to-one
relationship between device node and file system.

Links:
http://thread.gmane.org/gmane.comp.file-systems.btrfs/3508/
http://lists.gnu.org/archive/html/grub-devel/2010-05/msg00077.html

Checkroot.sh still assumes that one-to-one relationship and thus fails.
Make it skip filesystems with invalid (major=0) device number.

A related problem is that some administrators notice that there is no
fsck.btrfs provided by upstream and then try to create it by linking to
btrfsck. This will result in breakage:
 - btrfsck only works on unmounted file systems and does not work when
   the filesystem is mounted read-only
 - btrfsck does not support the standard fsck options

According to the btrfs wiki, it is safe to skip filesystem checks on
btrfs filesystems:
https://btrfs.wiki.kernel.org/index.php/FAQ#When_will_Btrfs_have_a_fsck_like_tool.3F

Therefore, even if there were a version of btrfs-tools that reports a
valid device, we should still skip btrfs file system checks.
---
 debian/src/initscripts/etc/init.d/checkroot.sh     |    5 ++++-
 debian/src/initscripts/lib/init/mount-functions.sh |    1 +
 2 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/debian/src/initscripts/etc/init.d/checkroot.sh b/debian/src/initscripts/etc/init.d/checkroot.sh
index fc261f3..8fab589 100755
--- a/debian/src/initscripts/etc/init.d/checkroot.sh
+++ b/debian/src/initscripts/etc/init.d/checkroot.sh
@@ -90,7 +90,10 @@ do_start () {
 		rdev="$(mountpoint -d /)"
 		if [ "$ddev" != "$rdev" ] && [ "$ddev" != "4:0" ]
 		then
-			if [ "$(mountpoint -qx /dev/root)" = "4:0" ]
+			if [ "${rdev%:*}" = "0" ]
+			then
+				rootcheck=no
+			elif [ "$(mountpoint -qx /dev/root)" = "4:0" ]
 			then
 				rootdev=/dev/root
 			else
diff --git a/debian/src/initscripts/lib/init/mount-functions.sh b/debian/src/initscripts/lib/init/mount-functions.sh
index 2ad4528..022b8dd 100644
--- a/debian/src/initscripts/lib/init/mount-functions.sh
+++ b/debian/src/initscripts/lib/init/mount-functions.sh
@@ -77,6 +77,7 @@ _read_fstab () {
 				echo roottype=\"$FSTYPE\"
 				( [ "$PASS" != 0 ] && [ "$PASS" != "" ]   ) && echo rootcheck=yes
 				( [ "$FSTYPE" = "nfs" ] || [ "$FSTYPE" = "nfs4" ] ) && echo rootcheck=no
+				( [ "$FSTYPE" = "btrfs" ] ) && echo rootcheck=no
 				case "$OPTS" in
 				  ro|ro,*|*,ro|*,ro,*)
 					echo rootmode=ro
-- 
1.7.2.5

Reply via email to