The Weblog of Vincent Oberle - Thoughts and opinions about technology and business

Linux: Slow encfs on USB drives

I recently purchased an external USB hard drive to backup my data. I want to encrypt some of the data I put and I decided to use encfs for this. It’s a very easy way to set up an encrypted file system, a 5 minutes setup under Ubuntu Feisty. Compared to a loopback encrypted file system, it doesn’t require to specify the size ahead of time, it grows as needed.

However when backing up on a encrypted directory on my USB drive I experienced very bad performance. I found a way to improve it several times by changing the Filesystem Block Size used by encfs. By default it uses 512 bytes blocks. Increasing it to 4096 bits made it several times faster.

In fact backing up 77 MB of data was over 5 times faster. It’s still much slower than not encrypting at all however.

  • 4096 block size: 1 min 43 secs (size 78856 KB)
  • 512 block size: 9 mins 21 secs (size 78860 KB)
  • Non encrypted: 19 secs (size 78824 KB)

The Filesystem Block Size can only be set when creating the file system. When starting encfs for the first time, choose the expert mode. Then you can choose the same options as for the standard mode (as described in the encfs man page: Blowfish algorithm, 160 bits key size, block encoding and everything else as default choices) except for the block size where you should choose 4096. You may also choose the AES algorithm with a 256 bits key. In my tests it was even slightly faster than the less secure Blowfish algorithm (1 min 41 secs).

Update: I ended up not using encfs at all on my USB drive, as I found out that TrueCrypt was much faster, in fact there is no penalty for the encryption. One has to choose the size of the file system before, but that is a small price to pay for speed. It is easy to install under Ubuntu and is also supported under Windows.

5 Responses to “Linux: Slow encfs on USB drives”

  1. wolli
    September 3rd, 2007 08:45
    1

    I use encfs on my “live” disks and do my backups onto USB disks. The trick is I back up the ‘raw’ directories so I don’t use encryption during the backup process.

    encfs /home/wolli/raw /home/wolli/enc

    rsync -aP /home/wolli/raw /media/usbdisk/backup

  2. Vincent Oberle
    October 19th, 2007 14:18
    2

    Yes that is a good setup for encrypted backup, simple and fast. Unfortunately I use an encrypted partition.

  3. XtoF
    November 30th, 2007 21:53
    3

    Is it wise to encrypt a backup in the first place ? I don’t know how encfs and truecrypt work, but what if you loose your key during the “disaster” that makes you require your backuped data ?
    Personally I try to keep my backups as “open” as possible : no encryption, and open file formats if possible (ex: DNG instead of NEF for my DSLR pics).
    And of course I try not to loose my USB drive ;)

  4. Vincent Oberle
    November 30th, 2007 23:44
    4

    It’s a good point, how I solve it:
    - I keep 2 backups of my laptop at 2 different physical location.
    - I keep the key to access the backups also a 2 different physical location.

    Sure it would be simpler not to encrypt anything. And in fact I don’t encrypt everything, only the files that must be.

  5. ihsan
    January 7th, 2008 10:23
    5

    The problem is with the loopback. If you use sync command you will see that everyting fine. But again there is a problem, you have to sync almost every second if u copy. :( .

Leave a Reply