3 # Mount local filesystems and activate swap
6 #locate and source functions script
7 source `PATH=$INIT_D/:${0%/*}/:${0%/*/*}/:${0%/*/*/*}/ type -p functions`
11 need
$checked_filesystems || exit_if_fatal_error
13 echo 'Remounting root file system in read-write mode...'
14 mount
-n -o remount
,rw
/
15 up_evaluate_retval || exit_if_any_error
17 #clear mtab to make sure there is no wrong data that could confuse
18 #the following mounting of /proc
19 echo > $INIT_ROOT/etc
/mtab
21 #try to mount /proc to have /proc/mounts available
22 mount
-t proc proc
/proc
2>/dev
/null
24 #try to copy /proc/mounts to /etc/mtab to get correct information
26 #We filter the entry for the / partition if it is called /dev/root
27 #because older versions of e2fsck are unable to deal with it properly.
28 #If we filter it out, we use a fake mount to add it back with the name
29 #from fstab (which said old e2fsck version expects)
30 if [ -e /proc
/mounts
]; then
31 x
="`expr "$
(</proc
/mounts
)" : '\(.*\)'$'/dev/root[ \t].*'`"
32 y
="`expr "$
(</proc
/mounts
)" : $'.*/dev/root[ \t][^\n]*\n''\(.*\)'`"
33 if [ -n "$x" ]; then x
="$x"$
'\n' ; fi
34 if [ -n "$y" ]; then y
="$y"$
'\n' ; fi
35 if [ -n "$x$y" ]; then
36 echo -n "$x$y" > $INIT_ROOT/etc
/mtab
39 cp /proc
/mounts
$INIT_ROOT/etc
/mtab
2>/dev
/null
43 echo 'Mounting local filesystems...'
44 if [ ! -r /etc
/fstab
]; then
45 echo -n 'Cannot read /etc/fstab => cannot mount local filesystems!'
50 up_evaluate_retval || exit_if_any_error
53 #add swap space *after* mounting filesystems because swap files might
54 #be located on an otherwise unmounted fs (is this really an issue?)
55 echo Adding swap space...
56 dmesg
-n6 #prevent message from swapon
59 dmesg
-n7 #allow all messages again
62 #deactivate swap *before* unmounting filesystems because swap files might
63 #prevent unmounting of fs (is this really an issue?)
64 echo 'Deactivating swap...'
68 #first fake the mount so that mtab is written properly as long
69 #as / still mounted rw
70 mount
-f -o remount
,ro
/
72 #unmount all filesystems except devfs and proc to avoid "none busy"
73 #warning. / is remounted read-only because it can't be unmounted
74 echo 'Unmounting local fs and remounting / read-only...'
75 umount
-a -r -t nodevfs
,noproc
76 up_evaluate_retval || exit_if_any_error