Current-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Fixing swap1_stop
On Tue, 08 Aug 2017 09:10:53 -0400 "Ian D. Leroux"
<idleroux%fastmail.fm@localhost> wrote:
> On Thu, Aug 3, 2017, at 08:00, Ian D. Leroux wrote:
> > On Thu, 3 Aug 2017 10:54:30 +0000 (UTC) christos%astron.com@localhost
> > (Christos Zoulas) wrote:
> >
> > > In article <20170802215811.02ff2faba38001ebe4f531eb%fastmail.fm@localhost>,
> > > Ian D. Leroux <idleroux%fastmail.fm@localhost> wrote:
> > > >The patches stop swap1_stop from blindly unmounting a
> > > >tmpfs-mounted /dev/while the system is still running multi-user.
> > >
> > > [...]
> > >
> > > Why not just skip /dev?
I append a patch that does just that (almost identical to the code you
suggested, except that I'm a bit more paranoid when parsing the name of
the mount point). I've tested it lightly, but my current system only
has /var/shm on tmpfs.
However, after taking a closer look at /etc/rc.d/swap2, I no longer
understand why /etc/rc.d/swap1 has to unmount any filesystem, ever. As
I understood it, the rationale ran:
- swap can live in files, so we must remove swap before unmounting
filesystems
- tmpfs can live in swap, and if it is large then it may exceed
available (non-swap) RAM, so we must remove the tmpfs filesystems
before removing swap.
However, all the swap that lives in the filesystem (i.e. non-block-type
swap devices) is removed by /etc/rc.d/swap2, while the critical
filesystems are still mounted. By the time swap1_stop() runs, most of
the filesystem (and any swap that lived in files) is already gone. Why
can't we then just leave the (remaining, block-type) swap configured
until the system goes down? And if we do need to unmount tmpfs
filesystems, why are we doing it in swap1_stop() after we've already
(potentially) unmounted a chunk of (file-backed) swap rather than in
swap2, before we start removing swap devices?
Yours in growing perplexity,
-- IDL
--- /etc/rc.d/swap1.orig 2017-02-28 06:51:12.737058550 -0500
+++ /etc/rc.d/swap1 2017-08-08 20:50:55.065104788 -0400
@@ -13,6 +13,26 @@
start_cmd="swap1_start"
stop_cmd="swap1_stop"
+umount_tmpfs()
+{
+ echo -n "Forcibly unmounting tmpfs filesystems:"
+ mount -t tmpfs | while read -r line
+ do
+ dir=${line#tmpfs on }
+ dir=${dir% type tmpfs*}
+ case "$dir" in
+ /dev)
+ echo -n " [skipping $dir]"
+ ;;
+ *)
+ echo -n " $dir"
+ umount -f "$dir"
+ ;;
+ esac
+ done
+ echo "."
+}
+
# Add all block-type swap devices; these might be necessary
# during disk checks.
#
@@ -31,8 +51,7 @@
swap1_stop()
{
if checkyesno swapoff || [ -n "$rc_force" ]; then
- echo "Forcibly unmounting tmpfs filesystems"
- umount -aft tmpfs
+ umount_tmpfs
echo "Removing block-type swap devices"
swapctl -U -t blk || [ $? = 2 ]
fi
Home |
Main Index |
Thread Index |
Old Index