Cryptmountで設定した暗号化は、Linuxカーネルのデバイスマッパのレベルで行われる。これは、サポートされている任意のファイルシステムタイプをデバイスマッパで暗号化されたブロックデバイスファイル上に作成できることを意味する。Cryptmountで扱える部分は、デバイスマッパによる暗号化の設定と、暗号化されたデバイスマッパレイヤ上に存在するファイルシステムのマウントである。ただし、Cryptmountの簡単な使い方では、これらの詳細を知る必要はない。
CryptmountのパッケージはUbuntu GutsyのUniverseリポジトリにあるほか、SlackwareやGentoo向けのものもさまざまな形で入手できる。また、SourceForge.netのCryptmountのページには、Fedora 8にインストールできるRPMファイルが用意されている。
Cryptmountを試す一番簡単な方法は、対話式スクリプトcryptmount-setupを使うことだ。暗号化されたファイルシステムを1つのファイルとして手早く作成できる。なお、cryptmount-setupのデフォルト設定は、暗号化されたコンテンツ用のディレクトリを「/home」の下に作成するものになっている。
# cryptmount-setup
********************************
* cryptmount setup script
*
* This program will allow you to setup a secure filing-system that will
* be managed by "cryptmount". You will be able to select basic features
* such as the location and size of the filesystem - if you want more
* advanced features, you should consult the cryptmount manual page.
*
...
Please enter a target name for your filesystem
[opaque]: my-encrypted-files
Which user should own the filesystem (leave blank for root)
[]:
Please specify where "my-encrypted-files" should be mounted
[/home/crypt]:
Enter the filesystem size (in MB)
[64]: 256
Enter a filename for your encrypted container
[/home/crypto.fs]:
Enter a location for the keyfile
[/etc/cryptmount/my-encrypted-files.key]:
...
enter new password for target "my-encrypted-files":
confirm password:
Formatting encrypted filesystem...
enter password for target "my-encrypted-files":
Your new encrypted filesystem is now ready for use.
To access, try:
cryptmount my-encrypted-files
cd /home/crypt
After you have finished using the filesystem, try:
cd
cryptmount --unmount my-encrypted-files
# cryptmount my-encrypted-files
enter password for target "my-encrypted-files":
e2fsck 1.40.2 (12-Jul-2007)
/dev/mapper/my-encrypted-files: clean, 11/65536 files, 18561/262144 blocks
# df /home/crypt
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/my-encrypted-files
253871 10288 230476 5% /home/crypt
「cryptmount --unmount」という部分に注意してほしい。Linuxカーネルは「/home/crypt」をごく普通のファイルシステムと見なすだろうが、「umount /home/crypt」としてはならない。Cryptmountではまだアクティブと見なされているからだ。これを実行すると、カーネルのファイルシステムはアンマウントされるが、Cryptmount側で再マウントしようとしても“create ioctl failed:Device or resource busy”というメッセージが出て失敗することになる。
このようにファイルシステムのアンマウントが行われてしまうと、本来は正しい「cryptmount --unmount my-encrypted-files」というコマンドの実行にも失敗し、指定されたファイルシステムがマウントされていないとのメッセージがCryptmountから出力されることになる。この問題を解決するには、「--release」オプションを使って、ほかの方法ですでにアンマウントされたcryptmount関連のリソースを解放するようにCryptmountに指示すればよい。
