OpenWrt Forum Archive

Topic: how to use the new block-mount ?

The content of this topic has been archived between 19 Jun 2015 and 6 May 2018. Unfortunately there are posts – most likely complete pages – missing.

the 'block' cmd has some hidden options (not shown with block -h):

block extroot
block hotplug

so I assume that in the startup scripts for AR71xx there is a missing call for that?

just 'block mount' will not mount an extroot FS, I looked into the source code of ubox:

        if (!strcmp(argv[1], "mount"))
            return main_mount(argc, argv);

that one goes into

static int mount_device(struct blkid_struct_probe *pr, int hotplug)
{
    struct mount *m;
    char *device = basename(pr->dev);

    if (!pr)
        return -1;

    if (!strcmp(pr->id->name, "swap")) {
        if (hotplug && !auto_swap)
            return -1;
        m = find_swap(pr->uuid, device);
        if (m || anon_swap)
            swapon(pr->dev, (m) ? (m->prio) : (0));

        return 0;
    }

    if (hotplug && !auto_mount)
        return -1;

    if (find_mount_point(pr->dev)) {
        fprintf(stderr, "%s is already mounted\n", pr->dev);
        return -1;
    }

    m = find_block(pr->uuid, pr->label, device, NULL);
    if (m && m->extroot)
        return -1;

so no / or /overlay targets can ever be mounted with 'block mount' - instead 'block extroot' must be used. IMO.

can someone check that this call is done on startup on AR71xx? I have no clue where to look.

after my router has finished booting "df -h" shows

Filesystem                Size      Used Available Use% Mounted on
rootfs                    5.1M      4.4M    712.0K  86% /
/dev/root                 1.8M      1.8M         0 100% /rom
tmpfs                    61.7M    288.0K     61.4M   0% /tmp
/dev/mtdblock3          869.8M     17.0M    807.8M   2% /overlay
overlayfs:/overlay        5.1M      4.4M    712.0K  86% /
tmpfs                   512.0K         0    512.0K   0% /dev
/dev/sda1               869.8M     17.0M    807.8M   2% /overlay

and when I type "block extroot", nothing is happening... (WDR4300)

harhar wrote:

and when I type "block extroot", nothing is happening... (WDR4300)

same here sad block extroot does no action. However maybe this call must be done during bootup? I have no idea where to look.

tp-link wr720n doesn't mount overlay with the latest trunk for me

gently wrote:

tp-link wr720n doesn't mount overlay with the latest trunk for me

Try [rm /etc/.ex*]
then mount your ext-overlay to /mnt
then [ rm /mnt/etc/.ex*]

johan666 wrote:
gently wrote:

tp-link wr720n doesn't mount overlay with the latest trunk for me

Try [rm /etc/.ex*]
then mount your ext-overlay to /mnt
then [ rm /mnt/etc/.ex*]

no such files, should they be there?

johan666 wrote:
gently wrote:

tp-link wr720n doesn't mount overlay with the latest trunk for me

Try [rm /etc/.ex*]
then mount your ext-overlay to /mnt
then [ rm /mnt/etc/.ex*]

This File(s) are not generated on TP-Link 1043ND and other Routers with broken extroot.

try setting PREINIT=1 in environment and then call 'block extroot' - see what happens

on my MR3220v2, trunk r37374, the startup scripts do not call the 'block' binary with correct arguments.

you can check this:

edit your /etc/config/fstab

config 'global'
        option  anon_swap       '0'
        option  anon_mount      '0'
        option  auto_swap       '1'
        option  auto_mount      '1'
        option  delay_root      '0'
        option  check_fs        '1'  <==== ENABLE THIS

then replace /usr/sbin/e2fsck with this:

#!/bin/sh
set >/tmp/boot.env

chmod 755  /usr/sbin/e2fsck  and then reboot.

on my router there is no /tmp/boot.env created! => block is not called or missing PREINIT=1 in the environment.

when I change target to /mnt, I am getting this in /tmp/boot.env:

cat boot.env
ACTION='add'
DEVNAME='sda1'
DEVPATH='/devices/platform/ehci-platform/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0/block/sda/sda1'
DEVTYPE='partition'
HOME='/'
HOTPLUG_TYPE='block'
IFS='
'
LOGNAME='root'
MAJOR='8'
MINOR='1'
OPTIND='1'
PATH='/bin:/sbin:/usr/bin:/usr/sbin'
PPID='683'
PS1='\w \$ '
PS2='> '
PS4='+ '
PWD='/'
SEQNUM='474'
SUBSYSTEM='block'
TERM='linux'
USER='root'
board='TL-MR3220-v2'

that means on MR3220 it calls 'block hotplug' during startup!

in my opinion the block binary is missing some calls to pivot_root?

in static int mount_device(struct blkid_struct_probe *pr, int hotplug):

this will prevent to reach mount when called for hotplug and / target:

    if (m && m->extroot)
        return -1;

idk how to fix it?

Should the init scripts call pivot_root or should it be done from inside block binary?

(Last edited by kurczaq on 19 Jul 2013, 03:03)

hi all,

I'm dealing with the same issue with my router wr1043, how can solve it?

Thanks

I'll give the new extroot a try later today on my WNDR3700 router.

(Last edited by written_direcon on 20 Jul 2013, 22:26)

Extroot with the new block-mount package works perfectly on my WNDR3700v1 :-)

