mountfs.xml 2.7 KB

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