Rebooter
I briefly mentioned that I was debugging a boot hang. Since the hang does not happen every time I try to boot, it may take a couple of reboots to get the kernel to hang. Doing this manually is tedious. Thankfully it can be scripted. Therefore, I made a simple script and a SMF manifest that runs the script at the end of boot. If the system boots fine, my script reboots it. If the system hangs mid-boot, well my script never executes leaving the system in a hung state. Then, I can break into the kernel debugger (mdb) and investigate.
I’m sharing the two here mostly for my benefit… in case one day in the future I decide that I need my system automatically rebooted over and over again.
The script is pretty simple. Hopefully, 60 seconds is long enough to log in and disable the service if necessary. (In reality, I setup a separate boot environment that’s the default choice in Grub. I can just select my normal boot environment and get back to non-timebomb system.)
#!/bin/sh sleep 60 reboot -p
The tricky part is of course in the manifest. Not because it is hard, but because XML is … verbose.
<?xml version="1.0"?> <!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1"> <service_bundle type='manifest' name='rebooter'> <service name='site/rebooter' type='service' version='1'> <dependency name='booted' grouping='require_all' restart_on='none' type='service'> <service_fmri value='svc:/milestone/multi-user-server:default'/> </dependency> <property_group name="startd" type="framework"> <propval name="duration" type="astring" value="child"/> <propval name="ignore_error" type="astring" value="core,signal"/> </property_group> <instance name='system' enabled='true'> <exec_method type='method' name='start' exec='/home/jeffpc/illumos/rebooter/script.sh' timeout_seconds='0' /> <exec_method type='method' name='stop' exec=':true' timeout_seconds='0' /> </instance> <stability value='Unstable' /> </service> </service_bundle>
That’s all, carry on what you were doing. :)