Skip to content

remounting overlayfs fails #2528

Open
Open

Description

@mwhudson

I found this digging in to https://bugs.launchpad.net/ubuntu/+source/util-linux/+bug/2037417 where I thought something a bit deeper around an overlayfs that was using paths no longer available from the current mount namespace was going on, but no:

mwhudson@orcrist:~/tmp/lp-2037417$ cat repro2.sh
#!/bin/bash
set -eux
mkdir -p lower work upper mountpoint
mount -o ro,lowerdir=lower,upperdir=upper,workdir=work -t overlay overlay mountpoint
mount -o remount,rw mountpoint
mwhudson@orcrist:~/tmp/lp-2037417$ sudo bash repro2.sh
+ mkdir -p lower work upper mountpoint
+ mount -o ro,lowerdir=lower,upperdir=upper,workdir=work -t overlay overlay mountpoint
+ mount -o remount,rw mountpoint
mount: /home/mwhudson/tmp/lp-2037417/mountpoint: mount point not mounted or bad option.
       dmesg(1) may have more information after failed mount system call.

The failure seems to be this syscall:

mwhudson@orcrist:~/tmp/lp-2037417$ sudo strace -e fsconfig mount -o remount,rw mountpoint 
fsconfig(4, FSCONFIG_SET_STRING, "lowerdir", "lower", 0) = -1 EINVAL (Invalid argument)
mount: /home/mwhudson/tmp/lp-2037417/mountpoint: mount point not mounted or bad option.
       dmesg(1) may have more information after failed mount system call.
+++ exited with 32 +++

Activity

  1. t-8ch commented on Oct 5, 2023

    @t-8ch
    Member

    The inability to reconfigure overlayfs seems to be intentional:

    https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/overlayfs/params.c?id=3006adf3be79cde4d14b1800b963b82b6e5572e0#n549

    It never did anything but when using the new API it actively throws an error.

  2. mwhudson commented on Oct 5, 2023

    @mwhudson
    Author

    I think it would be reasonable for mount -o remount,lowerdir=/something/new to error rather than silently do nothing but it's definitely surprising to me that remount,rw or remount,ro would fail.

    (It's probably not strictly necessary to call those in the boot process that's currently failing but it's definitely breaking something that used to work)

  3. t-8ch commented on Oct 5, 2023

    @t-8ch
    Member

    The best way forward would probably be to make sure to only set filesystem options that are not already set to the same value.

  4. karelzak commented on Nov 27, 2023

    @karelzak
    Collaborator

    Not sure if I see an error there. man mount:

              The remount functionality follows the standard way the mount command works with options
               from fstab. This means that mount does not read fstab (or mtab) only when both device and
               dir are specified.
    
               mount -o remount,rw /dev/foo /dir
    
               After this call all old mount options are replaced and arbitrary stuff from fstab (or
               mtab) is ignored, except the loop= option which is internally generated and maintained by
               the mount command.
    
               mount -o remount,rw /dir
    
               After this call, mount reads fstab and merges these options with the options from the
               command line (-o). If no mountpoint is found in fstab, then it defaults to mount options
               from /proc/self/mountinfo.
    

    And note there is also --options-mode <ignore, append, prepend, replace> to work wit options from fstab/mtab.

  5. karelzak commented on Nov 28, 2023

    @karelzak
    Collaborator

    Please let's continue the discussion on #2576 to keep it all in one place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions