Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I want to extend an existing Debian 6.0 system so that it is able to automatically fix a corrupt root file system by restoring a separate image. That process should start automatically instead of the typical

UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY

error message (so that the machine can be left unattended).

I was expecting that some script in initrd.img is responsible for checking the root fs (and handling error cases like the one above), but I can't find it. Is that job perhaps done by the Kernel itself or the boot loader (GRUB in this case) ?

(I'm using initramfs)

share|improve this question
    
How about setting it up with a read-only rootfs? –  peterph Nov 20 '12 at 17:01
    
The problem is that the rootfs needs to be changed from time to time (application upgrades, configurations) and I can't update the initramfs each time. Instead, falling back to a older backup and re-applying the changes is the better way for me. –  Udo G Nov 20 '12 at 17:09
    
Depending on how often you update, it might be viable to do it off-line on the image and just replace it on next boot - e.g. by setting a parameter on kernel command line which the initramfs notices and replaces the rootfs without asking. –  peterph Nov 21 '12 at 9:48

1 Answer 1

up vote 3 down vote accepted

Its handled in the init scripts, in particular /etc/init.d/checkroot.sh. After this message, you should be dropped into a shell (or given a single user password prompt) to run that fsck.

Its warning you that there is some error in the filesystem beyond the fairly normal (from unexpected power failures, etc.) and trivial to fix errors that -p will fix automatically.

You can configure it to do its best to fix everything (at the risk of eating the filesystem, or moving large parts to lost+found) by editing /etc/default/rcS and setting FSCKFIX=yes. (This corresponds to fsck -y instead of fsck -p)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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