root@OpenWrt:/# block info
/dev/mtdblock3: UUID="8752-46d7" VERSION="4.0" TYPE="squashfs"
/dev/mtdblock4: TYPE="jffs2"
/dev/sda1: UUID="83414faf-c476-41a6-bf1b-08450d8f671b" NAME="EXT_JOURNAL" VERSION="1.0" TYPE="ext4"
root@OpenWrt:/#
root@OpenWrt:/# df -h
Filesystem                Size      Used Available Use% Mounted on
rootfs                  109.9G     68.6M    104.2G   0% /
/dev/root                 2.5M      2.5M         0 100% /rom
tmpfs                    30.1M     52.0K     30.0M   0% /tmp
/dev/sda1               109.9G     68.6M    104.2G   0% /
tmpfs                   512.0K         0    512.0K   0% /dev
root@OpenWrt:/#

(Last edited by written_direcon on 20 Jul 2013, 22:28)

shape wrote:

Hello, everyone! Check out the new section (Barrier Breaker) in the updated extroot wiki:
http://wiki.openwrt.org/doc/howto/extro … aker.trunk

It also includes instructions on how the new block-mount works.

does not work in TL-MR3420

in the Logs here i see some difference:

overlayfs:/overlay <-- Router with this entry in df -h seems to be broken and models without this entry seems to be working?

Can someone Confirm this?

inder wrote:

same problem for tp-link wr703n no overlay works, no pivot root works :-( only swap working
[...]

I can confirm:  No overlay, nor root or pivot.  :/
Swap is working.
I was using the howto in the wiki.

root@OpenWrt:/# cat /proc/cpuinfo
system type             : Atheros AR9330 rev 1
machine                 : TP-LINK TL-WR703N v1

BARRIER BREAKER (Bleeding Edge, r37374)


Edit:  df shows the "overlayfs:/overlay" @ DarkStarXxX

root@OpenWrt:/# df -h
Filesystem                Size      Used Available Use% Mounted on
rootfs                    1.1M    712.0K    376.0K  65% /
/dev/root                 1.8M      1.8M         0 100% /rom
tmpfs                    14.1M     48.0K     14.1M   0% /tmp
/dev/mtdblock3            1.1M    712.0K    376.0K  65% /overlay
overlayfs:/overlay        1.1M    712.0K    376.0K  65% /                 <--------------------------- here
tmpfs                   512.0K         0    512.0K   0% /dev

(Last edited by fastred on 21 Jul 2013, 13:49)

Hi
I'm using TP-LINK 1043ND v1.6
below are the logs:

I have followed the http://wiki.openwrt.org/doc/howto/extro … aker.trunk :

I hope this will help

Thanks

Yaniv


vi /etc/config/fstab
config 'global'
        option  anon_swap       '0'
        option  anon_mount      '0'
        option  auto_swap       '1'
        option  auto_mount      '1'
        option  delay_root      '0'
        option  check_fs        '1'

config 'mount'
        option  target  '/overlay'
        option  uuid    '674e2fe2-46fd-49ae-8c3d-1e0daab1f5e0'
        option  enabled '1'

config 'swap'
        option  uuid    '5ee39ed9-0044-4305-b2bd-49a0130447e9'
        option  enabled '1'



root@OpenWrt:~# df -h
Filesystem                Size      Used Available Use% Mounted on
rootfs                    5.1M      3.2M      1.9M  63% /
/dev/root                 1.8M      1.8M         0 100% /rom
tmpfs                    14.2M     72.0K     14.1M   0% /tmp
/dev/mtdblock3            5.1M      3.2M      1.9M  63% /overlay
overlayfs:/overlay        5.1M      3.2M      1.9M  63% /
tmpfs                   512.0K         0    512.0K   0% /dev

root@OpenWrt:~# mount
/dev/root on /rom type squashfs (ro,relatime)
proc on /proc type proc (rw,noatime)
sysfs on /sys type sysfs (rw,noatime)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime)
/dev/mtdblock3 on /overlay type jffs2 (rw,noatime)
overlayfs:/overlay on / type overlayfs (rw,noatime,lowerdir=/,upperdir=/overlay)
tmpfs on /dev type tmpfs (rw,relatime,size=512k,mode=755)
devpts on /dev/pts type devpts (rw,relatime,mode=600)
debugfs on /sys/kernel/debug type debugfs (rw,noatime)


