HOWTO: Check for Invalid Entries in /etc/vfstab

/howto-check-for-invalid-entries-etcvfstab 2012-09-20T09:47:07+01:00

One of my colleagues asked for some help in quickly locating invalid entries in an /etc/vfstab file that is 462 lines long - the customer's system in question had a lot of zones and each has its own filesystem.

Manually trawling through the file is time consuming and cumbersome, so I sat down with my shell prompt and came up with this quick little command:

$ egrep -v "^\s*$|^#" etc/vfstab | awk '{ if(NF<7) print }'

Here's the logic and explanation for each part of this command...

  1. The problem the customer is encountering is due to an invalid entry somewhere in the file where the line has insufficient fields, so we're only interested in the uncommented lines which actually contain something which we pull those out using the egrep -v "^\s*$|^#"
  2. We're then only interested in the lines that have less than 7 fields as a valid entry on Solaris requires 7 fields, so we print just those lines that don't have 7 fields using awk '{ if(NF<7) print }'

Running this against the customer's /etc/vfstab file (gathered by the Explorer) produced (I've anonymized the actual results):

$ egrep -v "^\s*$|^#" etc/vfstab | awk '{ if(NF<7) print }' 
/dev/vx/dsk/my_db_dg/myzone09-my_db-cntrl2-fs       /dev/vx/rdsk/my_db_dg/myzone09-my_db-cntrl2-fs        /zonedata/myzone
09/opt/oracle/my_db/cntrl2 vxfs 3 yes -
/dev/vx/dsk/my_db_dg/myzone09-my_db-cntrl3-fs       /dev/vx/rdsk/my_db_dg/myzone09-my_db-cntrl3-fs        /zonedata/myzone
09/opt/oracle/my_db/cntrl3 vxfs 3 yes -
/dev/vx/dsk/my_db_dg/myzone09-my_db-redo-fs         /dev/vx/rdsk/my_db_dg/myzone09-my_db-redo-fs          /zonedata/myzone
09/opt/oracle/my_db/redo vxfs 3 yes -

Here we have the classic case of a copy-&-paste action inserting a newline character between myzone and 09 resulting in 6 invalid entries instead of 3 valid entries.

Of course this isn't a complete "solution" as it only checks the number of fields in each line. It doesn't actually check that each field is valid for its location within the file and that the paths mentioned exist and are valid, but it is a good start to finding those invalid entries caused by copying and pasting long entries.

Copyright © 2005 - 2018 Colin Seymour All rights reserved. Privacy Policy.
Check out the feed if you do the RSS/Atom thing.