LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 11-23-2009, 06:34 PM   #1
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.1
Posts: 3,482

Rep: Reputation: 545Reputation: 545Reputation: 545Reputation: 545Reputation: 545Reputation: 545
Running fsck At Boot On Partitions Not In fstab


When forcing a fsck at boot (touch /etc/forcefsck), I would like the option to run fsck on all partitions of all hard drives and not just those partitions explicitly enumerated in fstab.

I don't see any related option in the fsck man page. The fsck command seems narrowly focused to work only with fstab partitions.

I have several systems. On some systems I have partitions I don't always use. Those partitions are not explicitly mounted through fstab. I mount them manually when I need them.

I wrote a shell script to check those partitions, but a direct method with fsck would be more sensible.

Please correct me if I misunderstand the fsck man page.

Thanks again.
 
Old 11-23-2009, 09:02 PM   #2
lstamm
Member
 
Registered: Aug 2007
Location: McBride, BC, Canada
Distribution: Slackware, OpenBSD, Edubuntu
Posts: 53

Rep: Reputation: 18
Why not write a script that you call from rc.local? By that time in the boot process, all services should be up and running, so all devices and volumes present should have been detected. You can check for UUIDs, and if the ones you are interested in are present, run fsck on them.
 
Old 11-23-2009, 09:03 PM   #3
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.1
Posts: 3,482

Original Poster
Rep: Reputation: 545Reputation: 545Reputation: 545Reputation: 545Reputation: 545Reputation: 545
Running in rc.local is to late in the process for certain things I do.
 
Old 11-23-2009, 10:19 PM   #4
mRgOBLIN
Slackware Contributor
 
Registered: Jun 2002
Location: New Zealand
Distribution: Slackware
Posts: 999

Rep: Reputation: 229Reputation: 229Reputation: 229
Why not set up a monthly cron-job to check the last fsck time (tune2fs -l /dev/whatever) unmount (if needed) and fsck to taste.

Then it can be done at some time that you don't have to wait around for.
 
Old 11-23-2009, 10:51 PM   #5
voyciz
Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 425

Rep: Reputation: 40
In /etc/rc.d/rc.S you could add something like this:

Code:
for part in $(sed '/name/d' /proc/partitions| awk '{print $4}')
do
    /sbin/fsck $FORCEFSCK -C -a $part
done

Last edited by voyciz; 11-23-2009 at 10:53 PM.
 
Old 11-27-2009, 02:28 PM   #6
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.1
Posts: 3,482

Original Poster
Rep: Reputation: 545Reputation: 545Reputation: 545Reputation: 545Reputation: 545Reputation: 545
Quote:
In /etc/rc.d/rc.S you could add something like this:
I see no comments that my understanding about fsck is incorrect. As I alluded in my original post, I already had implemented a script solution. That solution includes a modification to rc.S and a new startup script.

rc.S Was:
Code:
if [ ! -r /etc/fastboot ]; then
  echo "Checking non-root filesystems:"
  /sbin/fsck $FORCEFSCK -C -R -A -a
fi
rc.S Changed To:
Code:
if [ ! -r /etc/fastboot ]; then
  echo "Checking non-root filesystems:"
  /sbin/fsck $FORCEFSCK -C -R -A -a
  # Check non-root filesystems not explicitly mounted in /etc/fstab.
  if [ -x /etc/rc.d/rc.fsck-unmounted ]; then
    /etc/rc.d/rc.fsck-unmounted
  fi
fi
/etc/rc.d/rc.fsck-unmounted
Code:
#!/bin/sh
# /etc/rc.d/rc.fsck-unmounted

# A script to fsck partitions not mounted in /etc/fstab.
# Render this script executable to run fsck on hard drive partitions
# not explicitly mounted in /etc/fstab.
# The script is intended to be run in rc.d/rc.S after running
# fsck -F on non-root systems.

if [ ! -r /etc/fastboot ]; then
  # Copied this snippet from rc.S:
  if [ -r /etc/forcefsck ]; then
    FORCEFSCK="-f"
  fi
  # Create a list of installed hard drives.
  HARD_DRIVES="`cat /proc/partitions | awk '{print $4}' | grep -v name | grep -v '[0-9]'`"
  for hd in $HARD_DRIVES; do
    # Create a list of hard drive partitions.
    PARTITIONS="`/sbin/fdisk -l /dev/$hd | grep -v swap | grep Linux | awk '{print $1}'`"
    for partition in $PARTITIONS; do
      # Determine whether the partition is mounted in /etc/fstab.
      MOUNTED="`grep \"$partition \" /etc/fstab`"
      # The partition might be listed in fstab but commented out.
      NOT_MOUNTED="`grep \"$partition \" /etc/fstab | grep '^#'`"
      if [ -z "$MOUNTED" ] || [ -n "$NOT_MOUNTED" ] ; then
        # echo "$partition would not be checked by forcefsck."
        # echo "Checking file system on $partition."
        /sbin/fsck $FORCEFSCK -T -C -a $partition
      fi
    done
  done
fi
I think a direct method through fsck would be more elegant, but my script solution seems to be working for me. Feel free to use or improve.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Boot process halts on `Waiting for device....sda4/3" for all partitions in fstab jago25_98 Linux - Distributions 4 11-04-2009 04:07 AM
How to run FSCK and error in FSTAB kc5hwb Ubuntu 5 04-12-2007 12:50 PM
fsck on two partitions geomatt Slackware 5 10-05-2004 05:37 AM
automatic fsck on boot. fsck errors. nixel Slackware 1 05-17-2004 08:51 AM
Your /ect/fstab does not contain the fsck passno field LostinCode Mandriva 3 05-07-2004 04:15 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 08:30 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration