OK, so I have a simple problem: I have a live CD, and I want the CD to eject when the computer is rebooted or halted.
/usr/bin/eject -m makes the CD eject just fine... trouble is, as you might expect, this then crashes the OS because it now can't read any files. So the reboot never happens, because
/sbin/reboot is inaccessible. (I tried executing
reboot --help > /dev/null right before the reboot, but there are still other files which still can't be read...)
In summary, it appears that I need to make the eject be the very last thing that happens. So it seems that
systemd is the puppy I need to play with... But I have wasted literally hours of my life poking and prodding it, and no matter what I do, it never, ever, under any circumstances, actually ejects the CD. And I have no idea why. I've tried a dozen different ways of invoking
eject, but nothing ever happens.
Can anybody tell me the simplest way to run
eject? (I imagine just after
umount.target would be sensible...)