At init level 6, the /etc/init.d/swap script is executed when all the system services are still alive. This causes a very slow shutdown time and possibly even the failure of swap deactivation on system with a moderate to high memory pressure. This is due to the fact that swap deactivation implies reclaiming all the swapped pages in memory, which: 1) may be a slow process if swap space is moderately used; 2) is useless, because that pages are going to be released anyway (often with very few accesses to them) when the owning service(s) stop; 3) may fail if free-memory < swapped-out-size. Please note every and each *nix system I put my fingers on was used to deactivate swap space after having stopped most services. The actual openrc approach in this is really unreasonable. Reproducible: Always Steps to Reproduce: 1. shutdown -h now 2. 3. Actual Results: (example) rc shutdown logging started at Fri Jan 27 09:55:02 2012 * Stopping local [ ok ] * Saving random seed ... [ ok ] * Deactivating swap devices ... [ ok ] * samba -> stop: smbd ... [ ok ] * samba -> stop: nmbd ... [ ok ] * Stopping sshd ... [ ok ] * Unmounting network filesystems ... [ ok ] * Stopping cupsd ... [ ok ] * Stopping syslog-ng ... [ ok ] * Stopping D-BUS system messagebus ... [ ok ] * Storing ALSA Mixer Levels ... [ ok ] * Unmounting loop devices * Unmounting filesystems * Unmounting /boot ... [ ok ] * Shutting down the Logical Volume Manager * Finished Shutting down the Logical Volume Manager * Stopping udevd ... [ ok ] Expected Results: (example) rc shutdown logging started at Fri Jan 27 09:55:02 2012 * Stopping local [ ok ] * Saving random seed ... [ ok ] * samba -> stop: smbd ... [ ok ] * samba -> stop: nmbd ... [ ok ] * Stopping sshd ... [ ok ] * Unmounting network filesystems ... [ ok ] * Stopping cupsd ... [ ok ] * Stopping syslog-ng ... [ ok ] * Stopping D-BUS system messagebus ... [ ok ] * Storing ALSA Mixer Levels ... [ ok ] * Deactivating swap devices ... [ ok ] * Unmounting loop devices * Unmounting filesystems * Unmounting /boot ... [ ok ] * Shutting down the Logical Volume Manager * Finished Shutting down the Logical Volume Manager * Stopping udevd ... [ ok ]
Is "swap" in your boot runlevel?
It is in my boot runlevel, and I can definitely confirm this issue: Below is my shutdown log. Notice how early swap is deactivated. rc shutdown logging started at Sat Dec 10 10:23:33 2011 * Stopping local [ ok ] * Stopping vixie-cron ... [ ok ] * Saving random seed ... [ ok ] * Deactivating swap devices ... [ ok ] * Use of the opts variable is deprecated and will be * removed in the future. * Please use extra_commands, extra_started_commands or extra_stopped_commands. * Stopping syslog-ng ... [ ok ] * Bringing down interface lo * Caching network module dependencies * Stopping D-BUS system messagebus ... [ ok ] * Use of the opts variable is deprecated and will be * removed in the future. * Please use extra_commands, extra_started_commands or extra_stopped_commands. * Storing ALSA Mixer Levels ... [ ok ] * Unmounting loop devices * Unmounting filesystems * Unmounting /tmp ... * in use but fuser finds nothing [ !! ] * Unmounting /srv ... [ ok ] * Unmounting /opt ... [ ok ] * Unmounting /usr/local ... [ ok ] * Unmounting /var ... [ ok ] * Unmounting /usr ... [ ok ] * Unmounting /home ... [ ok ] * Unmounting /boot ... [ ok ] * Stopping udev ... [ ok ] rc shutdown logging stopped at Sat Dec 10 10:23:37 2011
(In reply to comment #1) > Is "swap" in your boot runlevel? Yes, of course. This is from one of my gentoo box: xxx ~ # rc-update | grep swap swap | boot
Besides, I would suggest to merge (back?) the swap activation/deactivation stuff in /etc/init.d/localmount, which is the way most other *nixes do. Please note swap partitions are defined in /etc/fstab, so it seems reasonable to me to have them be handled by localmount.
For the record, in baselayout-1, swap was part of localmount. I have no idea why they were split in openrc. So, unless there is some reason not to, I do plan on merging them back together.
This is fixed in commit 79d6f10. I did not merge swap and localmount as I originally thought. Instead, we now have two separate swap scripts. Swap runs before localmount and swapfiles runs after localmount to handle the additional swap. They run in the opposite order when shutting down so that swapfiles are deactivated first, then local filesystems are unmounted and the rest of swap is deactivated.
*** Bug 407777 has been marked as a duplicate of this bug. ***