Skip to content
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

(RHEL-17394) fstab-generator: Chase symlinks where possible #150

Merged
merged 7 commits into from
Feb 7, 2024

Commits on Nov 27, 2023

  1. fstab-generator: Chase symlinks where possible (#6293)

    This has a long history; see see 5261ba9
    which originally introduced the behavior.  Unfortunately that commit
    doesn't include any rationale, but IIRC the basic issue is that
    systemd wants to model the real mount state as units, and symlinks
    make canonicalization much more difficult.
    
    At the same time, on a RHEL6 system (upstart), one can make e.g. `/home` a
    symlink, and things work as well as they always did; but one doesn't have
    access to the sophistication of mount units (dependencies, introspection, etc.)
    Supporting symlinks here will hence make it easier for people to do upgrades to
    RHEL7 and beyond.
    
    The `/home` as symlink case also appears prominently for OSTree; see
    https://ostree.readthedocs.io/en/latest/manual/adapting-existing/
    
    Further work has landed in the nspawn case for this; see e.g.
    d944dc9
    
    A basic limitation with doing this in the fstab generator (and that I hit while
    doing some testing) is that we obviously can't chase symlinks into mounts,
    since the generator runs early before mounts. Or at least - doing so would
    require multiple passes over the fstab data (as well as looking at existing
    mount units), and potentially doing multi-phase generation. I'm not sure it's
    worth doing that without a real world use case. For now, this will fix at least
    the OSTree + `/home` <https://bugzilla.redhat.com/show_bug.cgi?id=1382873> case
    mentioned above, and in general anyone who for whatever reason has symlinks in
    their `/etc/fstab`.
    
    (cherry picked from commit 634735b)
    
    Resolves: RHEL-17394
    cgwalters authored and brozs committed Nov 27, 2023
    Configuration menu
    Copy the full SHA
    b47f82a View commit details
    Browse the repository at this point in the history
  2. call chase_symlinks without the /sysroot prefix (#6411)

    In case fstab-generator is called in the initrd, chase_symlinks()
    returns with a canonical path "/sysroot/sysroot/<mountpoint>", if the
    "/sysroot" prefix is present in the path.
    
    This patch skips the "/sysroot" prefix for the chase_symlinks() call,
    because "/sysroot" is already the root directory and chase_symlinks()
    prepends the root directory in the canonical path returned.
    
    (cherry picked from commit 98eda38)
    
    Related: RHEL-17394
    haraldh authored and brozs committed Nov 27, 2023
    Configuration menu
    Copy the full SHA
    8eb5534 View commit details
    Browse the repository at this point in the history
  3. fstab-generator: downgrade message when we can't canonicalize fstab e…

    …ntries (#8281)
    
    Let's make this LOG_DEBUG, as this didn't used to be an issue, and
    shouldn't really be still.
    
    Replaces: #8132
    (cherry picked from commit f1a2c75)
    
    Related: RHEL-17394
    poettering authored and brozs committed Nov 27, 2023
    Configuration menu
    Copy the full SHA
    83cb24b View commit details
    Browse the repository at this point in the history
  4. Add $SYSTEMD_IN_INITRD=yes|no override for debugging

    Based on: 0307ea4
    Related: RHEL-17394
    
    rhel-only
    mrc0mmand committed Nov 27, 2023
    Configuration menu
    Copy the full SHA
    2d97c61 View commit details
    Browse the repository at this point in the history
  5. escape: call unit_name_is_valid() with correct flags

    Otherwise --template= simply doesn't work:
    
    $ ./systemd-escape --template=systemd-mkfs@.service --path /dev/test9
    is_valid: 0
    is_template: 1
    Template name systemd-mkfs@.service is not valid.
    
    Related: RHEL-17394
    
    rhel-only
    mrc0mmand committed Nov 27, 2023
    Configuration menu
    Copy the full SHA
    caa0c0a View commit details
    Browse the repository at this point in the history
  6. fstab-generator: fix ordering of /sysroot/usr mount

    According to bootup(7) and the behavior when /usr is specified in /etc/fstab, the /sysroot/usr mount should be before initrd-fs.target, not before initrd-root-fs.target.
    
    Related: RHEL-17394
    
    (cherry picked from commit 104bc12)
    nmartensen authored and mrc0mmand committed Nov 27, 2023
    Configuration menu
    Copy the full SHA
    656de45 View commit details
    Browse the repository at this point in the history
  7. test: backport TEST-81-GENERATORS (fstab-generator only)

    Some fstab-generator features are not present on RHEL 7 or they behave
    differently - in such case there's an inline comment explaining what's
    different with a reference to an upstream commit that introduced the
    changed behavior.
    
    Also, RHEL 7 systemd doesn't allow overriding (/sysroot)/etc/fstab or
    /proc/cmdline, so instead of backporting another bunch of potential
    risky commits, let's temporarily bind-mount a modified copy of necessary
    files in place of the expected ones. One exception is
    $SYSTEMD_IN_INITRD, since systemd checks if the mount for / is a tmpfs,
    which is a pain to mock, but the patch for that is, thankfully, pretty
    small.
    
    Related: RHEL-17394
    
    rhel-only
    mrc0mmand committed Nov 27, 2023
    Configuration menu
    Copy the full SHA
    ebf05d8 View commit details
    Browse the repository at this point in the history