bedrocklinux / bedrocklinux-userland

This tracks development for the things such as scripts and (defaults for) config files for Bedrock Linux
https://bedrocklinux.org
GNU General Public License v2.0
605 stars 64 forks source link

Mkdir before mounting read write #118

Open bepvte opened 5 years ago

bepvte commented 5 years ago

https://github.com/bedrocklinux/bedrocklinux-userland/blob/683e0f38531d4e0971aaeb29873f1bf98b534c0d/src/init/init#L47-L51 Im not sure if this works with a read only file system

fogti commented 5 years ago

It should be possible to replace this part with:

    if ! [ -r /proc/mounts ] || ! grep -q "^\\w* /proc proc" /proc/mounts 2>&1 | head -n0; then
        if [ -d /proc ]; then
            mount -t proc proc /proc
        fi
    fi
    mount -o remount,rw / 2>&1 | head -n0
    if ! [ -d /proc ]; then
        mkdir -p /proc
        mount -t proc proc /proc
    fi

But I don't know if that would have unintended side effects...

paradigm commented 5 years ago

Good catch. I think this has been a non-issue thus far because /proc has always existed prior to this point in the code.

My guess is we can just swap the order:

mount -o remount,rw / 2>&1 | head -n0
if ! [ -r /proc/mounts ] || ! grep -q "^\\w* /proc proc" /proc/mounts 2>&1 | head -n0; then
    mkdir -p /proc
    mount -t proc proc /proc
fi

as I don't see why /proc would be required to remount the root filesystem. I'll give that a try and, if it works, apply it, once I get the chance.

If that fails for whatever reason, I'll have the hijack install code create the directory and substitute the mkdir -p /proc with an appropriate comment.