-
-
Notifications
You must be signed in to change notification settings - Fork 11k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FS#2231 - fstools: PREINIT calling of block extroot doesn't acknowledge non-MTD rootfs overlays #7352
Comments
knodel: I wrote a small patch that allows proper rootfs and fstab discovery on devices where the rootfs+overlay reside on a block device partition. Here the dmesg of a current openwrt HEAD build with the patch:
Unrelated dmesg entries omitted, full log here: https://gist.github.com/knuddelknoedel/46db572959056d2e69fd861d59ad0daf |
val-kulkov: The proposed patch works beautifully to enable extroot on my x86_64 device. With it, I can finally make use of the available space on my /dev/sda without worrying about losing data on it upon a sysupgrade. The sysupgrade process on a x86_64 system that I use to avoid losing data is not yet a straightforward one. First, I burn openwrt-x86-64-combined-squashfs.img on a USB drive. Then, I copy first two partitions from the USB drive to the corresponding partitions on my /dev/sda. Finally, I copy the MBR bootstrap only, without the partition table: "dd if=/dev/sdc of=/dev/sda bs=446 count=1". This procedure retains sda3, my root overlay partition, and sda4, a swap partition. |
utrumo: Now on Zyxel Armor Z2 (NBG6817) extroot doesn't work without this patch. To make work extroot on this router we need compile own firmware and apply this patch:
results you can find in:
DEVICE="/dev/mmcblk0p10" // or if you want to use usb-hdd: DEVICE="/dev/sda1" mount "${DEVICE}" /mnt reboot |
rmilecki: That fstools patch cannot be applied as is (I reviewed & commented on it). I pushed three related fstools changes:
That moves us closer to fixing this issue. Someone now needs to improve main_extroot() and make it:
It's basically the same logic as what we already have for JFFS2 and UBIFS in that main_extroot() function. |
leifliddy: If we're going to use f2fs as the filesystem for the extroot overlay device (which is a great idea), then we should probably include these package as part of the base build for the zyxel_nbg6817: Actually, this brings up another question, why aren't we using the f2fs filesystem for the default overlay device? /dev/loop0 on /overlay type ext4 (rw,noatime,data=ordered) |
rmilecki: I just noticed that orignal report was about ext4. Recently I was chatting with m4t who was using f2fs. So this task seems more generic: we need to check /dev/loop0 for /etc/config/fstab with overlay setup. That /dev/loop0 may be ext4 or f2fs (or other?). |
leifliddy: I'm not sure if this is the correct forum for this or not, but here goes. https://openwrt.org/toh/zyxel/nbg6817 You'll see that mmcblk0p5 is divided up into two parts mmcblk0p5 rootfs 64 MiB /rom (squashfs) 4MB So, if you've configured mmcblk0p10 to act as the /overlay, Is there a reason we can't just re-partition this entire device, I mean there's no reason for openwrt to need 10 partitions. If we need to maintain the OEM partitioning scheme, then we should make mmcblk0p1 the 4MB /rom partition That's makes the most sense...but I'll save this discussion for another day. Need to do a bit more research on how openwrt is designed.... |
leifliddy: @ken would you be able to create a new patch based on the changes Rafał made to fstools? |
tofurky: leifliddy, this works for me with f2fs on 19.07.3. note that the change to check_filesystem() isn't strictly necessary, but i found that newer f2fs-tools gave some issues without it. diff --git a/block.c b/block.c
index 569bf56..b88e208 100644
--- a/block.c
+++ b/block.c
@@ -747,7 +747,7 @@ static void check_filesystem(struct probe_info *pr)
pid = fork();
if (!pid) {
if(!strncmp(pr->type, "f2fs", 4)) {
- execl(ckfs, ckfs, "-f", pr->dev, NULL);
+ execl(ckfs, ckfs, "-p", "2", "-f", pr->dev, NULL);
exit(EXIT_FAILURE);
} else if(!strncmp(pr->type, "btrfs", 5)) {
execl(ckfs, ckfs, "--repair", pr->dev, NULL);
@@ -1591,7 +1591,7 @@ static int main_extroot(int argc, char **argv)
#endif
/* As a last resort look for /etc/config/fstab on "rootfs" partition */
- return mount_extroot(NULL);
+ return mount_extroot("/tmp/overlay");
}
static int main_mount(int argc, char **argv) i spent a bit of time trying to figure out the proper way to do it per rafal's suggestion, but was running into segfaults with find_block(NULL, NULL, "loop0", NULL) so i just took the easy way out ;) not sure if i was even close to taking the right approach with that, though. |
katrat: Hi, I guess this fix wasn't included in the 19.07.3 release yet, since I am struggling to set up overlayfs on my new NBG6817 with usb hard disk and ext4. Are there any patched images to download/test? Any chance this will be fixed in one of the next releases? I am not that experienced to build/figure out this myself, so any links/instructions are much appreciated. On the other hand, my zyxel isn't productive yet, so I am willing to test... Thanks, |
rmilecki: Noone cared to develop a proper patch, people keep posting some hacks that are unacceptable due to breaking other setups. |
katrat: Thanks for the quick, if also a bit unsatisfying, answer. I got the zyxel because it seemed to be properly supported by openwrt (and having a bit more oomph than my ageing tp-link). I don't really understand where the problem is: ext4 of f2fs, hard disk or flash drive, or the drives not being ready at boot time, or just some configuration hiccup. Can you suggest what I could do? I don't mind playing around a bit. |
rmilecki:
|
visualage: Is it reasonable to use libfstools to search for rootfs_data volume and mount it, just like what mount_root.c does? |
visualage: I made a patch to openwrt to support extroot on non-MTD rootfs_data volumes. It uses libfstools in block.c to support other squashfs volumes, such as /dev/sd* or /dev/mmc*. The patch itself contains a patch to fstools project that can be applied to that codebase directly. I tested the build locally on a x86-64 virtualbox environment as well as rockchip friendlyarm nanopi r2s. It should work on any other environments as long as mount_root works since they use the same underlying library. |
visualage: This is the fstools patch. The openwrt patch is just to make sure block-mount depends on libfstools when packaging. |
kofec: Hi, |
uutrumo: Qi Liu, for wich version of openwrt your patch? |
uutrumo: tofurky, your hack works, thank you. --- a/block.c
+++ b/block.c
@@ -747,7 +747,7 @@ static void check_filesystem(struct prob
pid = fork();
if (!pid) {
if(!strncmp(pr->type, "f2fs", 4)) {
- execl(ckfs, ckfs, "-f", pr->dev, NULL);
+ execl(ckfs, ckfs, "-p", "2", "-f", pr->dev, NULL);
exit(EXIT_FAILURE);
} else if(!strncmp(pr->type, "btrfs", 5)) {
execl(ckfs, ckfs, "--repair", pr->dev, NULL);
@@ -1591,7 +1591,7 @@ static int main_extroot(int argc, char *
#endif
/* As a last resort look for /etc/config/fstab on "rootfs" partition */
- return mount_extroot(NULL);
+ return mount_extroot("/tmp/overlay");
}
static int main_mount(int argc, char **argv) |
luce.nera: How do I apply these patches and which one to use? |
flowercow: i met this bug in 21.02.0-rc4 installed in kvm. Is there any other method to solve this problem? For example, do something in /etc/preinit? |
Gandalf: Still got the issue in 21.02.0 !!! |
flowercow: i have tried to recompile firmware applying patch as mentioned by utrumo above. |
Op3n: The same bug occurs on the latest stable release 20.02, Is there any way to avoid this bug other than by compiling it myself? I prefer use official pre-compiled version on downloads.openwrt.com |
katrat: Well, any solutions apart from patching and compiling openwrt ourselves? Does anyone have a precompiled working solution for 21.02? |
siicosmos: Need some solution for 21.02 as well. Either patches or a pre-compiled image is fine... |
siicosmos: Updates: |
Is there a timeline for this being officially fixed? |
There is an alternative way for Zyxel NBG6817: change the uboot-env variable so that rootfs is loaded from /dev/mmсblk0p10 Example: view at the contents of the firmware:
flash: (
make an overlay:
find free loop:
Create and format it:
Now change uboot-env:
The first variable is responsible for booting from the main partition (FF), the second for booting from the alternate partition (01)
checking:
Everything. Now you can reboot into the main partition and check the result:
And no block-mount, blockd are no longer needed ;) |
I've been following this bug for a few years and wanted to check if there's anything I can do to help. This is my understanding of the current situation, please correct me if I'm wrong:
Is there anything a motivated bystander can do to help bump the version of fstools in openwrt master? Is more testing needed? (I assume submitting a patch to bump the version in |
Hi, |
This fix is important in its own right, but if you'll email me or contact me on the forum I'm pretty sure I can help you get your device working with either its internal NVME booting from an sdcard. |
Is there anything new? |
It's already 2024 but there aren't any solution to this. |
Afaik @lu-zero addressed this with commits merged by now: |
Is it now part of official openwrt images? |
At least I tried with latest stable |
You can try this in snapshot images, in 23.05.x this is not yet included (but we may include it in the next 23.05.x point release once users confirm that it fixes the issues previously affecting extroot use) |
I'll go test that out and report back. |
Nope it doesn't seem to work. |
Finally got to this thread after spending decent hours on figuring out where the problem with configuring an overlay is on my Turris Omnia after I've flashed OpenWrt to it. It'd be great to see this finally fixed, thank you to everyone it this thread for allowing me to understand where the problem is. |
There are more Turris Omnia owners who are awaiting eagerly any new info about this issue. |
Just to confirm, I was able to resolve the problem by flashing the latest snapshot on my Turris Omnia. Steps I've performed, for anyone who's in a similar situation.
Content of the
Validation of the overlay FS mounted properly from the USB partition:
Thanks to everyone in this thread for helping me to resolve the issue, I hope this will help others to resolve the issue. It'd be great to see this included in the main release and the issue closed. |
Awesome, thanks for detailed description. I will try later too. |
I'm wondering too, I'll try again with the instruction of |
Follow the same steps and no luck.
Did I missed anything? |
@xrh0905: I think the Can you try to update the
Eventually, you could try specifying Also, as described in the https://openwrt.org/docs/guide-user/additional-software/extroot_configuration#troubleshooting, you might need to set the |
Just verified that the setup I've described above works both with external USB and the internal mSATA SSD disks on my Turris Omnia. |
@tkapin Sorry for the late reply, been busy with something else. |
I'm curious if this fix will be intergrated into branch 23.05. In my case, my ipq60xx device with emmc can't boot from switching to /overlay extroot in /etc/config/fstab Before: Sat Jun 22 02:46:40 2024 user.info kernel: [ 14.456553] block: attempting to load /etc/config/fstab
Sat Jun 22 02:46:40 2024 user.err kernel: [ 14.459131] block: unable to load configuration (fstab: Entry not found)
Sat Jun 22 02:46:40 2024 user.err kernel: [ 14.460614] block: no usable configuration
Sat Jun 22 02:46:40 2024 kern.info kernel: [ 14.468230] loop0: detected capacity change from 0 to 122880
Sat Jun 22 02:46:40 2024 kern.info kernel: [ 14.535127] loop0: detected capacity change from 122880 to 8832
Sat Jun 22 02:46:40 2024 kern.info kernel: [ 14.555858] EXT4-fs (loop0): recovery complete
Sat Jun 22 02:46:40 2024 kern.info kernel: [ 14.556414] EXT4-fs (loop0): mounted filesystem with ordered data mode. Quota mode: disabled.
Sat Jun 22 02:46:40 2024 user.info kernel: [ 14.561917] mount_root: loading kmods from internal overlay
Sat Jun 22 02:46:40 2024 user.info kernel: [ 14.592924] kmodloader: loading kernel modules from /tmp/overlay/upper/etc/modules-boot.d/*
Sat Jun 22 02:46:40 2024 user.info kernel: [ 14.593703] kmodloader: done loading kernel modules from /tmp/overlay/upper/etc/modules-boot.d/*
Sat Jun 22 02:46:40 2024 user.info kernel: [ 14.717259] block: attempting to load /etc/config/fstab
Sat Jun 22 02:46:40 2024 user.err kernel: [ 14.717345] block: unable to load configuration (fstab: Entry not found)
Sat Jun 22 02:46:40 2024 user.err kernel: [ 14.721317] block: no usable configuration
Sat Jun 22 02:46:40 2024 user.info kernel: [ 14.728948] mount_root: switching to ext4 overlay
Sat Jun 22 02:46:40 2024 kern.warn kernel: [ 14.735463] overlayfs: null uuid detected in lower fs '/', falling back to xino=off,index=off,nfs_export=off. After: Mon Jun 24 03:44:49 2024 user.info kernel: [ 14.100648] block: attempting to load /tmp/overlay/upper/etc/config/fstab
Mon Jun 24 03:44:49 2024 user.err kernel: [ 14.100760] block: unable to load configuration (fstab: Entry not found)
Mon Jun 24 03:44:49 2024 user.info kernel: [ 14.106593] block: attempting to load /tmp/overlay/etc/config/fstab
Mon Jun 24 03:44:49 2024 user.err kernel: [ 14.113239] block: unable to load configuration (fstab: Entry not found)
Mon Jun 24 03:44:49 2024 user.info kernel: [ 14.119220] block: attempting to load /etc/config/fstab
Mon Jun 24 03:44:49 2024 user.err kernel: [ 14.126253] block: unable to load configuration (fstab: Entry not found)
Mon Jun 24 03:44:49 2024 user.err kernel: [ 14.131098] block: no usable configuration
Mon Jun 24 03:44:49 2024 user.info kernel: [ 14.138177] block: attempting to load /etc/config/fstab
Mon Jun 24 03:44:49 2024 user.err kernel: [ 14.141958] block: unable to load configuration (fstab: Entry not found)
Mon Jun 24 03:44:49 2024 user.err kernel: [ 14.147075] block: no usable configuration
Mon Jun 24 03:44:49 2024 kern.info kernel: [ 14.154560] loop0: detected capacity change from 0 to 122880
Mon Jun 24 03:44:49 2024 kern.info kernel: [ 14.214251] loop0: detected capacity change from 122880 to 94848
Mon Jun 24 03:44:49 2024 kern.info kernel: [ 14.256599] EXT4-fs (loop0): recovery complete
Mon Jun 24 03:44:49 2024 kern.info kernel: [ 14.257155] EXT4-fs (loop0): mounted filesystem with ordered data mode. Quota mode: disabled.
Mon Jun 24 03:44:49 2024 user.info kernel: [ 14.260307] mount_root: loading kmods from internal overlay
Mon Jun 24 03:44:49 2024 user.info kernel: [ 14.286819] kmodloader: loading kernel modules from /tmp/overlay/upper/etc/modules-boot.d/*
Mon Jun 24 03:44:49 2024 user.info kernel: [ 14.287063] kmodloader: done loading kernel modules from /tmp/overlay/upper/etc/modules-boot.d/*
Mon Jun 24 03:44:49 2024 user.info kernel: [ 14.413687] block: attempting to load /tmp/overlay/upper/etc/config/fstab
Mon Jun 24 03:44:49 2024 kern.info kernel: [ 14.506900] EXT4-fs (mmcblk0p27): mounted filesystem with ordered data mode. Quota mode: disabled.
Mon Jun 24 03:44:49 2024 kern.warn kernel: [ 14.511366] overlayfs: null uuid detected in lower fs '/', falling back to xino=off,index=off,nfs_export=off.
Mon Jun 24 03:44:49 2024 kern.info kernel: [ 14.517383] EXT4-fs (loop0): unmounting filesystem.
Mon Jun 24 03:44:49 2024 user.info kernel: [ 14.527882] mount_root: switched to extroot |
see openwrt/openwrt#7352 The fix is already in the mainline but not backport yet.
Since 23.05.4 is out, would this patch be included in this release? |
23.05.5 still doesn't work with Omnia. |
The 24.10.0-rc5 works as expected, great thanks. |
But I have problem to mount the overlay with the 'discard' option, the
The mounts:
The |
With 24.10-rc7 extroot on USB became worked. But non-extroot wifi radio0(5g) and radio1(2g) swapped comparing to extroot radio0(2g) and radio1(5g) default config and MAC-addresses not assigned. |
knodel:
Extroot overlay mount fails on my ZyXEL NBG6817.
I can confirm this bug on both the latest stable 18.06.2, and the snapshot from the 4th of April.
When PREINIT calls 'block extroot', block fails to load the custom fstab from the eMMC ext4 overlay mounted at /tmp/overlay:
Unrelated dmesg entries omitted, full log here:
https://gist.github.com/knuddelknoedel/2985ce7777a0263fbc22a02f8ef5307c
Custom modules are loaded with the correct overlay /tmp/overlay/upper prefix by libfstools, however the forked 'block extroot' process behaves differently when searching for /etc/config/fstab configuration.
Steps to reproduce:
Further notes: adding /etc/config/fstab with the desired /overlay entry to the sysupgrade squashfs image before flashing allows block to successfully find the uci fstab config, however the mounting of the therein configured /overlay mount still fails.
The text was updated successfully, but these errors were encountered: