Improper filesystem unmount order (swap on files)
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
sysvinit (Debian) |
Fix Released
|
Unknown
|
|||
sysvinit (Ubuntu) |
Fix Released
|
Wishlist
|
Unassigned |
Bug Description
Binary package hint: initscripts
When turning off my computer, I noticed one `failed' status line. It was:
* Unmounting local filesystems [fail]
Followed by:
* Deactivating swap [ok]
Since I use ordinary files instead of dedicated partitions for swap, I found that very natural. I also think it is more than just a valid usage pattern (no problems with resizing partitions etc) and with regards to that, suggest the following patch to /etc/init.
20,40c20
< # List all mounts, deepest mount point first
< LANG=C sort -r -k 2 /etc/mtab |
< (
< DIRS=""
< while read DEV DIR TYPE REST ; do
< if [ "x$TYPE" == "xtmpfs"]; then
< DIRS="$DIRS $DIR" # Unmount tmpfs before turning off swap
< fi
< done
< umount -r -d $DIRS
< )
<
< # Make sure tmpfs file systems are umounted before turning off
< # swap, to avoid running out of memory if the tmpfs filesystems
< # use a lot of space.
< log_action_
< swapoff -a
< log_action_end_msg $?
<
< # Umount all filesystems now
---
> # Umount all filesystems except root and the virtual ones
63a44,50
>
> # Make sure tmpfs file systems are umounted before turning off
> # swap, to avoid running out of memory if the tmpfs filesystems
> # use a lot of space.
> log_action_
> swapoff -a
> log_action_end_msg $?
It firstly unmounts tmpfs, then deactivas swap and remaining
filesystems lastly. I'd like to hear if there are any reasons for not
applying this patch, if any.
Changed in sysvinit: | |
importance: | Medium → Wishlist |
status: | Unconfirmed → Confirmed |
Changed in sysvinit: | |
status: | Unknown → Fix Released |
On Fri, Sep 16, 2005 at 10:55:37AM +0200, johannes wrote: d/umountfs first tries to unmount all local filesystems and then deactivates all swap d/umountfs in such a way that it first calls swapoff and then unmounts the local filesystems it works correctly
> hi all,
>
> i'm using a swapfile in a file on a local filesystem "/data/swapfile" (not a swap partition!)
> during shutdown /etc/init.
> but unmounting of the partitition wich has the swapfile "/data" fails because the swapfile is still active
>
> if i change /etc/init.
>
I think it should unmount all tmpfs'es (except /dev and similar) first.
Then it can safely turn off swapping. Doing it in reverse order could
cause trouble in some configurations (eg. /tmp as tmpfs).
Something like this:
do_stop () {
continue
# Umount all memory filesystems except /dev
log_begin_msg "Unmounting memory filesystems..."
LANG=C sort -r -k 2 /etc/mtab |
(
DIRS=""
while read DEV DIR TYPE REST ; do
case "$TYPE" in
tmpfs)
;;
*)
;;
esac
case "$DIR" in
continue
/dev)
;;
esac
DIRS="$DIRS $DIR"
done
umount -r -d $DIRS
)
log_end_msg $?
log_begin_msg "Deactivating swap..."
swapoff -a
log_end_msg $?
# Umount all filesystems except root and the virtual ones
log_begin_msg "Unmounting local filesystems..."
# List all mounts, deepest mount point first /dev|/. dev|/dev/ pts|/proc/ *|/sys)
LANG=C sort -r -k 2 /etc/mtab |
(
DIRS=""
while read DEV DIR TYPE REST ; do
case "$DIR" in
/|/proc|
continue # Ignoring virtual file systems needed later
;;
esac
case $TYPE in
proc|procfs| linprocfs| devfs|sysfs| usbfs|usbdevfs| devpts)
continue # Ignoring non-tmpfs virtual file systems
;;
esac
DIRS="$DIRS $DIR"
done
umount -r -d $DIRS
)
log_end_msg $?
}
--
Marcel Sebek