Operating System - HP-UX
1826466 Members
2288 Online
109692 Solutions
New Discussion

FSCK vxfs returning code ...

 
SOLVED
Go to solution
Filipe_1
Frequent Advisor

FSCK vxfs returning code ...

Hi folks,

I have to make a backup script that works on a BCV, and I must do a fsck on the volumes before mounting them on our Media Server (of course... :-). The situation I want to handle is if a "regular" fsck doesn't work, I'd try the full one. I cannot performa a full one on all of the volumes due to time restrictions.

But when checking fsck_vxfs man page, I found the information confusing about returning codes. There are several for the "-m" option, but no returning code if it ends asking for a full FSCK. Instead, it describes outputs. Below is a excerpt from the refered man page.

What should I do? Plenty of points to assign.

Thanks in advance,

Filipe.

"
In most cases, fsck prints the following messages:

log replay in progress
replay complete - marking super-block as CLEAN

If the file system is already clean, fsck prints the following message
instead:

file system is clean - log replay is not required

If fsck prints any other messages, a full structural check is needed.
"

10 REPLIES 10
Raj D.
Honored Contributor

Re: FSCK vxfs returning code ...

Hi Filipe ,

"replay complete - marking super-block as CLEAN"

Is a normal message ,when it checks in phase 1 - Check Blocks and Sizes

and running full fsck , i.e # fsck -F vxfs -o full /dev/vgxx/lvolxy

Cheers,

" If u think u can , If u think u cannot , - You are always Right . "
Alex Lavrov.
Honored Contributor

Re: FSCK vxfs returning code ...

First thought in my head:

Get the output of fsck to some variable and then just grep for the known words, like "CLEAN" or "full", this how you can know how fcks ended ...

Alex.
I don't give a damn for a man that can only spell a word one way. (M. Twain)
Alex Lavrov.
Honored Contributor

Re: FSCK vxfs returning code ...

Found in google:

man pages->HP-UX 11i man pages -> fsck_vxfs (1m)

RETURN VALUES [Toc] [Back]
Structural errors discovered during a full check are displayed on
standard output. Responses required during a full check are read from
standard input.

The following return codes are used for the -m option for all devices
other than the one used by the root file system:

0 The file system is unmounted and clean.

32 The file system is unmounted and needs checking.

33 The file system is mounted.

34 The stat of the device failed.

Other
The state could not be determined because of an error.

The following return codes are used for the -m option for the device
used by the root file system:

0 The root file system is mounted read-only and is clean, or
the root file system is mounted read/write and therefore is
clean.

32 The root file system is mounted read-only and needs
checking.


Alex.
I don't give a damn for a man that can only spell a word one way. (M. Twain)
saju_2
Respected Contributor

Re: FSCK vxfs returning code ...

Hi

From the man page it is seen that

"fsck will return 0 if the file system is suitable for mounting. If the file system needs additional checking, the return code is 32. If the file system is mounted, the return code is 33. Error codes larger than 33 indicate that the file system is badly damaged."

So write a script and get the return codes. I think $? gives the return code in shell script.

if error code is 0 proceed with mounting.
If error code is 32 proceed with full FS fsck
and if error code is greater than 33 echo FS problem..

Regards
CS
Raj D.
Honored Contributor

Re: FSCK vxfs returning code ...

Hi Filipe ,

In short ,here are the error codes returns by fsck:


0 Either no errors were detected or all errors were corrected.

32 The file system needs additional checking.

33 The file system is mounted.

Return values greater that 33 indicate that file system is badly corrupted.

You can catch these in a shell script with "echo $? ".

Cheers,
Raj.


" If u think u can , If u think u cannot , - You are always Right . "
Mel Burslan
Honored Contributor
Solution

Re: FSCK vxfs returning code ...

assuming your filesystems to be checked are being read from /etc/fstab

cat /etc/fstab | grep -v "..." | while read line
do

lv=`echo $line | awk {'print $1'}`
fs=`echo $line | awk {'print $2'}`

fsck $lv # > /dev/null (if you do not want clutter on screen)
r=${?}

case $r in

0) echo "Volume $lv is fine. Mounting."
mount $fs
;;
32) echo "Volume $lv needs full fsck. Proceeding"
fsck -o full $lv ; r2=${?}
if [ $r2 -eq 0 ]
then
echo "Volume $lv has been repaired. Mounting."
mount $fs
else
echo "Volume $lv could not be repaired. Please investigate. Skipping..."
fi
;;
33) echo "filesystem is already mounted."
;;
*) echo "Volume $lv has problems fsck can not handle. Please investigate."
;;
esac
done

________________________________
UNIX because I majored in cryptology...
Dave La Mar
Honored Contributor

Re: FSCK vxfs returning code ...

Filipe -
We have commonly done this for 4+ years on our BC disks (120) using /usr/sbin/fsck -F vxfs
on each.
The time was minimal and this was performed each night prior to mounting the BC voumes for backup.
We use a simple for loop, reading a file of all the disks and output the results to a file for review if necessary. Of course the return code was checked after each command issuance as well.

Regards,

dl
"I'm not dumb. I just have a command of thoroughly useless information."
John E.Ophious
Regular Advisor

Re: FSCK vxfs returning code ...

Filipe,

Fsck is the key to your success. Try to do a man on it.

John E. Ophious

Florian Heigl (new acc)
Honored Contributor

Re: FSCK vxfs returning code ...

dear people,

I'd just like to throw my usual reminder in that a 'full' fsck is still comfortably fast, because it's still using the vxfs log.

To do a *full* fsck of the filesystem structure, You need to run fsck -Fvxfs -o full,nolog

to verify both log and fs are consistent I usally run both of them. :)

Also, I'm a bit surprised You're not only running a fsck -n [options] when handling BCV volumes. It's of course ok as long as the messages from fsck are really monitored, but if not, You might have consistent backups of inconsistent production filesystems ;)
yesterday I stood at the edge. Today I'm one step ahead.
Filipe_1
Frequent Advisor

Re: FSCK vxfs returning code ...

Folks,

Yes, I am aware of the 0, 32 and 33 thing, regarding the -m option. The issue here is that it is not clear in the man page that it is the same when fsck is doing the real thing.

Due to the responses here, I will assume those returning codes as a fact in both cases. Anyway, I cannot test it, at least in time to do these scripts...

Regards,

Filipe.