You are not logged in.

#1 2010-11-03 14:06:19

BoySka
Member
Registered: 2008-05-09
Posts: 25

fsck on shutdown: a kiss solution

Hi all, I read these topics https://bbs.archlinux.org/viewtopic.php?id=41963 and https://bbs.archlinux.org/viewtopic.php?id=15496
and I found'em really interesting. They allow to have fsck during shutdown, so that at boot it won't be done. While this can seem good, there is a big issue: sometimes we CAN'T fsck on shutdown (because of battery power on laptop, mainly)

So, I introduced some minor modifications to rc.shutdown:

before Unmounting Filesystems

## Related to the fsck-on-shutdown hack
# Check for user "consensus"
if [ -f /tmp/allowfsck ]; then
    ALLOWFSCK="1"
    rm /tmp/allowfsck
    if [ -f /tmp/forcefsck ]; then
        FORCEFSCK="-- -f"
        rm /tmp/forcefsck
        printhl "Shutdown allowed and FORCED"
    else
        FORCEFSCK=
        printhl "Shutdown allowed, but not forced"
    fi
fi

after Remounting Root Filesystem Read-only

if [ "$RUNLEVEL" = "0" -a "$ALLOWFSCK" = "1" ]; then
    stat_busy "Checking Filesystems"
    [ "$FORCEFSCK" != "" ] && stat_append " (forced by user)"
    /sbin/fsck -A -T -C -a $FORCEFSCK
    fsckret=$?
    if [ ${fsckret} -gt 1 ]; then
        stat_fail
    else
        stat_done
    fi
fi

This allow fsck to be "allowed" just when we want so, in userspace. You should then customize your halt script/gui button, so that it does some checks (about battery) and decide if fsck will run on not.
You could even create a simple zenity dialog which allows you to choose if you want to fsck or not.
When we wanto to allow fsck, just touch /tmp/allowfsck.
If we want to *force* it, /tmp/forcefsck.

Moreover, the traditional fsck on boot is still there.
What do you think about that? Improvements? Issues?

Offline

#2 2010-11-03 17:21:10

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: fsck on shutdown: a kiss solution

I think this is better placed in Community Contributions. Moving...


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

Board footer

Powered by FluxBB