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