Opened 23 years ago

Closed 23 years ago

Last modified 23 years ago

#118 closed defect (invalid)

Some mistakes in /etc/init.d/checkfs

Reported by: JustusWinter@… Owned by: lfs-book@…
Priority: normal Milestone:
Component: Book Version: 3.0-pre4
Severity: minor Keywords:
Cc:

Description

Two mistakes in /etc/init.d/checkfs

1) There is a "fi" missing 2) It prints out a error message if fsck return 0 as return value

Please take a look at my modified version:

#!/bin/sh # Begin /etc/init.d/checkfs

# # Include the functions declared in the /etc/init.d/functions file #

source /etc/init.d/functions

# # Activate all the swap partitions declared in the /etc/fstab file #

echo -n "Activating swap..." /sbin/swapon -a evaluate_retval

# # If the /fastboot file exists we don't want to run the partition checks #

if [ -f /fastboot ] then

echo "Fast boot, no file system check"

else

# # Mount the root partition read-only (just in case the kernel mounts it # read-write and we don't want to run fsck on a read-write mounted # partition). #

/bin/mount -n -o remount,ro / if [ $? = 0 ] then

# # If the /forcefsck file exists we want to force a partition check even # if the partition was unmounted cleanly the last time #

if [ -f /forcefsck ] then

echo -n "/forcefsck exists, forcing " echo "file system check" force="-f"

else

force=""

fi

# # Check all the file systems mentioned in /etc/fstab that have the # fs_passno value set to 1 or 2 (the 6th field. See man fstab for more # info) #

echo "Checking file systems..." /sbin/fsck $force -a -A -C -T

# # If something went wrong during the checks of one of the partitions, # fsck will exit with a return value greater than 1. If this is # the case we start sulogin so you can repair the damage manually #

if [ $? -gt 1 ] then

$FAILURE echo echo -n "fsck failed. Please repair your file " echo "systems manually by running /sbin/fsck" echo "without the -a option" echo echo -n "Please note that the root file system " echo "is currently mounted in read-only mode." echo echo -n "I will start sulogin now. When you " echo "logout I will reboot your system." echo $NORMAL /sbin/sulogin /sbin/reboot -f

########################### here ##################################

# The following lines are IMHO nonsense. you check whether the return value # is greater than 1 and if it is for example 0 you print out this error # message. # # else # # # If the remount to read-only mode didn't work abort the fsck and print # an error # # # echo -n "Cannot check root file system because it " # echo "could not be mounted in read-only mode."

######################### and here ###############################

fi

##################################################################

fi

fi

# End /etc/init.d/checkfs

Change History (1)

comment:1 by gerard@…, 23 years ago

Resolution: invalid
Status: newclosed

First of all, there's no missing 'fi'. There are four opening 'if' statements and four closing 'fi' statements.

Perhaps you made a typo while copying the script from the book? Or if you used a bootscripts package let us know which version so we can fix it in there.

If not, then please fix the script but do not alter the way you did it with the error messages. That makes it harder to figure out where the missing fi might be.

Secondly about your "The following lines are IMHO nonsense" comment: They aren't. Your modifications now work like this:

if [ $? -gt 1 ] then

print some error lines, run sulogin and reboot afterwards

else

echo -n "Cannot check root file system because it " echo "could not be mounted in read-only mode.

fi

This isn't what happenes. If $? -gt 1 is true, then it doesn't mean the root file system could not be mounted in read-only mode. If $? -gt 1 is true, it means that the root fs was mounted readonly, but that the checks of file systems failed.

With your modifications nothing happens when the root file couldn't be (re-)mounted in read-only mode. At the very least it should run "print_status failed" But as it is, it'll also tell you what exactly went wrong. checkfs is pretty important to your system, so these extra errors are good practise.

I'll mark this bug as invalid for now.

Note: See TracTickets for help on using tickets.