I built a pxe client using a rootfs as an overlay between a nbd device and ram.
That works flawlessly until I try to shutdown or reboot. The problem is that systemd brings network down as soon as I ask a reboot.
So, any read from a new block (not in cache) will block the system.
I tried to add _netdev on every mount (/ and /read-only) but systemd keeps bringing network down.
I enabled the debug-shell which is enough to detect that eth0 is down and no wicked process is running
but I cannot do much more as anything not in the cache blocks.
How can I workaround it?
Is there a way to keep network always on during shutdown?
Or there is a way to run a command as soon as I call reboot/poweroff (on which I’ll call reboot/poweroff -f)?
A very provocative question: do PXE (disk-less) clients really need to shut-down cleanly?
[HR][/HR]Given that, the user data has been written away to the remote storage and, any logging information has been written away to the remote storage, the box can simply be powered off or rebooted.It’ll reload it’s Operating System from the PXE Server anyway . . .
It’s been my observation for a long time (things may have changed) that if you do a shutdown or reboot using the Desktop, the shutdown is very sudden and kills (does not shut down) services gracefully. This is something I’ve warned about if, for instance you’re running a database application in the middle of replication between instances.
In the past (prior to systemd because with init, there is no automatic management of processes and services), the workaround was to implement a timer which blindly guesses how long it might be for all networking to cease, even long running processes. Some of that code may still exist in today’s systems, or they may not. I have also seen intricate code to manage shutdowns which were largely handcrafted.
That is why traditionally,
I’ve always required these types of systems to be shut down manually, whereby the User manually shuts down the application, and then waits until it’s certain that all activity has ceased before shutting down the machine completely.
I suppose it’s possible to write your own systemd shutdown service, which simply shuts down your specified running services first, and only then invokes the normal shutdown/power off. The problem of course is how running activity is defined for the specified application(s), sometimes it’s not enough to simply monitor state.
Assuming you are using wicked - set interface STARTMODE to “nfsroot” (Activate Device == On NFSroot in YaST interface editor, General tab). Interfaces with STARTMODE=nfsroot are ignored by normal ifdown which is performed on shutdown.
@arvidjaar, it do work
The only problem is that wicked does not accept the existing ifcfg-eth0 file. It simply replace it with one using ifplugd.
I managed to fix this adding a hack in after.local replacing the STARTMODE value and reloading with wicked ifup eth0.
Now it works! But I wish wicked kept my existing file…