[Mageia-dev] [soft-commits] [4379] fix shutting down

Colin Guthrie mageia at colin.guthr.ie
Thu May 3 12:47:52 CEST 2012


'Twas brillig, and Thomas Backlund at 03/05/12 10:45 did gyre and gimble:
> Colin Guthrie skrev 3.5.2012 12:33:
>> 'Twas brillig, and Thierry Vignaud at 03/05/12 09:05 did gyre and gimble:
>>> On 3 May 2012 09:53, Guillaume Rousse<guillomovitch at gmail.com>  wrote:
>>>>> please use system("/usr/bin/chvt", "1"), or system(qw(/usr/bin/chvt
>>>>> 1))
>>>>> instead in order to not fork useless shells.
>>>>
>>>> and kill is a perl builtin perl too:
>>>> kill SIGRTMAX-10, 1
>>>
>>> needs 'use POSIX;' though for symbolic values
>>
>> Actually none of the above. Please do it in the systemd unit itself with
>> ExecStartPre as this actually fixes the issues, whereas the internal
>> approach does not (at least in my tests) :)
>>
> 
> It seemed to work in vbox, but I'll retest the isos currently building

Ahh OK. I coudln't make it work in my vbox when doing it in the script,
but if it worked for you then it's probably fine.

>> In actual fact, this shut down script could be something that the
>> mgalive dracut module drops into /run/systemd/systemd. This would
>> prevent any poking at the installed file system and maybe allows for
>> easier hacking - i.e. no need to actually edit the squashfs filesystem
>> to tweak certain things.
>>
> 
> What/how should this look like ?

Basically the dracut module would add some kind hook that gets run
during the boot phase that would copy a unit file and a script to the
/run tree (/run/systemd/system/ folder)

This unit file could be called halt-local.service as this would override
the one in /lib/systemd/system/ folder of the installed system. The
dracut hook would also copy the script needed (i.e. the current
/sbin/halt.local) to somewhere in the run tree (I suggest
/run/mageia/live-halt or a similarly descriptive name) and the unit
copied previously would simply refer to it in it's ExecStart= line
rather than /sbin/halt.local.

I'm still not totally sure how the live CD's are built, but this may
make tweaking the images more easy than rebuilding the whole squashfs image?

Ping me on IRC if you want to discuss it further or if you want to to
make a change somewhere - tho' you'll need to point me at where to make
the change! :)



As a slightly more radical approach, dracut is also designed to allow a
pivot back into the initrd on shutdown/reboot.

It does so via these systemd files in the dracut package:
/lib/systemd/system/dracut-shutdown.service
/lib/systemd/system/reboot.target.wants/dracut-shutdown.service
/lib/systemd/system/shutdown.target.wants/dracut-shutdown.service

and this script:
/usr/lib/dracut/dracut-initramfs-restore

The key systemd file is the first one, the other two are just symlinks
to ensure it's run when needed.

The script itself is pretty simple and somewhat ugly (also it only
supports gziped initrds at present - although that should be trivial to
fix) and relies on naming conventions for initrds as there is no way to
know which initrd the current boot used AFAIK. I've suggest a workaround
for both to Harald upstream (short version ship these scripts inside
initrd and put them in /run too - use the name of the initrd passed on
dracut command line and you know the compression format used, so you
also know how to decompress - still not perfect but still a bit better IMO).

Anyway, this allows the initrd continue and there are late hooks we can
put into our custom dracut module to deal with the whole ejecting stuff.
Obviously anything needed to do this would have to be included in the
initramfs (so I don't think the current perl implementation is wise :p)

Anyway, this is more food for thought than practical suggestions at this
stage - one to think about tho' :)

Col


-- 

Colin Guthrie
colin(at)mageia.org
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited http://www.tribalogic.net/
Open Source:
  Mageia Contributor http://www.mageia.org/
  PulseAudio Hacker http://www.pulseaudio.org/
  Trac Hacker http://trac.edgewall.org/


More information about the Mageia-dev mailing list