summaryrefslogtreecommitdiffstats
path: root/src/fstab-generator (follow)
Commit message (Collapse)AuthorAgeFilesLines
* sysroot: Support x-systemd.makefsWill Fancher2022-12-121-3/+12
|
* basic: create new basic/initrd-util.[ch] for initrd-related functionsZbigniew Jędrzejewski-Szmek2022-11-081-1/+1
| | | | | | | | | I changed imports of util.h to initrd-util.h, or added an import of initrd-util.h, to keep compilation working. It turns out that many files didn't import util.h directly. When viewing the patch, don't be confused by git rename detection logic: a new .c file is added and two functions moved into it.
* fstab-generator: add mode to check /sysroot/etc/fstab and maybe do daemon-reloadZbigniew Jędrzejewski-Szmek2022-07-231-8/+110
| | | | | | | | | | | The idea is that we can peek into /sysroot/etc/fstab and figure out if there's anything interesting there. We could use a separate binary for this, but we'd need to duplicate most of the logic that in systemd-fstab-generator. Thus I think it's nicer to make systemd-fstab-generator work as a multi-call binary. If called as systemd-sysroot-fstab-check, we look for units that we'd mount and call daemon-reload and initrd-fs.target/restart, similarly to what we did before, but in the process itself.
* fstab-generator: do not skip /sysroot prefix if the mount point is missingZbigniew Jędrzejewski-Szmek2022-07-151-4/+16
| | | | | | | | | When chase_symlinks() is called on something on a doesn't exist, it immediately returns an error. But we were relying on it to prepend "/sysroot/". If it fails, we need to do that ourselves. For example, with /sysroot/etc/fstab containing a line for /foo, if /sysroot/foo doesn't exist, we'd generate a mount point for /foo.
* fstab-generator: rename 'post' variableZbigniew Jędrzejewski-Szmek2022-07-151-16/+13
| | | | | | | Originally (6b1dc2bd3cdb3bd932b0692be636ddd2879edb92) we had 'pre' and 'post' to refer to remote-fs-pre.target and remote-fs.target or local-fs-pre.target and local-fs.target. But 'pre' is long gone, and 'post' by itself doesn't make much sense. Rename it for clarity.
* fstab-generator: tweak commentsZbigniew Jędrzejewski-Szmek2022-07-151-2/+2
|
* fstab-generator: allow overriding path to /sysroot/etc/fstab tooZbigniew Jędrzejewski-Szmek2022-07-151-1/+9
| | | | This adds $SYSTEMD_SYSROOT_FSTAB analoguous to $SYSTEMD_FSTAB.
* fstab-generator: properly report the source of dataZbigniew Jędrzejewski-Szmek2022-07-151-22/+23
| | | | | | | | Mount information can come from /etc/fstab, /sysroot/etc/fstab, and /proc/cmdline. Even when we had the path to the right source handy, we would often write something inaccurate. In particular, in the initrd, we would generally write "/etc/fstab" instead of "/sysroot/etc/fstab" for no good reason.
* fstab-generator: use path_equal() to detect alternate spellings of /usrZbigniew Jędrzejewski-Szmek2022-07-151-1/+1
| | | | | In the initrd we would treat e.g. "/usr/" as different from "/usr", which doesn't seem right.
* strv: make iterator in STRV_FOREACH() declaread in the loopYu Watanabe2022-03-191-3/+0
| | | | This also avoids multiple evaluations in STRV_FOREACH_BACKWARDS()
* fstab-generator: use str(n)dupa_safe() instead of plain str(n)dupa()Frantisek Sumsal2022-01-291-2/+2
|
* fstab-generator: also skip other network filesystems and live imageYu Watanabe2022-01-061-0/+15
|
* fstab-generator: skip root directory handling when nfsroot is requestedYu Watanabe2022-01-061-2/+57
| | | | Fixes RHBZ#2037233 (https://bugzilla.redhat.com/show_bug.cgi?id=2037233).
* fstab-generator: do not remount /sys when running in a containerYu Watanabe2021-12-141-3/+10
| | | | Closes #21744.
* Merge pull request #20598 from tomty89/order_noautoZbigniew Jędrzejewski-Szmek2021-12-111-2/+1
|\ | | | | fstab-generator, core/mount: Avoid special fs target before dependency only if nofail is used
| * fstab-generator: also order noauto or automount mount units before "post" ↵Tom Yan2021-09-011-2/+1
| | | | | | | | | | | | | | | | target units The ordering should not prevent noauto or automount from working as expected, and we do not want them to be stopped too early if they are active.
* | fstab-generator: use 'usr' mapper device when 'usrhash' is presentMark Boudreau2021-11-191-7/+28
| | | | | | | | | | If 'usrhash' is present as a kernel command line parameter, use the usr mapper device for usr mount
* | basic: spit out chase_symlinks() from fs-util.[ch] → chase-symlinks.[ch]Lennart Poettering2021-10-051-1/+1
|/
* fstab-generator: Respect nofail when orderingVladimir Panteleev2021-08-181-1/+2
|
* fstab-generator: put What= before Where=Zbigniew Jędrzejewski-Szmek2021-08-101-4/+4
| | | | | | | | All units in units/ follow this pattern, as do all other generators that we provide. The question of the order was raised in https://github.com/systemd/zram-generator/pull/90#discussion_r684965984, and I think it's nice to make it consistent everywhere (What= before Where= matches mount(8) and fstab(5)).
* tree-wide: add FORMAT_TIMESPAN()Zbigniew Jędrzejewski-Szmek2021-07-091-2/+1
|
* tree-wide: always drop unnecessary dot in pathYu Watanabe2021-05-281-1/+1
|
* meson: use jinja2 for rpm templatesZbigniew Jędrzejewski-Szmek2021-05-191-1/+1
| | | | | | | The naming of variables is very inconsistent. I tried to use more modern style naming (UNDERSCORED_TITLE_CASE), but I didn't change existing names too much. Only SYSTEM_DATA_UNIT_PATH is renamed to SYSTEM_DATA_UNIT_DIR to match SYSTEM_CONFIG_UNIT_DIR.
* fstab-generator: clean up mount point flags handlingLennart Poettering2021-04-231-39/+48
| | | | | | | | | | | | Let's rename MountpointsFlags → MountPointFlags. In most of our codebase we name things mount_point/MountPoint rather than mountpoint/Mountpoint, do so here too. Also, prefix the enum values with "MOUNT_". The fact the enum values weren#t prefixed was pretty unique in our codebase, and pretty surprising. Let's fix that. This is just refactoring, no actual change in behaviour
* fstab-generator: properly order generated mount units before "post" target unitsLennart Poettering2021-04-201-0/+5
| | | | | | Let's make sure, that our mount unit are properly ordered before the "post" target unit even if DefaultDependencies= is used on the target unit.
* fstab-generator: extend logging a bitLennart Poettering2021-04-201-1/+1
|
* fstab-generator: if usr= is specified, mount it to /sysusr/usr/ firstLennart Poettering2021-04-201-13/+77
| | | | | | | | | | | | | | | This changes the fstab-generator to handle mounting of /usr/ a bit differently than before. Instead of immediately mounting the fs to /sysroot/usr/ we'll first mount it to /sysusr/usr/ and then add a separate bind mount that mounts it from /sysusr/usr/ to /sysroot/usr/. This way we can access /usr independently of the root fs, without for waiting to be mounted via the /sysusr/ hierarchy. This is useful for invoking systemd-repart while a root fs doesn't exist yet and for creating it, with partition data read from the /usr/ hierarchy. This introduces a new generic target initrd-usr-fs.target that may be used to generically order services against /sysusr/ to become available.
* tree-wide: avoid uninitialized warning on _cleanup_ variablesLuca Boccassi2021-04-141-1/+1
| | | | | | | With some versions of the compiler, the _cleanup_ attr makes it think the variable might be freed/closed when uninitialized, even though it cannot happen. The added cost is small enough to be worth the benefit, and optimized builds will help reduce it even further.
* fstab-generator: get rid of fstab_extract_values()Zbigniew Jędrzejewski-Szmek2021-03-111-7/+7
| | | | | | | This was a parallel implementation of option parsing that didn't support escaping of separators. Let's port this over to the common code. Fixes #18952.
* shared/fstab-util: teach fstab_filter_options() a mode where all values are ↵Zbigniew Jędrzejewski-Szmek2021-03-111-1/+1
| | | | | | | | | | returned Apart from tests, the new argument isn't used anywhere, so there should be no functional change. Note that the two arms of the big conditional are switched, so the diff is artificially inflated. The actual code change is rather small. I dropped the path which extracts ret_value manually, because it wasn't supporting unescaping of the escape character properly.
* fstab-generator: do not propagate error if we fail to canonicalizeZbigniew Jędrzejewski-Szmek2021-03-101-3/+3
| | | | | r is used for the return value of the function, so we shouldn't use it a non-fatal check.
* fstab-generator: fix typoYu Watanabe2021-03-061-4/+4
|
* fstab-generator: add new root=tmpfs optionLennart Poettering2021-03-031-6/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's useful to be able to combine a regular /usr/ file system with a tmpfs as root, for an OS that boots up in volatile mode on every single boot. Let's add explicit support for this via root=tmpfs. Note the relationship to the existing systemd.volatile= option: 1. The kernel command line "root=/dev/… systemd.volatile=yes" will mount the specified root fs, and then hide everything at the top by overmounting it with a tmpfs, except for the /usr subtree. 2. The kernel command line "root=tmpfs mount.usr=/dev/…" otoh will mount a toot fs at the top (just like the case above), but will then mount the top-level dir of the fs specified in mount.usr= directly below it. Or to say this differently: in the first case /usr/ from the physical storage fs is going to become /usr/ of the hierarchy ultimately booted, while in the second case / from the physical storage fs is going to become /usr of the hierarchy booted. Philosophically I figure systemd.volatile= is more an option for "one-off" boots, while root=tmpfs is something to have as default mode of operation for suitable images. This is currently hard to test reasonably, since Dracut refuses to accept root=tmpfs. This needs to be addressed separately though.
* tree-wide: use free_and_strdup_warn()Yu Watanabe2021-02-111-10/+5
|
* tree-wide: propagate error code from _from_string() functionsZbigniew Jędrzejewski-Szmek2021-02-101-1/+1
| | | | Now that we know we have something useful, no need to make an answer up.
* string-util: imply NULL termination of strextend() argument listLennart Poettering2021-01-061-2/+2
| | | | | The trailing NULL in the argument list is now implied (similar to what we already have in place in strjoin()).
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* fstab-generator: add 'nofail' when NFS 'bg' option is usedFranck Bui2020-09-151-1/+1
| | | | | Otherwise a 'Before=remote-fs.target' dependency is added to the mount unit which defeats the purpose of 'bg' option.
* fstab-generator: introduce an helper to write extra dependencies specified ↵Franck Bui2020-07-011-14/+26
| | | | | | via the mount options No functional change.
* fstab-generator: extra dependencies specified in fstab should be applied to ↵Franck Bui2020-07-011-16/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | the mount unit If an entry in fstab uses "x-systemd.automount" option and also asks for additionnal dependencies via x-systemd.requires or such, then the dependencies were applied to the automount unit. But this unlikely to do the right thing and is inconsistent with what's done for network mounts. Indeed when an fstab entries has "_netdev,x-systemd.automount" options, the dependencies against the network requested by "_netdev" are (correctly) applied to the mount unit only and the automount unit remains ordered against local-fs.target. The same logic should be followed when extra deps are specified via the mount options as automount units should always be ordered against local-fs.target. Note: in general explicit deps specified via mount options should be used with care and should be used to specify dependencies on other mount units only as it can easily create ordering cycles otherwise like it's been seen in https://github.com/systemd/systemd-stable/issues/69. Mount units (as well as automount ones) are ordered before local-fs.target by default which is a low-level target that most other units depend on.
* tree-wide: use DISABLE_WARNING_FORMAT_NONLITERAL where appropriateLennart Poettering2020-05-251-3/+3
|
* Merge pull request #15661 from hundeboll/mount-read-write-onlyZbigniew Jędrzejewski-Szmek2020-05-201-2/+7
|\ | | | | Mount read write only
| * fstab-generator: add x-systemd.rw-only option supportMartin Hundebøll2020-05-201-2/+7
| | | | | | | | | | Support enabling the ReadwriteOnly= unit setting from fstab using 'x-systemd.rw-only'
* | Merge pull request #15265 from fbuihuu/mount-fixesLennart Poettering2020-05-151-11/+0
|\ \ | | | | | | Mount fixes
| * | automount: fix handling of default dependencies for automount unitsFranck Bui2020-04-091-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | First After=local-fs-pre.target wasn't described in the man page although it's part of the default dependencies automatically set by pid1. Secondly, Before=local-fs.target was only set if the automount unit was generated from the fstab-generator because the dep was explicitly generated. It was also not documented as a default dependency. Fix it by managing the dep from pid1 instead.
| * | mount: let pid1 alone handle the default dependencies for mount unitsFranck Bui2020-04-091-9/+0
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | fstab-generator was also handling the default ordering dependencies for mount units setup in initrd. To do that it was turning the defaults dependencies off completely and ordered the mount unit against either local-fs.target or initrd-fs.target or initrd-root-fs.target itself. But it had the bad side effect to also remove all other default dependencies as well. Thus if an initrd mount was using _netdev, the network dependencies were missing. In general fstab-generator shouldn't use DefaultDependecies=no because it can handle only a small set of the default dependencies the rest are dealt by pid1. So this patch makes pid1 handle all default dependencies.
* / tree-wide: add size limits for tmpfs mountsTopi Miettinen2020-05-131-1/+1
|/ | | | | | | | | | | | | | | | | Limit size of various tmpfs mounts to 10% of RAM, except volatile root and /var to 25%. Another exception is made for /dev (also /devs for PrivateDevices) and /sys/fs/cgroup since no (or very few) regular files are expected to be used. In addition, since directories, symbolic links, device specials and xattrs are not counted towards the size= limit, number of inodes is also limited correspondingly: 4MB size translates to 1k of inodes (assuming 4k each), 10% of RAM (using 16GB of RAM as baseline) translates to 400k and 25% to 1M inodes. Because nr_inodes option can't use ratios like size option, there's an unfortunate side effect that with small memory systems the limit may be on the too large side. Also, on an extremely small device with only 256MB of RAM, 10% of RAM for /run may not be enough for re-exec of PID1 because 16MB of free space is required.
* fstab-generator: handle systemd.swap= command-line argumentnabijaczleweli2020-03-121-0/+14
| | | | | | | | | | | | Don't generate swap units if set to false The inverse of this argument is present as "noswap" on Debian sysvinit Ref: https://salsa.debian.org/debian/sysvinit/blob/4422988cb41c3022eee7444378cac3b2e36eac28/debian/vars.sh#L34 https://salsa.debian.org/debian/sysvinit/blob/4422988cb41c3022eee7444378cac3b2e36eac28/debian/src/initscripts/etc/init.d/mountall.sh#L78 Fixes https://github.com/systemd/systemd/issues/6686
* units: introduce blockdev@.target for properly ordering mounts/swaps against ↵Lennart Poettering2020-01-211-6/+20
| | | | | | | | | cryptsetup Let's hook it into both cryptsetup-generator and gpt-auto-generator with a shared implementation in generator.c Fixes: #8472
* fstab-generator: line break a bit more systematicallyLennart Poettering2020-01-211-5/+16
|