2

Problem: During The Linux Boot, I want to know a certain instance of time, when all the block devices have been enumerated. I assume the block devices are NOT coming via a network( like iscsi), but come via FC, and could even be "multipath devices".

What I know:

If write a some script and set it up like

kernel.hotplug=MyScript and place it at /etc/sysconfig/MyScript.modules (notice the .modules extension).

I will get the devpath names of the devices being enumerated.

But this approach is not efficient.

Example : I want to act on the block devices have a different type of signature.

But, MyScript will get called all the times whenever any block device will be added to the system ( specifically whenever any kobject will be created/removed).

What I want do is:

Another instance in the boot sequence when I know that all the block devices attached are available, so that I can just find the block devices I like and do something I want with them.

Also, Notice that, I cannot wait till the xyz.service are enabled, which is quite late in the boot sequence.

Edit : Assume no systemd. Linux uses the old(init) way of booting.

0
$ systemctl status systemd-udev-settle
● systemd-udev-settle.service - udev Wait for Complete Device Initialization
   Loaded: loaded (/usr/lib/systemd/system/systemd-udev-settle.service; static; vendor preset: disabled)

$ systemctl --reverse list-dependencies systemd-udev-settle.service
systemd-udev-settle.service
● └─dmraid-activation.service

$ systemctl cat dmraid-activation.service
# /usr/lib/systemd/system/dmraid-activation.service
[Unit]
Description=Activation of DM RAID sets
DefaultDependencies=no
Conflicts=shutdown.target
After=systemd-udev-settle.service
Before=lvm2-activation-early.service cryptsetup.target local-fs-pre.target shutdown.target
Wants=systemd-udev-settle.service

Try copying the relevant lines from dmraid-activation.service above. This includes DefaultDependencies=no, since you insist on being as early as possible. It is documented in man systemd.unit (refers to systemd.service. Also you should read man bootup.

  • I should have added, What if there is no systemd, the system has old way of(init) way of booting. – rrai Dec 10 '16 at 12:51
  • you certainly should. then you get to write an init script with a header that indicates it's dependence on the udev-settle init script. This could potentially be forwards-compatible with systemd - provided the scripts being depended on all have service equivalents with the same (or aliased) names. – sourcejedi Dec 10 '16 at 13:12
  • How do I do that? – rrai Dec 10 '16 at 13:42
  • There is generic reference information at refspecs.linuxfoundation.org/LSB_3.1.0/LSB-Core-generic/… – sourcejedi Dec 10 '16 at 14:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.