Eject CD on shutdown

Eventually my colleague found the following article:

http://lists.freedesktop.org/archives/systemd-devel/2012-September/006573.html

In summary, I created a file named /lib/systemd/system/eject.service which contains

[Unit]
Description=Eject the DVD
Before=final.target
After=shutdown.target
DefaultDependencies=no

[Service]
Type=oneshot
ExecStart=/usr/bin/eject -m
StandardInput=tty-force
StandardOutput=inherit
StandardError=inherit

[Install]
WantedBy=shutdown.target

I also had to run systemctl enable eject.service to make this actually do anything. But now systemd ejects the CD right before shutdown, exactly as I wanted.

...unfortunately the OS still segfaults when it can't find the rest of the files with the CD ejected. I tried adjusting the above file so we have After=unmount.target, which you would think runs the script after the filesystems have been unmounted. But no, still it segfaults.

It looks like I'm going to have to figure out how to copy the live CD image into RAM on boot - but that is an entire other question...