• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 577
  • Last Modified:

kill script if fsck or e2fsck is waiting on input

Operating System: Oracle Enterprise Release 5 Update 1 (RH code base - would be the same as Red Hat release)
Hardware: Sun Microsystems x4100 M2

I am coding a backup server system. Before mounting SAN filesystems, I need to fsck or e2fsck the file systems prior to mounting. If the check fails, it is easy enough to display a message, clean up and remove related processes. The problem that I am thinking about, have not yet encountered via bash script is, if fsck or e2fsck is waiting on user input particularly for whether or not you wish to use alternate superblock. My guess is that it would sit there forever, waiting for an answer. I want to answer no and die. I can't see anything that would say to call that an error and die. I would like to know if there is a way to wait 2 seconds or so waiting on input to just do same tasks as if the check had failed? if trap, what would i trap for. If there some other way to answer no, display a message and die? Is there some undocumented flag or alternate fsck utility that would just error if it got to that point?

Thank you,
Mark N.

0
ManoaHI
Asked:
ManoaHI
1 Solution
 
ravenplCommented:
never tried, but You could test

yes no | e2fsck -p /dev/sdXY
if [ $? -le 1 ]; then
 echo e2fsck finished ok
else
 echo e2fsck left fs unclean
fi
0
 
ManoaHIAuthor Commented:
Thanks, I'll put the -p option and take out the -y in so that it works with Solaris as well as Linux. By any chance does anyone know how to force a disk to ask to use the alternate superblock (essentially corrupt it on purpose) to see if that works?
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now