<p>
Create an empty file of a predetermined size:
</p>

<pre><code>$ fallocate --length 512M foo.img
</code></pre>
<p>Create a LUKS container on it:</p>
<pre><code>$ cryptsetup --verify-passphrase luksFormat foo.img
</code></pre>
<p>Set it up:</p>
<pre><code>$ sudo cryptsetup luksOpen foo.img foo
$ ls /dev/mapper
foo
$
</code></pre>
<p>Make a file system on it:</p>
<pre><code>$ sudo mkfs.ext2 /dev/mapper/foo
</code></pre>
<p>If you don't need it for anything now, you can close it:
</p>
<pre><code>$ sudo cryptsetup luksClose foo
$ ls /dev/mapper
$
</code></pre>
<p>Mount it as a usable filesystem:</p>
<pre><code>$ sudo mkdir /crypt
$ sudo mount /dev/mapper/foo /crypt
</code></pre>
<p>
Depending on your system configuration, you may need to set up reasonable permissions:
</p>
<pre><code>$ sudo mkdir /crypt/mystuff
$ sudo chown klaatu:users /crypt/mystuff
$ sudo chmod 770 /crypt/mystuff
$ echo "hello world" &gt;&gt; /crypt/mystuff/file.txt
</code></pre>
<p>
When you're finished using your encrypted vault, unmount and close it:
</p>
<pre><code>$ sudo umount /crypt
$ sudo cryptsetup luksClose foo
</code></pre>

