source: chapter07/checkfs.xml@ 4c63d1e

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_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 4c63d1e was e12115e, checked in by Gerard Beekmans <gerard@…>, 23 years ago

added <?dbhtml> tag for output redirection into subdir

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

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