3

I need to find out what kind of script runs fsck during the boot on CentOS 7? I know that all scenarios are located in /etc/rc.d directory. But I haven't any idea about where is this script is located.

12

I know that all scenarios are located in /etc/rc.d directory.

What you know is wrong.

Welcome to CentOS 7. The world has changed. In particular, your base of Red Hat Enterprise Linux 7 has changed. You are using a systemd Linux operating system. A lot of the received wisdom about Linux is not true for such systems.

fsck is not run by any script at all on systemd Linux operating systems.

The native format for systemd is the unit, which can be amongst other things a service unit or a mount unit. systemd's service management proper operates solely in terms of those, which it reads from one of nine directories where (system-wide) .service and .mount files can live. /etc/systemd/system, /run/systemd/system, /usr/local/lib/systemd/system, and /usr/lib/systemd/system are four of those directories.

Your /etc/fstab database is converted into mount units by a program named systemd-fstab-generator. This program is listed in the /usr/lib/systemd/system-generators/ directory and is thus run automatically by systemd early in the bootstrap process at every boot, and again every time that systemd is instructed to re-load its configuration later on.

This program is a generator, a type of ancillary utility whose job is to create unit files on the fly, in a tmpfs where three more of those nine directories (which are intended to be used only by generators) are located. systemd-fstab-generator generates .mount units that mount the volumes. These in their turn reference .service units that run fsck.

Those fsck service units don't themselves exist as files in the filesystem (not even in a tmpfs), and are not the products of a generator. They are instantiated by systemd from a template service unit file, named systemd-fsck@.service, using the device name as the service unit instance name. The instantiation happens because of the Requires= and After= references to systemd-fsck@device.service from the generated .mount units.

This instantiated template is a service that runs a program named systemd-fsck, which sets up a client-server connection for displaying progress information and then in its turn runs fsck. systemd-fsck is a compiled C program, not an interpreted script.

Further reading

0

If CentOS 7 is still using the SysV setup, under /etc/rc.d are all scripts, a fast grep should show where it is called. The scripts themselves are linked (under their names, preceded by precedence) in the /etc/rc/X directories, untangling that isn't too hard. Understanding the scripts is another kettle of fish altogether...

If it is already using systemd (look e.g. here for an overview) the configuration files are under /lib/systemd, and specific configuration is in /etc/systemd. Again, grap trusty grep(1) and dig in.

  • Using this :sudo find / -name "fsck" I found only this two directories: /usr/sbin/fsck and /usr/share/bash-completion/completions/fsck – fuser Oct 18 '15 at 13:19
  • @MRX /usr/sbin/fsck is the executable. Not a script, a binary. which fsck would have told you faster... – vonbrand Oct 18 '15 at 13:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.