How can I force fsck on next boot on Red Hat Enterprise Linux?

By default, the fsck utility is run on every boot. For ext3 filesystems, the boot scripts do a quick check to see if the filesystem journal indicates the file system is clean. If the initial check passes no further checking is performed. Otherwise, the user is prompted to run a full fsck check.

You can force an automatic full check by changing the check interval using tune2fs (-c and/or -i). For example:

# tune2fs -c 1 /dev/hda2

The above command would tell the init scripts to run fsck on hda2 at every boot.

# tune2fs -i 1d /dev/hda2

The above command would tell the init scripts to run fsck on hda2 after 1 day.

If you only want to run fsck on the next boot, please execute the following as the root user:

# cd /
# touch forcefsck

This will only run the file system check on the next reboot. By touching the file “forcefsck” in the / directory, it will force the system to perform a full file system check.

The file “forcefsck” will be deleted automatically after fsck is finished.

Note: For systems with large disks, fsck on boot may take a long time to run depending on system speed and disk sizes.

How to reload sysctl.conf variables on Linux

The sysctl command is used to modify Linux kernel variables at runtime. The variables are read and write from /proc/sys/ location using procfs. The syntax is as follows for to define variable:


Read variable from command line

Type the following command
$ sysctl kernel.ostype
Sample outputs:

kernel.ostype = Linux
To see all variables pass the -a option:
 $ sysctl -a
 $ sysctl -a | grep kernel
 $ sysctl -a | more

Write variable from command line

The syntax is:
# sysctl -w variable=value
To enable packet forwarding for IPv4, enter:
# sysctl -w net.ipv4.ip_forward=1

Reload settings from all system configuration files

Type the following command to reload settings from config files without rebooting the box:
# sysctl --system
The settings are read from all of the following system configuration files:

  1. /run/sysctl.d/*.conf
  2. /etc/sysctl.d/*.conf
  3. /usr/local/lib/sysctl.d/*.conf
  4. /usr/lib/sysctl.d/*.conf
  5. /lib/sysctl.d/*.conf
  6. /etc/sysctl.conf

Persistent configuration

You need to edit the /etc/sysctl.conf file for setting system variables:
# vi /etc/sysctl.conf
Modify or add in the file. Close and save the file. To Load in sysctl settings from the file specified or /etc/sysctl.conf if none given, enter:
# sysctl -p