The FreeBSD Diary |
(TM) | Providing practical examples since 1998If you buy from Amazon USA, please support us by using this link. |
Setting up an encrypted file system --- by Niklas Saers
6 January 2001
|
This article was written by Niklas Saers |
I had long been hearing from my Linux using friends about their different encrypted
filesystems and wanted one for FreeBSD. The reasons for this are many: I have copies
of all my emails and mails from the golden BBS days until now with the exception of a few
harddrive crashes, and I wouldn't want whoever to read this. I also find encryption
interesting and I would see how this worked performancewise. Although there are no
encrypted file systems in the kernel, I found one in ports/security .
This file system is really a RPC server for the NFS protocol. It uses 3DES by
default but has other forms of encryption available as well. However, for this
introduction we'll stick with the standard. First of all, use su to become cd /usr/ports/security/cfs && make install clean should do the trick. If you for some reason don't use ports, you can fetch the package from freebsd.org The next step is setting up the daemon. cfs requires an entry in /var/tmp localhost All right. If you do not have NFS up and running already, we're going to have to start
the portmap and the mountd dæmons. Add the following lines to your single_mountd_enable="YES" mountd_flags="-r" portmap_enable="YES" portmap_program="/usr/sbin/portmap" and then start the dæmons by issuing these commands: /usr/sbin/portmap /sbin/mountd -r You now have the dæmons started and they will start automatically next time you boot your computer. Since it's quite handy to have the filesystem mounted directly after loading the
server, edit mount -o port=3049,intr,nfsv2 localhost:/var/tmp /crypt Of course you have to be sure to create the /usr/local/etc/rc.d/cfsd.sh start Voila, now you can log root out. In your home directory, for instance, we are going to make a storage for your encrypted data. All your data will be stored here in encrypted form, so don't delete and don't worry about not understanding your data. Let's call this directory crypt: cmkdir crypt and write your password twice. Be sure to make it long. Then we attach it to the encrypted file system: cattach crypt mysafestorage And write your password again. Voila, now there is a directory in All done. For convenience sake you could make a symlink from cdetach mysafestorage Now, for the performance evaluation. On my really great laptop with the really poor chipset which makes even a process niced to -20 hang and wait for the IO to finish, I did a
on my home directory and in my encrypted filesystem which was stored in my home directory. In my home directory I got Thu Nov 2 13:49:42 EST 2000 100000+0 records in 100000+0 records out 51200000 bytes transferred in 10.266791 secs (4986953 bytes/sec) Thu Nov 2 13:49:53 EST 2000 Thus an 11 seconds operation give or take half a second, while compared with my encrypted filesystem I got: Thu Nov 2 13:55:14 EST 2000 100000+0 records in 100000+0 records out 51200000 bytes transferred in 21.279745 secs (2406044 bytes/sec) Thu Nov 2 13:55:35 EST 2000 Thus roughly 21,5 seconds. A 100% increase in time consumption, but still doable. And of course, I would love to hear about how your performance was. My email is safe and sound now as long as I remember my password. :) -Niklas |