[systemd-devel] Need help detecting local/remote targets
Mantas Mikulėnas
grawity at gmail.com
Wed Aug 21 04:07:36 UTC 2019
On Wed, Aug 21, 2019, 01:15 Tony Rodriguez <unixpro1970 at gmail.com> wrote:
> I modified systemd-219 functionality to meet a custom requirement for
> detecting filesystems/devices that use iscsi without using the _netdev
> keyword in /etc/fstab. It is a strict requirement regarding not using
> _netdev that I have no control over. However, I am stuck.
>
> From my understanding, src/fstab-generator.c is used to determine
> LOCAL-FS and REMOTE-FS. I have modified fstab-generator.c to search for
> iscsi udev devices which works, provided the system is already fully
> booted (typical multi-user state type of thing). I can also find
> /dev/disk/ block devices including iscsi devices using my logic within
> fstab-generator.c. The problem is when the system reboots, it appears
> systemd using the same fstab-generator logic that I implemented is
> unable to detect any iscsi devices. After doing some research, it
> appears normal systemd behavior is to mount / and /usr then invoke
> fstab-generator.c to determine if a given filesystem in /etc/fstab
> should be a local or remote target.
>
/ and /usr are mounted by initramfs before systemd starts.
(If your initramfs itself uses systemd, that's mostly independent from the
main-root systemd – they're two separate worlds.)
> The problem is I have no way to tell if a given iscsi filesystem/device
> specified in /etc/fstab (without the _netdev keyord ) is local/remote
> during the booting state. Mainly because devices are not yet populated
> in /dev/disk or udev. Is there a way I can determine if a
> filesystem/mount point/device specified in /etc/fstab is local or remote
> without the _netdev or fstype (which handles nfs, etc) keywords within
> fstab-generator.c?
By design, generators run before any services have started, so no udev yet.
(But if you had udev in the initramfs, it could store data in /run that you
could then read from a generator.)
If checking udev and /dev/disk are not possible
> within fstab-generator.c, because such devices are not yet populated,
> then what should I modify within the systemd source so I can determine
> such local/remote targets myself and pass it to fstab-generator.c
> (especially when the system is in that / and /usr mounting state and
> udev devices are not yet populated?
>
If you can't use _netdev, then use custom options. Fstab now supports
arbitrary "x-" prefixed options, and systemd fstab generator already
recognizes several such as "x-systemd.requires=iscsid-is-ready.target". (I
think they're listed in the systemd.mount manpage?)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20190821/dfff1f4f/attachment.html>
More information about the systemd-devel
mailing list