root@OpenWrt:~# export PREINIT=1  <------------------
root@OpenWrt:~# block extroot
root@OpenWrt:~# df -h
Filesystem                Size      Used Available Use% Mounted on
rootfs                    5.1M      3.2M      1.9M  63% /
/dev/root                 1.8M      1.8M         0 100% /rom
tmpfs                    14.2M     72.0K     14.1M   0% /tmp
/dev/mtdblock3            5.1M      3.2M      1.9M  63% /overlay
overlayfs:/overlay        5.1M      3.2M      1.9M  63% /
tmpfs                   512.0K         0    512.0K   0% /dev
/dev/sda1                13.6G     49.1M     12.8G   0% /tmp/overlay  <-------------------

(Last edited by yaniv1111 on 21 Jul 2013, 14:10)

I summarize what we have found:

1) on AR71xx platform, the boot scripts call 'block hotplug' instead of 'block extroot'. 'PREINIT' variable is missing in the boot environment to be able to call 'block extroot'.

2) 'block extroot' will mount the filesystems under /tmp:
either /tmp/overlay
or /tmp/mnt
(see static int mount_extroot(char *cfg))

there is no further call to either bind mount or pivot_root. (so it can NEVER work like that! the code is totally broken).

3) calling 'block hotplug' will NOT mount any /overlay target or / target, the code prevents this see static int mount_device(struct blkid_struct_probe *pr, int hotplug):
    if (m && m->extroot) {
        return -1;
    }

it will mount only NON-overlay NON-/ targets.

4) on AR71xx there are no further calls to pivot_root during boot - this must be done if you want the extroot filesystem to appear on / - you CANNOT just mount a device on global '/' after it was mounted by kernel startup (as root=XXXX kernel cmd line) - try on shell command line and you see that it does NOT work on Linux 3.8.13!!!

IF YOU READ THE KERNEL SOURCE CAREFULLY YOU WILL SEE, that the setting up the root file system during bootup, is basically a call to pivot_root and NOT a simple mount. There you have the code to see why just mounting on / will NEVER work on Linux (at least 2.6 upwards). Therefore I repeat, the 'block' binary is totally broken - it has no clue about how Linux is working.

pivot_root must be called just after init starts it work but before ANY service process is launched and before other file systems are mounted onto the original boot - otherwise you end up with stuff running inside the original root - that is BAD!

I am not openwrt developer, I do not know where to fix it, to not break anything further.

Other platforms may work though - if the boot scripts include some calls to pivot the mounted FS under /tmp - so please do not write again "but it works on my router" - yeah it may work on yours, but on AR71xx with (Bleeding Edge, r37374) it DOES NOT WORK.

(Last edited by kurczaq on 21 Jul 2013, 16:25)

I tried also to directly mount & pivot from /etc/init.d/boot - but this does not work either (I load the modules manually) - I can mount my usb drive but cannot pivot it to be new root - if I add pivot_root call to the init script, it hangs with flashing led - no way.

kurczaq wrote:

1) on AR71xx platform, the boot scripts call 'block hotplug' instead of 'block extroot'. 'PREINIT' variable is missing in the boot environment to be able to call 'block extroot'.

block extroot is directly invoked from mount_root - see http://nbd.name/gitweb.cgi?p=luci2/ubox … 8b2b5#l680

kurczaq wrote:

there is no further call to either bind mount or pivot_root. (so it can NEVER work like that! the code is totally broken).

mount_root takes care of moving the mounts from /tmp.

kurczaq wrote:

3) calling 'block hotplug' will NOT mount any /overlay target or / target

Correct, because this happens in block extroot.

kurczaq wrote:

4) on AR71xx there are no further calls to pivot_root during boot

They happen in mount_root.

kurczaq wrote:

Other platforms may work though - if the boot scripts include some calls to pivot the mounted FS under /tmp - so please do not write again "but it works on my router" - yeah it may work on yours, but on AR71xx with (Bleeding Edge, r37374) it DOES NOT WORK.

It works for a number of ar71xx users, including me. There are however a number of null pointer dereferences in block that happen with certain partition layouts, so please do not jump to premature conclusions.

But it does not work on TP-Link 1043ND and a lot of other Systems.
There must be something wrong.

It works on a tl-wr1043nd for me, the problem is not device or architecture specific but rather related to the storage (usb settle times, partition layout, existing filesystems etc.)

To those people seeing non working extroots: try the delay_root option of block. Also run "block detect" and see if it segfaults in between.

The only Thing i can say that's not working for me.
I try a lot in the last weeks (Different Trunk Versions / Self Builds etc) and nothing working here.

I also tested it with 2 Different USB Sticks.

I can give you ssh Access if you don't believe me...

I didn't say that I do not believe you, I just said that the problem is far from generic and yes, ssh access would be useful.

Sorry, posts 76 to 75 are missing from our archive.