Is it possible to somehow break out of e2fsck on boot?

My system runs e2fsck every 30 days, which is fine by me and I want it to stay that way. But sometimes when I turn on the computer and 30 days have passed, I still want it to boot fast. For instance when I have to give a presentation off a laptop - imagine telling 50 people "we just have to wait for 10 minutes... no, I can't avoid it... yes, this is Linux, why are you asking?" :)

If I press Ctrl+C it stops the check and continues boot sequence, but the system is unusable because root filesystem is mounted read-only. And after I reboot the check starts again.

I have searched the Internet for the answer and there are many similar questions, but I could find no solution. Anyone know of a solution?

Note: I am looking for a solution that would not disable fsck and that would not require any action before rebooting the computer - I do not know in advance I will have to skip the check.

If it matters: Debian 6 (Squeeze).\

UPDATE: I learned that it is possible to break out of e2fsck with Esc key on Ubuntu. This is exactly what I am looking for - anyone know how to make this happen on Debian?

SOLUTION: Garrett's answer was correct, I had to edit /etc/init.d/checkroot.sh. Just before these lines:

# The actual checking is done here.
if [ "$rootcheck" = yes ]

I added these lines:

if [ "$rootcheck" = yes ]
    if [ -f /forcefsck ] || grep -s -w -i "forcefsck" /proc/cmdline
        echo "fsck was forced."
        echo "********************************************************************************************************"
        echo "*                                                                                                      *"
        echo "*  WARNING: fsck should be run, but it is disabled. Create /forcefsck and reboot at your convenience.  *"
        echo "*                                                                                                      *"
        echo "********************************************************************************************************"

Works beautifully - I smile every time I see the message, knowing I have just rescued another half an hour of my life. :)

  • 1
    The checks are pointless anyhow so it's best just to disable them. – psusi Jan 31 '12 at 14:57
  • 4
    Strongly disagree with the previous comment. They are there for a reason, and unless you like inconsistent data, I would not follow such a bold comment. – Garrett Jan 31 '12 at 16:36
  • 1
    I suspect that you are using ext3 filesystem. If you instead use ext4, you are going to experience much faster fsck... my ~200GB partition with well over 100GB of data would take perhaps 10s. In fact, that's the one feature that made this filesystem extremely attractive to me (I started using it before it was declared stable). – tshepang Feb 1 '12 at 7:37
  • Still, faster is not good enough - I want to skip this step unless I am willing to wait. – johndodo Feb 1 '12 at 8:20
  • If you don't like automated fsck that often you should use tune2fs with options -c and -C and -i. See man tune2fs for more details. Then do make manual fsck runs every now and then. The periodic checks are not only for possible file system driver errors, those are meant to detect possible hardware issues, too. – Mikko Rantalainen Jan 16 '13 at 8:36

There are three easy ways to achieve what you're looking to do, depending on the situation.

  1. When shutting down, use the command line shutdown binary and pass the -f switch, e.g. for a reboot: shutdown -rf now. You could also make a shortcut with this if you'd prefer. This will skip the fsck check on the next reboot only.
  2. When the grub menu is displayed on boot hit 'e' to edit the current booting kernel, edit the vmlinuz line and append fastboot to the end. Like option 1, this skips the fsck check for that boot only.
  3. If you really want to disable the check entirely (not recommended), you can edit the file /etc/fstab. Find the line with your root filesystem and at the end there will be two numbers, usually 1 2. Changing the last number (2 here) to 0 will prevent all automatic boot-time fsck checks from running on that volume.

Edit for #2: You could add a new entry to grub for fastboot, which may be more suited to your example case. This retains the normal fsck check while presenting a choice during boot.

| improve this answer | |
  • +1! First and third option are not viable for me, but the 2nd option is. If check "happens", I can use Ctrl+C, reboot and use fastboot option (which I can prepare in advance). I'll wait to see if there is an easier way, but that would help too! Thanks! :) – johndodo Feb 1 '12 at 8:26
  • I couldn't make it work with option 2, but I have found a way to solve this issue for me (I have updated the question with the answer). Thanks! – johndodo Jan 16 '13 at 19:29

While it does not directly address your question of how to abort a running fsck, if you know in advance that you will need a fast boot (such as if you are planning to give a presentation) then you can certainly run fsck manually at some earlier time. This will give you a new 30 days before the next automated file system check without touching any system configuration.

| improve this answer | |
  • Thanks, but I do have better things to do than count how many days passed from the last check, you know... ;) Joke aside, I am really not that thrilled at the prospect of manually taking care of fs checks. – johndodo Feb 1 '12 at 8:27
  • Well, there's always dumpe2fs -h and its Mount count, Maximum mount count and Next check after bits of information. I agree that it's not optimal (and @Garrett's point on fastboot is probably better, if it works for you) but the caveat of my answer was specifically "if you know in advance". – user Feb 1 '12 at 10:24
  • Yes, but my question specifically stated "I do not know in advance"... ;) Still, thanks for the answer. The reason for the reply was that most of the questions I have found had the same kind of answers - none of which fit my bill. I appreciate the effort though. – johndodo Feb 1 '12 at 14:11

You can edit the startup script which calls fsck. So you could for example make it ask the console whether to do a fsck, with a timeout. The scripts are in /etc/init.d/checkroot.sh and /etc/init.d/checkfs.sh.

I notice that my copy has this code in it which you could re-enable:

# Disabled AC power check until fsck can be told to only check the
# file system if it is corrupt when running on battery. (bug #526398)
#       if which on_ac_power >/dev/null 2>&1 && [ "$rootcheck" = yes ]
#       then
#               on_ac_power >/dev/null 2>&1
#               if [ "$?" -eq 1 ]
#               then
#                       log_warning_msg "On battery power, so skipping file system check."
#                       rootcheck=no
#               fi
#       fi
| improve this answer | |
  • if I understand correctly, this will skip the check every time I am on battery? – johndodo Jan 31 '12 at 13:53
  • Yes, if on_ac_power exists and works properly. – pjc50 Jan 31 '12 at 17:03

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.