Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

[SOLVED] Force FSCK automatically at boot

Linux Kernel, Network, and Services configuration.
Post Reply
Message
Author
marcoventurini
Posts: 3
Joined: 2017-06-23 16:44

[SOLVED] Force FSCK automatically at boot

#1 Post by marcoventurini »

Hello,

I'm deploying a bunch of custom x86 headless systems that boot from SD card.
Its not uncommon that an SD card get corrupted and at boot I get:

UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY

and the system starts int the initial ram FS.

From here I can manually recover the boot... but only by connecting a monitor and a keyboard, since the system is stuck without network configuration.

Is there a way to setup FSCK to recover the errors AUTOMATICALLY... or maybe boot from another source or execute any kind of script.... ? I don't mind much about the content of the drive because I can clone it back, but it's very very bad if the system stops the boot waiting for user input...

Thanks a lot!

Marco
Last edited by marcoventurini on 2017-07-01 12:56, edited 1 time in total.

User avatar
dasein
Posts: 7680
Joined: 2011-03-04 01:06
Location: Terra Incantationum

Re: Force FSCK automatically at boot

#2 Post by dasein »

marcoventurini wrote:Is there a way to setup FSCK to recover the errors AUTOMATICALLY
Yes.

If you want additional detail, copy-and-paste your thread title directly into your favorite search engine.

marcoventurini
Posts: 3
Joined: 2017-06-23 16:44

Re: Force FSCK automatically at boot

#3 Post by marcoventurini »

Can you please enlighten me? It may be a more useful way to spend your time.

User avatar
GarryRicketson
Posts: 5644
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: Force FSCK automatically at boot

#4 Post by GarryRicketson »

Like this:
Force FSCK automatically at boot

There are several good results, you can take your pick, or try this one:
https://unix.stackexchange.com/question ... ilesystems

Also :

Code: Select all

man fsck
has instructions.
From fsck manual:
FSCK(8) System Manager's Manual FSCK(8)

NAME
fsck - file system consistency check and interactive repair
------snip--------
-y Cause fsck to assume "yes" as the answer to all operator
questions.

marcoventurini
Posts: 3
Joined: 2017-06-23 16:44

Re: Force FSCK automatically at boot

#5 Post by marcoventurini »

Thanks a lot,

More or less all the results that I found (and this is why I posted my question) recommend this :
To prevent manual fsck runs, ask fsck to try to automatically fix errors with the -y option by uncommenting and changing no to yes in the following /etc/default/rcS entry, after the edit it should look like:

# automatically repair filesystems with inconsistencies during boot
FSCKFIX=yes
But i don't understand how is it supposed to work... let me clarify:

1) Syslinux (my bootloader in the UEFI parition) boots the Kernel.
2) The Kernel starts with the initial ramdisk that is on the UEFI partition as well.
3) The initial ramdisk mounts (or refuses to mount in case of errors) the root file system and the FSCK utility must run form the initramfs.

How can a setting stored inside the root file system affect the initramfs behavior? Is the rootfs is not mounted "/etc/default/rcS" has no effect... am I right?

I verified that changing "/etc/default/rcS" does not work, at the end i found that those two Kernel command line parameters will do the job (and that makes sense, since they are passed to the initramfs too)
fsck.mode=
One of “auto”, “force”, “skip”. Controls the mode of operation. The default is “auto”, and ensures that file system checks are done when the file system checker deems them necessary. “force” unconditionally results in full file system checks. “skip” skips any file system checks.
fsck.repair=
One of “preen”, “yes”, “no”. Controls the mode of operation. The default is ” preen”, and will automatically repair problems that can be safely fixed. “yes ” will answer yes to all questions by fsck and “no” will answer no to all questions.
https://www.freedesktop.org/software/sy ... rvice.html

I'm a bit puzzled by the "/etc/default/rcS" thing... is that clear to you?

Thanks a lot,

Marco

Post Reply