[6370fa6] | 1 | <sect1 id="ch07-mountfs">
|
---|
| 2 | <title>Creating the mountfs script</title>
|
---|
| 3 |
|
---|
[b822811] | 4 | <para>Create the <filename>/etc/init.d/mountfs</filename> script by running
|
---|
| 5 | the following command:</para>
|
---|
| 6 |
|
---|
[b1772b15] | 7 | <para><screen><userinput>cat > /etc/init.d/mountfs << "EOF"</userinput>
|
---|
[6370fa6] | 8 | #!/bin/sh
|
---|
| 9 | # Begin /etc/init.d/mountfs
|
---|
| 10 |
|
---|
| 11 | #
|
---|
| 12 | # Include the functions declared in the /etc/init.d/functions file
|
---|
| 13 | #
|
---|
| 14 |
|
---|
| 15 | source /etc/init.d/functions
|
---|
| 16 |
|
---|
| 17 | case "$1" in
|
---|
| 18 | start)
|
---|
| 19 |
|
---|
| 20 | #
|
---|
| 21 | # Remount the root partition in read-write mode. -n tells mount
|
---|
| 22 | # not to
|
---|
| 23 | # write to the /etc/mtab file (because it can't do this. The
|
---|
| 24 | # root
|
---|
| 25 | # partition is most likely still mounted in read-only mode
|
---|
| 26 | #
|
---|
| 27 |
|
---|
| 28 | echo -n "Remounting root file system in read-write mode..."
|
---|
| 29 | /bin/mount -n -o remount,rw /
|
---|
| 30 | evaluate_retval
|
---|
| 31 |
|
---|
| 32 | #
|
---|
| 33 | # First empty the /etc/mtab file. Then remount root partition
|
---|
| 34 | # in read-write
|
---|
| 35 | # mode again but pass -f to mount. This way mount does
|
---|
| 36 | # everything
|
---|
| 37 | # except the mount itself. This is needed for it to write to the
|
---|
| 38 | # mtab
|
---|
| 39 | # file which contains a list of currently mounted file systems.
|
---|
| 40 | #
|
---|
| 41 |
|
---|
[b822811] | 42 | echo > /etc/mtab
|
---|
[6370fa6] | 43 | /bin/mount -f -o remount,rw /
|
---|
| 44 |
|
---|
| 45 | #
|
---|
| 46 | # Remove the possible /fastboot and /forcefsck files. they are
|
---|
| 47 | # only
|
---|
[4d994af4] | 48 | # supposed to be used during the next reboot's checkfs which just
|
---|
[6370fa6] | 49 | # happened. If you want to fastboot or forcefsck again you'll
|
---|
| 50 | # have to
|
---|
| 51 | # recreate the files
|
---|
| 52 | #
|
---|
| 53 |
|
---|
[c3feda7] | 54 | /bin/rm /fastboot /forcefsck
|
---|
[6370fa6] | 55 |
|
---|
| 56 | #
|
---|
| 57 | # Walk through /etc/fstab and mount all file systems that don't
|
---|
| 58 | # have the noauto option set in the fs_mntops field (the 4th
|
---|
| 59 | # field.
|
---|
| 60 | # See man fstab for more info)
|
---|
| 61 | #
|
---|
| 62 |
|
---|
| 63 | echo -n "Mounting other file systems..."
|
---|
| 64 | /bin/mount -a
|
---|
| 65 | evaluate_retval
|
---|
| 66 | ;;
|
---|
| 67 |
|
---|
| 68 | stop)
|
---|
| 69 |
|
---|
| 70 | #
|
---|
[4d994af4] | 71 | # Deactivate all the swap partitions
|
---|
[6370fa6] | 72 | #
|
---|
| 73 |
|
---|
| 74 | echo -n "Deactivating swap..."
|
---|
| 75 | /sbin/swapoff -a
|
---|
| 76 | evaluate_retval
|
---|
| 77 |
|
---|
| 78 | #
|
---|
| 79 | # And unmount all the file systems, mounting the root file
|
---|
| 80 | # system
|
---|
| 81 | # read-only (all are unmounted but because root can't be
|
---|
| 82 | # unmounted
|
---|
| 83 | # at this point mount will automatically mount it read-only
|
---|
| 84 | # which
|
---|
| 85 | # is what supposed to happen. This way no data can be written
|
---|
| 86 | # anymore from disk)
|
---|
| 87 | #
|
---|
| 88 |
|
---|
| 89 | echo -n "Unmounting file systems..."
|
---|
| 90 | /bin/umount -a -r
|
---|
| 91 | evaluate_retval
|
---|
| 92 | ;;
|
---|
| 93 |
|
---|
| 94 | *)
|
---|
| 95 | echo "Usage: $0 {start|stop}"
|
---|
| 96 | exit 1
|
---|
| 97 | ;;
|
---|
| 98 | esac
|
---|
| 99 |
|
---|
| 100 | # End /etc/init.d/mountfs
|
---|
[b822811] | 101 | <userinput>EOF</userinput></screen></para>
|
---|
[6370fa6] | 102 |
|
---|
| 103 | </sect1>
|
---|
| 104 |
|
---|