Re: [OpenWrt-Devel] [PATCH] fstools: block: make extroot mount preparation more robust
On 09.04.2019 20:08, Kenneth J. Miller wrote: The extroot mount preparation code for r/w rootfs overlay discovery, and determining the user-defined /etc/config/fstab location within, would only discover overlays residing on JFFS2 or UBIFS MTD storage. This led to attempts at loading the uci fstab configuration without the required /tmp/overlay directory prefix on devices with a non-MTD r/w rootfs overlay, and thus failure to find any custom fstab /overlay extroot entries on PREINIT. (example: the default openwrt eMMC partition layout on the zyxel nbg6817) Futher, with UBIFS_EXTROOT enabled (fstools package default), and no MTD rootfs partitions present, check_extroot would not attempt rootfs discovery on block devices, such as the ext4 mmcblk rootfs overlay on the nbg6817. With this patch: 1) main_extroot now attempts to load uci fstab configuration from an already mounted overlay, before defaulting to the prefix-less uci config dir when no MTD rootfs partitions are detected. 2) check_extroot now also attempts to find rootfs partitions on block > devices when no MTD rootfs partitions are detected. There were some questions about this old patch on IRC so I took a moment to review it (finally). It touches some rarely used code and there are no enough experienced people who remember how it's supposed to work. block.c | 17 + 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/block.c b/block.c index 39212d2..3dfc4a5 100644 --- a/block.c +++ b/block.c @@ -1301,7 +1301,7 @@ static int find_block_ubi_RO(libubi_t libubi, char *name, char *part, int plen) return err; } -#else +#endif static int find_root_dev(char *buf, int len) { @@ -1332,8 +1332,6 @@ static int find_root_dev(char *buf, int len) return -1; } -#endif - static int test_fs_support(const char *name) { char line[128], *p; @@ -1363,25 +1361,20 @@ static int check_extroot(char *path) struct probe_info *pr = NULL; char devpath[32]; -#ifdef UBIFS_EXTROOT if (find_block_mtd("\"rootfs\"", devpath, sizeof(devpath))) { int err = -1; +#ifdef UBIFS_EXTROOT libubi_t libubi; libubi = libubi_open(); err = find_block_ubi_RO(libubi, "rootfs", devpath, sizeof(devpath)); libubi_close(libubi); - if (err) - return -1; - } -#else - if (find_block_mtd("\"rootfs\"", devpath, sizeof(devpath))) { - if (find_root_dev(devpath, sizeof(devpath))) { +#endif + if (err && find_root_dev(devpath, sizeof(devpath))) { ULOG_ERR("extroot: unable to determine root device\n"); return -1; } } -#endif list_for_each_entry(pr, , list) { if (!strcmp(pr->dev, devpath)) { @@ -1585,7 +1578,7 @@ static int main_extroot(int argc, char **argv) } #endif - return mount_extroot(NULL); + return mount_extroot("/tmp/overlay"); Did you consider consequences of this change? This breaks reading /etc/config/fstab from "rootfs" partition. You need to handle your case properly (carefully). Please don't suggest random change that just happen to work for your scenario. ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH] fstools: block: make extroot, mount preparation more robust
On Tue, 9 Apr 2019 at 14:08, Kenneth J. Miller wrote: The extroot mount preparation code for r/w rootfs overlay discovery, and determining the user-defined /etc/config/fstab location within, would only discover overlays residing on JFFS2 or UBIFS MTD storage. This led to attempts at loading the uci fstab configuration without the required /tmp/overlay directory prefix on devices with a non-MTD r/w rootfs overlay, and thus failure to find any custom fstab /overlay extroot entries on PREINIT. (example: the default openwrt eMMC partition layout on the zyxel nbg6817) Futher, with UBIFS_EXTROOT enabled (fstools package default), and no MTD rootfs partitions present, check_extroot would not attempt rootfs discovery on block devices, such as the ext4 mmcblk rootfs overlay on the nbg6817. With this patch: 1) main_extroot now attempts to load uci fstab configuration from an already mounted overlay, before defaulting to the prefix-less uci config dir when no MTD rootfs partitions are detected. 2) check_extroot now also attempts to find rootfs partitions on block devices when no MTD rootfs partitions are detected. Fixes: FS#2231 Ref:https://bugs.openwrt.org/index.php?do=details_id=2231 Signed-off-by: Kenneth J. Miller This patch makes it possible to mount extroot overlay on x86_64. Tested-by: Val Kulkov Thanks for testing my patch on another platform Val. The patch is quite small and only expands the code paths that can be taken by extroot mount detection without removing any existing potential conditions on raw MTD or UBI extroots, it'd be nice if it could get merged. Any comments are appreciated. ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH] fstools: block: make extroot mount preparation more robust
On Tue, 9 Apr 2019 at 14:08, Kenneth J. Miller wrote: > > The extroot mount preparation code for r/w rootfs overlay discovery, and > determining the user-defined /etc/config/fstab location within, would only > discover overlays residing on JFFS2 or UBIFS MTD storage. > > This led to attempts at loading the uci fstab configuration without the > required /tmp/overlay directory prefix on devices with a non-MTD r/w > rootfs overlay, and thus failure to find any custom fstab /overlay extroot > entries on PREINIT. > (example: the default openwrt eMMC partition layout on the zyxel nbg6817) > > Futher, with UBIFS_EXTROOT enabled (fstools package default), and no MTD > rootfs partitions present, check_extroot would not attempt rootfs > discovery on block devices, such as the ext4 mmcblk rootfs overlay on the > nbg6817. > > With this patch: > 1) main_extroot now attempts to load uci fstab configuration from an >already mounted overlay, before defaulting to the prefix-less uci >config dir when no MTD rootfs partitions are detected. > 2) check_extroot now also attempts to find rootfs partitions on block >devices when no MTD rootfs partitions are detected. > > Fixes: FS#2231 > Ref: https://bugs.openwrt.org/index.php?do=details_id=2231 > Signed-off-by: Kenneth J. Miller This patch makes it possible to mount extroot overlay on x86_64. Tested-by: Val Kulkov ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH] fstools: block: make extroot mount preparation more robust
Val Kulkov [2019-05-14 17:03:11]: > The patch was proposed last month by Kenneth Miller [1]. It enables > extroot on x86_64-based devices. I confirm that the patch does what it > claims. The issue with extroot on x86_64 devices is described in > FS#2231 [2]. Then you should reply to that email[1] with your `Tested-by` tag[3], so the potential reviewer knows, that it has been actually tested and that there's some interest to get this fixed and merged. > Any possibility to see this patch in the trunk any time soon? You know, day has just 42 hours :-) > [1] http://lists.infradead.org/pipermail/openwrt-devel/2019-April/016654.html > [2] https://bugs.openwrt.org/index.php?do=details_id=2231 [3] https://www.kernel.org/doc/html/latest/process/submitting-patches.html#using-reported-by-tested-by-reviewed-by-suggested-by-and-fixes -- ynezz ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH] fstools: block: make extroot mount preparation more robust
The patch was proposed last month by Kenneth Miller [1]. It enables extroot on x86_64-based devices. I confirm that the patch does what it claims. The issue with extroot on x86_64 devices is described in FS#2231 [2]. Any possibility to see this patch in the trunk any time soon? With this patch, one can use extroot to claim the remaining space on /dev/sda and store data on it. Sysupgrade of a x86_64 system remains a tricky business however. For sysupgrade, I am currently using dd to copy OpenWrt boot partition and squashfs partitions onto the target drive and then using dd to copy the MBR bootstrap only, without the partition table: "dd if=/dev/sdc of=/dev/sda bs=446 count=1". This procedure retains the partition layout on the target drive. [1] http://lists.infradead.org/pipermail/openwrt-devel/2019-April/016654.html [2] https://bugs.openwrt.org/index.php?do=details_id=2231 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH] fstools: block: make extroot mount preparation more robust
The extroot mount preparation code for r/w rootfs overlay discovery, and determining the user-defined /etc/config/fstab location within, would only discover overlays residing on JFFS2 or UBIFS MTD storage. This led to attempts at loading the uci fstab configuration without the required /tmp/overlay directory prefix on devices with a non-MTD r/w rootfs overlay, and thus failure to find any custom fstab /overlay extroot entries on PREINIT. (example: the default openwrt eMMC partition layout on the zyxel nbg6817) Futher, with UBIFS_EXTROOT enabled (fstools package default), and no MTD rootfs partitions present, check_extroot would not attempt rootfs discovery on block devices, such as the ext4 mmcblk rootfs overlay on the nbg6817. With this patch: 1) main_extroot now attempts to load uci fstab configuration from an already mounted overlay, before defaulting to the prefix-less uci config dir when no MTD rootfs partitions are detected. 2) check_extroot now also attempts to find rootfs partitions on block devices when no MTD rootfs partitions are detected. Fixes: FS#2231 Ref: https://bugs.openwrt.org/index.php?do=details_id=2231 Signed-off-by: Kenneth J. Miller --- block.c | 17 + 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/block.c b/block.c index 39212d2..3dfc4a5 100644 --- a/block.c +++ b/block.c @@ -1301,7 +1301,7 @@ static int find_block_ubi_RO(libubi_t libubi, char *name, char *part, int plen) return err; } -#else +#endif static int find_root_dev(char *buf, int len) { @@ -1332,8 +1332,6 @@ static int find_root_dev(char *buf, int len) return -1; } -#endif - static int test_fs_support(const char *name) { char line[128], *p; @@ -1363,25 +1361,20 @@ static int check_extroot(char *path) struct probe_info *pr = NULL; char devpath[32]; -#ifdef UBIFS_EXTROOT if (find_block_mtd("\"rootfs\"", devpath, sizeof(devpath))) { int err = -1; +#ifdef UBIFS_EXTROOT libubi_t libubi; libubi = libubi_open(); err = find_block_ubi_RO(libubi, "rootfs", devpath, sizeof(devpath)); libubi_close(libubi); - if (err) - return -1; - } -#else - if (find_block_mtd("\"rootfs\"", devpath, sizeof(devpath))) { - if (find_root_dev(devpath, sizeof(devpath))) { +#endif + if (err && find_root_dev(devpath, sizeof(devpath))) { ULOG_ERR("extroot: unable to determine root device\n"); return -1; } } -#endif list_for_each_entry(pr, , list) { if (!strcmp(pr->dev, devpath)) { @@ -1585,7 +1578,7 @@ static int main_extroot(int argc, char **argv) } #endif - return mount_extroot(NULL); + return mount_extroot("/tmp/overlay"); } static int main_mount(int argc, char **argv) -- 2.21.0 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH] fstools: block: make extroot mount preparation more robust
Signed-off plain-text patch: >From 6df03fc450d7f1e2b49791b0d384a7b1ae0d9c69 Mon Sep 17 00:00:00 2001 From: Kenneth Miller Date: Tue, 9 Apr 2019 19:14:37 +0200 Subject: [PATCH] block: make extroot mount preparation more robust The extroot mount preparation code for r/w rootfs overlay discovery, and determining the user-defined /etc/config/fstab location within, would only discover overlays residing on JFFS2 or UBIFS MTD storage. This led to attempts at loading the uci fstab configuration without the required /tmp/overlay directory prefix on devices with a non-MTD r/w rootfs overlay, and thus failure to find any custom fstab /overlay extroot entries on PREINIT. (example: the default openwrt eMMC partition layout on the zyxel nbg6817) Futher, with UBIFS_EXTROOT enabled (fstools package default), and no MTD rootfs partitions present, check_extroot would not attempt rootfs discovery on block devices, such as the ext4 mmcblk rootfs overlay on the nbg6817. With this patch: 1) main_extroot now attempts to load uci fstab configuration from an already mounted overlay, before defaulting to the prefix-less uci config dir when no MTD rootfs partitions are detected. 2) check_extroot now also attempts to find rootfs partitions on block devices when no MTD rootfs partitions are detected. Signed-off-by: Kenneth Miller --- block.c | 17 + 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/block.c b/block.c index 39212d2..3dfc4a5 100644 --- a/block.c +++ b/block.c @@ -1301,7 +1301,7 @@ static int find_block_ubi_RO(libubi_t libubi, char *name, char *part, int plen) return err; } -#else +#endif static int find_root_dev(char *buf, int len) { @@ -1332,8 +1332,6 @@ static int find_root_dev(char *buf, int len) return -1; } -#endif - static int test_fs_support(const char *name) { char line[128], *p; @@ -1363,25 +1361,20 @@ static int check_extroot(char *path) struct probe_info *pr = NULL; char devpath[32]; -#ifdef UBIFS_EXTROOT if (find_block_mtd("\"rootfs\"", devpath, sizeof(devpath))) { int err = -1; +#ifdef UBIFS_EXTROOT libubi_t libubi; libubi = libubi_open(); err = find_block_ubi_RO(libubi, "rootfs", devpath, sizeof(devpath)); libubi_close(libubi); - if (err) - return -1; - } -#else - if (find_block_mtd("\"rootfs\"", devpath, sizeof(devpath))) { - if (find_root_dev(devpath, sizeof(devpath))) { +#endif + if (err && find_root_dev(devpath, sizeof(devpath))) { ULOG_ERR("extroot: unable to determine root device\n"); return -1; } } -#endif list_for_each_entry(pr, , list) { if (!strcmp(pr->dev, devpath)) { @@ -1585,7 +1578,7 @@ static int main_extroot(int argc, char **argv) } #endif - return mount_extroot(NULL); + return mount_extroot("/tmp/overlay"); } static int main_mount(int argc, char **argv) -- 2.21.0 On 4/9/19 6:44 PM, Kenneth Miller wrote: > I had trouble using an ext4 extroot overlay on my Zyxel NBG6817 running > 18.06.2, so I took a closer look at the way libfstools and its block > tool setup the extroot overlay during PREINIT and found some things > broke extroot mounting on certain devices. > > The issue and logs are documented in the following ticket: > https://bugs.openwrt.org/index.php?do=details_id=2231 > > What I found was that the main_extroot code would only look for > "rootfs_data" partitions on MTD storage (specifically only JFFS2 and > UBIFS partitions), before defaulting to calling mount_extroot with no > configuration path prefix. > mount_extroot would then try to load the fstab uci config at > /etc/config/fstab, which would fail as this isn't present on the normal > r/o squashfs eMMC partition. > > With a /etc/config/fstab uci config be pre-placed on the squashfs, > mount_extroot would continue after loading it and successfully finding > an /overlay extroot entry, but fail during check_extroot when no MTD > partition or UBIFS volume can be found. > > With the attached patch the behaviour of main_extroot and check_extroot > is expanded to allow detection of rootfs overlays on block devices such > as eMMC, without compromising the behavior for JFFS2 and UBIFS rootfs > discovery: > > 1. The default mount_extroot call now uses '/tmp/overlay' as a default > parameter should no MTD partition be detected. This results in > config_load attempting to load a uci fstab with this > prefix before defaulting to /etc/config/fstab. > 2. UBIFS_EXTROOT now acts as a supplementary option instead of an > exclusionary one and will allow rootfs discovery on block devices even > when it fails to find UBIFS rootfs volumes. > (IMHO the best design decision as this option defaults to 'y' in the > fstools package configuration) >
[OpenWrt-Devel] [PATCH] fstools: block: make extroot mount preparation more robust
I had trouble using an ext4 extroot overlay on my Zyxel NBG6817 running 18.06.2, so I took a closer look at the way libfstools and its block tool setup the extroot overlay during PREINIT and found some things broke extroot mounting on certain devices. The issue and logs are documented in the following ticket: https://bugs.openwrt.org/index.php?do=details_id=2231 What I found was that the main_extroot code would only look for "rootfs_data" partitions on MTD storage (specifically only JFFS2 and UBIFS partitions), before defaulting to calling mount_extroot with no configuration path prefix. mount_extroot would then try to load the fstab uci config at /etc/config/fstab, which would fail as this isn't present on the normal r/o squashfs eMMC partition. With a /etc/config/fstab uci config be pre-placed on the squashfs, mount_extroot would continue after loading it and successfully finding an /overlay extroot entry, but fail during check_extroot when no MTD partition or UBIFS volume can be found. With the attached patch the behaviour of main_extroot and check_extroot is expanded to allow detection of rootfs overlays on block devices such as eMMC, without compromising the behavior for JFFS2 and UBIFS rootfs discovery: 1. The default mount_extroot call now uses '/tmp/overlay' as a default parameter should no MTD partition be detected. This results in config_load attempting to load a uci fstab with this prefix before defaulting to /etc/config/fstab. 2. UBIFS_EXTROOT now acts as a supplementary option instead of an exclusionary one and will allow rootfs discovery on block devices even when it fails to find UBIFS rootfs volumes. (IMHO the best design decision as this option defaults to 'y' in the fstools package configuration) >From 9daabc73ed804fe969e0318dfe533794d6da73b6 Mon Sep 17 00:00:00 2001 From: Ken Miller Date: Tue, 9 Apr 2019 01:03:26 +0200 Subject: [PATCH] block: make extroot mount preparation more robust The extroot mount preparation code for r/w rootfs overlay discovery, and determining the user-defined /etc/config/fstab location within, would only discover overlays residing on JFFS2 or UBIFS MTD storage. This led to attempts at loading the uci fstab configuration without the required /tmp/overlay directory prefix on devices with a non-MTD r/w rootfs overlay, and thus failure to find any custom fstab /overlay extroot entries on PREINIT. (example: the default openwrt eMMC partition layout on the zyxel nbg6817) Futher, with UBIFS_EXTROOT enabled (fstools package default), and no MTD rootfs partitions present, check_extroot would not attempt rootfs discovery on block devices, such as the ext4 mmcblk rootfs overlay on the nbg6817. With this patch: 1) main_extroot now attempts to load uci fstab configuration from an already mounted overlay, before defaulting to the prefix-less uci config dir when no MTD rootfs partitions are detected. 2) check_extroot now also attempts to find rootfs partitions on block devices when no MTD rootfs partitions are detected. --- block.c | 17 + 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/block.c b/block.c index 39212d2..3dfc4a5 100644 --- a/block.c +++ b/block.c @@ -1301,7 +1301,7 @@ static int find_block_ubi_RO(libubi_t libubi, char *name, char *part, int plen) return err; } -#else +#endif static int find_root_dev(char *buf, int len) { @@ -1332,8 +1332,6 @@ static int find_root_dev(char *buf, int len) return -1; } -#endif - static int test_fs_support(const char *name) { char line[128], *p; @@ -1363,25 +1361,20 @@ static int check_extroot(char *path) struct probe_info *pr = NULL; char devpath[32]; -#ifdef UBIFS_EXTROOT if (find_block_mtd("\"rootfs\"", devpath, sizeof(devpath))) { int err = -1; +#ifdef UBIFS_EXTROOT libubi_t libubi; libubi = libubi_open(); err = find_block_ubi_RO(libubi, "rootfs", devpath, sizeof(devpath)); libubi_close(libubi); - if (err) - return -1; - } -#else - if (find_block_mtd("\"rootfs\"", devpath, sizeof(devpath))) { - if (find_root_dev(devpath, sizeof(devpath))) { +#endif + if (err && find_root_dev(devpath, sizeof(devpath))) { ULOG_ERR("extroot: unable to determine root device\n"); return -1; } } -#endif list_for_each_entry(pr, , list) { if (!strcmp(pr->dev, devpath)) { @@ -1585,7 +1578,7 @@ static int main_extroot(int argc, char **argv) } #endif - return mount_extroot(NULL); + return mount_extroot("/tmp/overlay"); } static int main_mount(int argc, char **argv) -- 2.21.0 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel