removed lfs-commands
[linux_from_scratch.git] / bootscripts / contrib / new-boot-0.2 / sbin / init.d / runlevel.1 / mountfs
blob33bb44eb8a9a468bf9c3c8d67a18bc355460e12b
1 #! /bin/sh
3 # Mount local filesystems and activate swap
6 #locate and source functions script
7 source `PATH=$INIT_D/:${0%/*}/:${0%/*/*}/:${0%/*/*/*}/ type -p functions`
9 case "$1" in
10 start)
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
25 #about filesystems
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
37 mount -f /
38 else
39 cp /proc/mounts $INIT_ROOT/etc/mtab 2>/dev/null
40 fi
41 fi
43 echo 'Mounting local filesystems...'
44 if [ ! -r /etc/fstab ]; then
45 echo -n 'Cannot read /etc/fstab => cannot mount local filesystems!'
46 print_status failed
47 exit 1
48 else
49 mount -a
50 up_evaluate_retval || exit_if_any_error
51 fi
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
57 swapon -a
58 up_evaluate_retval
59 dmesg -n7 #allow all messages again
61 stop)
62 #deactivate swap *before* unmounting filesystems because swap files might
63 #prevent unmounting of fs (is this really an issue?)
64 echo 'Deactivating swap...'
65 swapoff -a
66 up_evaluate_retval
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
79 exit 1
81 esac
83 exit 0