[LEDE-DEV] [PATCH] fstools: add extroot btrfs support to block-mount

Robert Young yayooo at gmail.com
Sun Jun 25 07:35:08 PDT 2017


Post Installation Checks:

root at LEDE:/# strings mtdblock6/upper/sbin/block | grep ext4 | grep f2fs
extroot: unsupported filesystem %s, try ext4, f2fs, btrfs or ubifs
root at LEDE:/#

root at LEDE:/# cat mtdblock6/upper/etc/config/fstab
config 'global'
option anon_swap '0'
option anon_mount '0'
option auto_swap '0'
option auto_mount '1'
option delay_root '5'
option check_fs '0'

config 'mount'
option device '/dev/sda2'
option target '/overlay'
option fstype 'btrfs'
option options 'rw,noatime,async,compress-force=zlib,ssd,noacl,space_cache,subvol=/OpenWrt'
option enabled '1'
option enabled_fsck '0'
option is_rootfs '1'

root at LEDE:/#

root at LEDE:/# mount
/dev/mtdblock5 on /rom type squashfs (ro,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,noatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,noatime)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime)
/dev/sda2 on /overlay type btrfs
(rw,noatime,compress-force=zlib,ssd,noacl,space_cache,subvolid=257,subvol=/OpenWrt)
overlayfs:/overlay on / type overlay
(rw,noatime,lowerdir=/,upperdir=/overlay/upper,workdir=/overlay/work)
tmpfs on /dev type tmpfs (rw,nosuid,relatime,size=512k,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,mode=600)
root at LEDE:/#

root at LEDE:/# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                 2.3M      2.3M         0 100% /rom
tmpfs                   251.1M    768.0K    250.3M   0% /tmp
/dev/sda2                28.4G    144.4M     28.0G   1% /overlay
overlayfs:/overlay       28.4G    144.4M     28.0G   1% /
tmpfs                   512.0K         0    512.0K   0% /dev
root at LEDE:/#

# https://git.lede-project.org/project/fstools.git

Signed-off-by: Robert Young <yayooo at gmail.com>
---
 block.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/block.c b/block.c
index d5c3937..3424462 100644
--- a/block.c
+++ b/block.c
@@ -707,6 +707,7 @@ static void check_filesystem(struct probe_info *pr)
        struct stat statbuf;
        const char *e2fsck = "/usr/sbin/e2fsck";
        const char *f2fsck = "/usr/sbin/fsck.f2fs";
+       const char *btrfsck = "/usr/bin/btrfsck";
        const char *dosfsck = "/usr/sbin/dosfsck";
        const char *ckfs;

@@ -718,6 +719,8 @@ static void check_filesystem(struct probe_info *pr)
                ckfs = dosfsck;
        } else if (!strncmp(pr->type, "f2fs", 4)) {
                ckfs = f2fsck;
+       } else if (!strncmp(pr->type, "btrfs", 5)) {
+               ckfs = btrfsck;
        } else if (!strncmp(pr->type, "ext", 3)) {
                ckfs = e2fsck;
        } else {
@@ -735,6 +738,9 @@ static void check_filesystem(struct probe_info *pr)
                if(!strncmp(pr->type, "f2fs", 4)) {
                        execl(ckfs, ckfs, "-f", pr->dev, NULL);
                        exit(-1);
+               } else if(!strncmp(pr->type, "btrfs", 5)) {
+                       execl(ckfs, ckfs, "--repair", pr->dev, NULL);
+                       exit(-1);
                } else {
                        execl(ckfs, ckfs, "-p", pr->dev, NULL);
                        exit(-1);
@@ -1428,8 +1434,9 @@ static int mount_extroot(char *cfg)
        if (pr) {
                if (strncmp(pr->type, "ext", 3) &&
                    strncmp(pr->type, "f2fs", 4) &&
+                   strncmp(pr->type, "btrfs", 5) &&
                    strncmp(pr->type, "ubifs", 5)) {
-                       ULOG_ERR("extroot: unsupported filesystem %s,
try ext4, f2fs or ubifs\n", pr->type);
+                       ULOG_ERR("extroot: unsupported filesystem %s,
try ext4, f2fs, btrfs or ubifs\n", pr->type);
                        return -1;
                }

--
2.13.1



More information about the Lede-dev mailing list