blob: d6f432dbdaf567d42662caa68166256947a1285e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
#! /bin/sh
#
# umountfs Turn off swap and unmount all local filesystems.
#
PATH=/sbin:/bin:/usr/sbin:/usr/bin
# Ensure /proc is mounted
test -r /proc/mounts || mount -t proc proc /proc
echo "Deactivating swap..."
swapoff -a
# We leave /proc mounted, the umount of /dev/devpts seems to fail
# quite frequently, the busybox umount apparently gives up at the
# first failure, so it is necessary to go file system by file
# system. It is necessary to go backward in the /proc list, because
# later things may have been mounted on earlier mounts.
devfs=
unmount() {
local dev mp type opts
if read dev mp type opts
then
# recurse - unmount later items
unmount
# skip /proc and /dev but not the sub-directories
case "$mp" in
/|/proc)return 0;;
/dev) devfs=1
return 0;;
esac
# then unmount this, if possible, otherwise make
# it read-only
umount -f -r "$mp"
fi
}
echo "Unmounting local filesystems..."
unmount </proc/mounts
# now /dev and read-only / (halt/reboot may need /proc!)
test -n "$devfs" && umount -f -r /dev
mount -o remount,ro /
|