cancel
Showing results for 
Search instead for 
Did you mean: 

How to fsck between import and mounts

sclind
Moderator
Moderator
   VIP   

Is there a way to define that an fsck command needs to be run on each file system between the time the dg is imported and the file systems are actually mounted?  In case we have an abnormal shutdown we'd like to make sure we check the file systems for errors. 

1 ACCEPTED SOLUTION

Accepted Solutions

mikebounds
Level 6
Partner Accredited

The mount agent does an fsck if required - see extract from bundled agent guide for FsckOpt attribute:

 

Use this attribute to specify options for the fsck command. You
must correctly set this attribute for local mounts. If the mount
process fails, the fsck command is executed with the specified
options before it attempts to remount the block device. Its value
must include either -y or -n. Refer to the fsck manual page for more
information.
 
If want to force a fsck before the first mount is tried, you would have to create a custom resource.  For exampe, create the following file called fsck.sh in /opt/VRTSvcs/bin:
BLOCK_DEVICE=$2
LOCKFILE=/tmp/.{$3}.DO_NOT_REMOVE
case "$1" in
start)
    touch $LOCKFILE
    fsck $BLOCK_DEVICE;;
stop)
    rm $LOCKFILE
    ;;
monitor)
if [ -a $LOCKFILE ]
then
        exit 110
    else
        exit 100
    fi ;;
*) 
    echo "Usage: $0 {start|stop|monitor} block_device lock_file
    exit 1
    ;;
esac 
 

Then create a resource using Application agent like:

Application fsk_vol1 (
  StartProgram = "/opt/VRTSvcs/bin/fsck.sh start /dev/vx/dsk/mydg/vol1 vol1"
  StopProgram = "/opt/VRTSvcs/bin/fsck.sh stop /dev/vx/dsk/mydg/vol1 vol1"
  MonitorProgram = "/opt/VRTSvcs/bin/fsck.sh monitor /dev/vx/dsk/mydg/vol1 vol1"
)

and make this resource dependent on diskgroup resource and make associated mount point dependent on this application resource

Mike

View solution in original post

4 REPLIES 4

mikebounds
Level 6
Partner Accredited

The mount agent does an fsck if required - see extract from bundled agent guide for FsckOpt attribute:

 

Use this attribute to specify options for the fsck command. You
must correctly set this attribute for local mounts. If the mount
process fails, the fsck command is executed with the specified
options before it attempts to remount the block device. Its value
must include either -y or -n. Refer to the fsck manual page for more
information.
 
If want to force a fsck before the first mount is tried, you would have to create a custom resource.  For exampe, create the following file called fsck.sh in /opt/VRTSvcs/bin:
BLOCK_DEVICE=$2
LOCKFILE=/tmp/.{$3}.DO_NOT_REMOVE
case "$1" in
start)
    touch $LOCKFILE
    fsck $BLOCK_DEVICE;;
stop)
    rm $LOCKFILE
    ;;
monitor)
if [ -a $LOCKFILE ]
then
        exit 110
    else
        exit 100
    fi ;;
*) 
    echo "Usage: $0 {start|stop|monitor} block_device lock_file
    exit 1
    ;;
esac 
 

Then create a resource using Application agent like:

Application fsk_vol1 (
  StartProgram = "/opt/VRTSvcs/bin/fsck.sh start /dev/vx/dsk/mydg/vol1 vol1"
  StopProgram = "/opt/VRTSvcs/bin/fsck.sh stop /dev/vx/dsk/mydg/vol1 vol1"
  MonitorProgram = "/opt/VRTSvcs/bin/fsck.sh monitor /dev/vx/dsk/mydg/vol1 vol1"
)

and make this resource dependent on diskgroup resource and make associated mount point dependent on this application resource

Mike

sclind
Moderator
Moderator
   VIP   

Mike - now in see (in some doc provided by the consultant that set this all up) that fskcopt is defined:

hares -modify <resource_name> FsckOpt %-y

But I've never seen an fsck run when the resource was started.  I know we've had some start ups after abnormal shutdowns and I would have expected to see some evidence of the fsck while the online process was running.

We do believe we have some file system corruption - which is why I ask.

Scott

mikebounds
Level 6
Partner Accredited

I believe Fsck is only run if the mount fails and if Fsck is set to "n", then if mount fails, then agent does not try an fsck.

Mike

sclind
Moderator
Moderator
   VIP   

Thanks guys.  I think we'll try to schedule some down time to run an fsck just to be sure.