filesystem checking?


hi i know the chkfsys utility and know how to check through command line . but i want to check in script .

i have cf having 4 partition . 1st partition having qnx image . after booting i have to check filesystem on other partition . if any error having those partition i have to display the error and shutdown . i don’t how to do it. please help me to check filesystem in scipting and take decission .


  1. if error on any partition ,chkfsys utility returns anythink?
  2. how to take decissions if errors occur?
  3. how i kow this partition is error?.

note:i have partition type- hd0t77,hd0t78,hd0t79,hd0t80

thanks and regards,
ganesan palanisamy

First, I think it’s worth noting that chkfsys only works on a QNX 4 initialized partition.
QNX 6 partitions seem to have no equivalent checking program. Maybe it doesn’t need one?

Second, your request seems quite strange, to detect that a partition has corruption and the shut down.
The function of chkfsys is to fix a partition, so why shut down afterwards?

Your question about whether chkfsys sends a meaningful return code is a good one that you can determine by testing.
The default ksh that QNX uses has a variable you can check after a program runs that is set to the return code, so I would
just create a simple script that runs chkfsys and then prints it out.

For testing it’s fairly easy to create some corruption. Create a program that opens a file, writes some data, and then goes to sleep.
After the program goes to sleep, power down.

# My Test Script

echo Test Chkfsys Output

chkfsys -u MountPoint $1
if test STATUS -ne 0; then
    echo "An error occured while running chkfsys!"
	shutdown -bf

# end of Test Script

Where MountPoint is the mount info for your partitions (use the df command). On my system for example I have
/dev/hd0t79 mounted as /
/dev/hd1t77 mounted as /fs/ram

To check my Ram disk I run

chkfsys -u /fs/ram


hi TIM,

thanks for your reply,

this code is not working.

status: not found

hi ,
thank you your reply,

this script is not working well,
status :not found error os comming

chkfsys utility is return any value?


You’ve done something wrong. ‘status: not found’ usually indicates the program can’t be found. For example if I just type garbage at the command prompt like ‘foo’ I see: ‘sh: foo: not found’. Do you have the proper path specified for chkfsys. This is especially important if you are checking in a boot image. You must have chkfsys in the boot image itself.

It does. 0 = success and !0 = error.

I know this because if I run my script as a non-root user I get the error case because non-root users can’t run chkfsys. Once I switch to root user I run successfully (since I don’t have any errors on my Ram disk). You can test corruption in the manner that Maschoen described.


thanks for your reply TIM,

this script is working good…
but after executing this script it is asking yes/no questions(corruption occur do u want to continue? , bitmap clear) if corruptions occur in partition.

hi TIM,

whenever ran the script it is asking user input like…

  1. chkfsys: Root directory has wrong status (FIXABLE)
    Serious error: continue program (Y/n) ?

  2. incorrect link count (3 should be 10): FIXABLE
    fix (Y/n) ?

if any errors occur in the partitions.
but i don’t want to ask user input and also it won’t fix errors automatically.

how i have to avoid the user input please help me…

thanks and regards
ganesan … kfsys.html

You may want to look carefully at the exit status’s and take action based on a non-zero result.


hi TIM,
thanks for your reply,

i am using -x option (# chkfsys -x hd0t77).
but it is telling illegal option like (chkfsys: illegal option – x)

please give the solution …

thanks and regards,

thanks for your reply,

i am using with x but its telling illegal option .

chkfsys -x /dev/hd0t77
chkfsys: illegal option – x


-x is not a parameter of chkfsys.