source: chapter07/checkfs.sgml@ f2cdbc5

10.0 10.0-rc1 10.1 10.1-rc1 11.0 11.0-rc1 11.0-rc2 11.0-rc3 11.1 11.1-rc1 11.2 11.2-rc1 11.3 11.3-rc1 12.0 12.0-rc1 12.1 12.1-rc1 6.0 6.1 6.1.1 6.3 6.4 6.5 6.6 6.7 6.8 7.0 7.1 7.2 7.3 7.4 7.5 7.5-systemd 7.6 7.6-systemd 7.7 7.7-systemd 7.8 7.8-systemd 7.9 7.9-systemd 8.0 8.1 8.2 8.3 8.4 9.0 9.1 arm bdubbs/gcc13 ml-11.0 multilib renodr/libudev-from-systemd s6-init trunk v3_0 v3_1 v3_2 v3_3 v4_0 v4_1 v5_0 v5_1 v5_1_1 xry111/arm64 xry111/arm64-12.0 xry111/clfs-ng xry111/lfs-next xry111/loongarch xry111/loongarch-12.0 xry111/loongarch-12.1 xry111/mips64el xry111/pip3 xry111/rust-wip-20221008 xry111/update-glibc
Last change on this file since f2cdbc5 was 6370fa6, checked in by Gerard Beekmans <gerard@…>, 23 years ago

Initial commit - LFS 2.4.4 files

git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@14 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

  • Property mode set to 100644
File size: 2.9 KB
Line 
1<sect1 id="ch07-checkfs">
2<title>Creating the checkfs script</title>
3
4<para>
5Create a new file <filename>/etc/init.d/checkfs</filename> containing
6the following:
7</para>
8
9<literallayout>
10
11<userinput>cat &gt; checkfs &lt;&lt; "EOF"</userinput>
12#!/bin/sh
13# Begin /etc/init.d/checkfs
14
15#
16# Include the functions declared in the /etc/init.d/functions file
17#
18
19source /etc/init.d/functions
20
21#
22# Activate all the swap partitions declared in the /etc/fstab file
23#
24
25echo -n "Activating swap..."
26/sbin/swapon -a
27evaluate_retval
28
29#
30# If the /fastboot file exists we don't want to run the partition checks
31#
32
33if [ -f /fastboot ]
34then
35 echo "Fast boot, no file system check"
36else
37
38#
39# Mount the root partition read-only (just in case the kernel mounts it
40# read-write and we don't want to run fsck on a read-write mounted
41# partition).
42#
43
44 /bin/mount -n -o remount,ro /
45 if [ $? = 0 ]
46 then
47
48#
49# If the /forcefsck file exists we want to force a partition check even
50# if the partition was unmounted cleanly the last time
51#
52
53 if [ -f /forcefsck ]
54 then
55 echo -n "/forcefsck exists, forcing "
56 echo "file system check"
57 force="-f"
58 else
59 force=""
60 fi
61
62#
63# Check all the file systems mentioned in /etc/fstab that have the
64# fs_passno value set to 1 or 2 (the 6th field. See man fstab for more
65# info)
66#
67
68 echo "Checking file systems..."
69 /sbin/fsck $force -a -A -C -T
70
71#
72# If something went wrong during the checks of one of the partitions,
73# fsck will exit with a return value greater than 1. If this is
74# the case we start sulogin so you can repair the damage manually
75#
76
77 if [ $? -gt 1 ]
78 then
79 $FAILURE
80 echo
81 echo -n "fsck failed. Please repair your file "
82 echo "systems manually by running /sbin/fsck"
83 echo "without the -a option"
84 echo
85 echo -n "Please note that the root file system "
86 echo "is currently mounted in read-only mode."
87 echo
88 echo -n "I will start sulogin now. When you "
89 echo "logout I will reboot your system."
90 echo
91 $NORMAL
92 /sbin/sulogin
93 /sbin/reboot -f
94 else
95 print_status success
96 fi
97
98 else
99
100#
101# If the remount to read-only mode didn't work abort the fsck and print
102# an error
103#
104
105 echo -n "Cannot check root file system because it "
106 echo "could not be mounted in read-only mode."
107 fi
108fi
109
110# End /etc/init.d/checkfs
111<userinput>EOF</userinput>
112
113</literallayout>
114
115</sect1>
116
Note: See TracBrowser for help on using the repository browser.