LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-26-2005, 12:36 PM   #1
holst
LQ Newbie
 
Registered: Nov 2002
Location: Stockholm
Posts: 28

Rep: Reputation: 15
Problem with interactive fsck at bootup


Problem with interactive fsck at bootup. To begin with here is my fstab:
Code:
  LABEL=BOOT      /boot           ext2    noauto,noatime  0 0 
  LABEL=ROOT      /               auto    noatime,errors=remount-ro 0 0 
  /dev/hda2               none            swap            sw      0 0
  /dev/cdroms/cdrom0      /mnt/cdrom      iso9660         noauto,ro       0 0
If the ROOT disk is not clean - and need a fsck - the bootup sequence will abort and start asking interactive questions to the user. This is no good as i CAN'T ANSWER THEM. I only have access to the machine via remote shell (SSH). Hence I need to machine to continue to try and boot into network mode so i CAN access the machine and run fsck on the disk (when the disk is in read-only mode). I also would be nice if the system could give me some indication that the disk is not clean and need a fsck when I login by remote.
 
Old 02-26-2005, 02:07 PM   #2
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,337

Rep: Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548
"the bootup sequence will abort and start asking interactive questions to the user. This is no good as i CAN'T ANSWER THEM."

fsck has an automatic option which turns off the questions. See man fsck. You can find the boot scripts which run fsck and add the -a option to the fsck command. That way boot can procede without your intervention. In SuSE the following files would need to be changed:

/etc/init.d/S04boot.lvm
/etc/init.d/S05boot.localfs
/etc/init.d/S06boot.crypto

I don't know what the corresponding Gentoo files are called.

----------------------------
Steve Stites
 
Old 02-26-2005, 02:46 PM   #3
holst
LQ Newbie
 
Registered: Nov 2002
Location: Stockholm
Posts: 28

Original Poster
Rep: Reputation: 15
Its already full of -a
Code:
sh-2.05b$ grep 'fsck' /etc/init.d/checkroot 
                if [ -f /forcefsck ]
                  ewarn "A full fsck has been forced"
                  fsck -C -a -f /
                  # /forcefsck isn't deleted because checkfs needs it.
                  fsck -C -T -a /
sh-2.05b$
Still no go. It stalls and asks for my confirmation to fix errors.
 
Old 02-26-2005, 04:53 PM   #4
holst
LQ Newbie
 
Registered: Nov 2002
Location: Stockholm
Posts: 28

Original Poster
Rep: Reputation: 15
I tried to replace "-a" with "-p" in the script and it SEEMS it works better now. I tried with this:

1. create a "/forcecheck" file to make sure the checkroot script was exected.
2. reboot.
3. ...wait for 10 minutes for disk to be scanned... (??? something took some time here atleast)
4. machine surfaced!

Entire script:
Code:
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# $Header: /home/cvsroot/gentoo-src/rc-scripts/init.d/checkroot,v 1.39 2004/04/21 17:09:18 vapier Exp $

depend() {
    before *
}

start() {
    local retval=0

    if [ ! -f /fastboot -a -z "${CDBOOT}" ]
    then
        ebegin "Remounting root filesystem read-only (if necessary)"
        mount / -n -o remount,ro &>/dev/null
        eend $?

        ebegin "Checking root filesystem"
        if [ -f /forcefsck ]
        then
            ewarn "A full fsck has been forced"
            fsck -C -p -f /
            # /forcefsck isn't deleted because checkfs needs it.
            # it'll be deleted in that script.
            retval=$?
        else
            fsck -C -T -p /
            retval=$?
        fi
        if [ "${retval}" -eq 0 ]
        then
            eend 0
        elif [ "${retval}" -eq 1 ]
        then
            ewend 1 "Filesystem repaired"
        elif [ "${retval}" -eq 2 -o "${retval}" -eq 3 ]
        then
            ewend 1 "Filesystem repaired, but reboot needed!"
            echo -ne "\a"; sleep 1; echo -ne "\a"; sleep 1
            echo -ne "\a"; sleep 1; echo -ne "\a"; sleep 1
            ewarn "Rebooting in 10 seconds ..."
            sleep 10
            einfo "Rebooting"
            /sbin/reboot -f
        else
            eend 2 "Filesystem couldn't be fixed :("
            /sbin/sulogin ${CONSOLE}
            einfo "Unmounting filesystems"
            /bin/mount -a -o remount,ro &>/dev/null
            einfo "Rebooting"
            /sbin/reboot -f
        fi
    fi

    # Should we mount root rw ?
    if mount -vf -o remount / 2> /dev/null | \
            awk '{ if ($6 ~ /rw/) exit 0; else exit 1; }'
    then
        ebegin "Remounting root filesystem read/write"
        mount / -n -o remount,rw &>/dev/null
        if [ "$?" -ne 0 ]
        then
            eend 2 "Root filesystem could not be mounted read/write :("
            /sbin/sulogin ${CONSOLE}
        else
            eend 0
        fi
    fi

    if [ "${BOOT}" = "yes" ]
    then
        local x=
        local y=

        #
        # Create /etc/mtab
        #

        # Clear the existing mtab
        > /etc/mtab

        # Add the entry for / to mtab
        mount -f /

        # Don't list root more than once
        awk '$2 != "/" {print}' /proc/mounts >> /etc/mtab

        # Now make sure /etc/mtab have additional info (gid, etc) in there
        for x in $(awk '{ print $2 }' /proc/mounts | uniq)
        do
            for y in $(awk '{ print $2 }' /etc/fstab)
            do
                if [ "${x}" = "${y}" ]
                then
                    mount -f -o remount $x
                    continue
                fi
            done
        done

        # Remove stale backups
        rm -f /etc/mtab~ /etc/mtab~~
    fi
}


# vim:ts=4
 
Old 03-30-2005, 12:12 AM   #5
holst
LQ Newbie
 
Registered: Nov 2002
Location: Stockholm
Posts: 28

Original Poster
Rep: Reputation: 15
nope. didnt work. same error one again! *goes jumping jackson in joy*
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
fsck delay reported bootup time? rmang Linux - General 2 10-30-2005 05:29 PM
fsck problem RBJohns Linux - General 6 02-24-2005 06:55 PM
fsck.ext3 PROBLEM Darcan Linux - Newbie 5 10-12-2004 03:22 AM
automatic fsck on boot. fsck errors. nixel Slackware 1 05-17-2004 07:51 AM
fsck problem under 2.6.1 mbruti Linux - General 2 02-05-2004 12:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:38 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration