Add Extroot Btrfs Support - vanaware/openwrt GitHub Wiki
Add Extroot Btrfs Support to Block-mount
link: http://lists.infradead.org/pipermail/lede-dev/2017-June/008117.html
link: https://openwrt.org/docs/guide-developer/feeds
link: https://wiki.openwrt.org/doc/howtobuild/single.package
link: https://wiki.openwrt.org/doc/howto/build.a.package
Change fstools makefile to newer version
link: https://git.openwrt.org/?p=project/fstools.git;a=commit
Link ahead has most updated version of fstools
Take note of commit dd02dad332958575cc52e60c78ef10ef2b5aaced
Change file Makefile
cd ~/openwrt
git pull
./scripts/feeds clean
./scripts/feeds update -a
./scripts/feeds install -a
make dirclean
wget https://downloads.lede-project.org/releases/17.01.4/targets/ar71xx/generic/config.seed
cp config.seed .config
make defconfig
make package/symlinks
make menuconfig -> check M or * for block-mount
make download
FORCE_UNSAFE_CONFIGURE=1 make -j5 V=s tools/install
FORCE_UNSAFE_CONFIGURE=1 make -j5 V=s toolchain/install
FORCE_UNSAFE_CONFIGURE=1 make -j5 V=s target/compile
nano package/system/fstools/Makefile
#PKG_SOURCE_VERSION:=bdcb075fafdac0bfe3207c23f64acd58432bad86
PKG_SOURCE_VERSION:=dd02dad332958575cc52e60c78ef10ef2b5aaced
FORCE_UNSAFE_CONFIGURE=1 make -j5 V=s package/fstools/prepare
cd build_dir/target-mips_24kc_musl-1.1.16/fstools-2017-06-30-dd02dad3/
Or Step into source file
cd build_dir/target-mips_24kc_musl-1.1.16/fstools-2017-06-30-bdcb075f/
nano block.c
./scripts/feeds install block-mount
FORCE_UNSAFE_CONFIGURE=1 make -j5 V=s package/fstools/compile
FORCE_UNSAFE_CONFIGURE=1 make -j5 V=s package/fstools/install
FORCE_UNSAFE_CONFIGURE=1 make -j5 V=s package/fstools/index
Change file block.c
--- 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;
}