How do I validate / fsck my ecryptfs filesystem?

Asked by Eric Shattow on 2009-02-05

I ran out of diskspace on a computer running Ubuntu Jaunty and an ecryptfs mounted home directory. As a result of this, there are files that when accessed, report "Either the lower file is not in a valid eCryptfs format, or the key could not be retrieved. Plaintext passthrough mode is not enabled; returning -EIO" in dmesg.

How do I identify which files have become corrupted?

Question information

English Edit question
Ubuntu ecryptfs-utils Edit question
No assignee Edit question
Solved by:
Eric Shattow
Last query:
Last reply:
Eric Shattow (eshattow) said : #1

In the course of making a backup, I have found that 'tar' reports Input/Output error on suspect files:

tar: user/.dmrc.CKS2OU: Cannot open: Input/output error
tar: user/.ICEauthority.swo: Cannot open: Input/output error
tar: user/.viminfo.tmp: Cannot open: Input/output error
tar: user/.ICEauthority.swp: Cannot open: Input/output error
tar: user/.gconf/system/networking/connections/1/802-11-wireless-security/%gconf.xml: Cannot open: Input/output error
tar: user/.gconf/system/networking/connections/1/802-11-wireless/%gconf.xml: Cannot open: Input/output error
tar: user/.nautilus/metafiles/x-nautilus-desktop\:%2F%2F%2F.xmlWEMPOU: Cannot open: Input/output error
tar: user/.nautilus/metafiles/file\:%2F%2F%2Fhome%2Feshattow%2FDesktop.xmlN5S1OU: Cannot open: Input/output error
tar: user/.nautilus/metafiles/x-nautilus-desktop\:%2F%2F%2F.xmlA1I1OU: Cannot open: Input/output error

Desktop operation is broken when such files are not in a consistent state. It is important to be able to find these files quickly.

I devised a Ruby script that does so, as follows:


# mounted_filesystem_error_check.rb - r1

if ARGV[0] == "--help"
  puts "Walk a mounted filesystem and check for input/output errors in files"
  puts "Usage: #{__FILE__} [directory1] [directory2] [directory3..]"
  exit 8

basedir = []

unless ARGV.length > 0
  basedir << Dir.pwd
  ARGV.each do |dirname|
    if dirname
      basedir << dirname
      puts "### WARNING Skipped invalid directory: #{dirname}"

basedir.each do |dirname|
  Dir[File.join(dirname, "**/.*")].each do |filename|
    begin, "r") {} unless filename
    rescue Errno::EIO
      $stdout.puts "Input/Output Error: #{filename}"
    rescue Errno::EACCES
      $stderr.puts "Skipping file (No permission to access): #{filename}"