Creating an encrypted volume (virtual disk) on linux using the kernel dm-crypt framework
  1. needed modules, add dm-crypt to /etc/modules
    modprobe dm-crypt
  2. create the volume file on disk
    dd if=/dev/zero of=vol10m bs=1M count=10
  3. make it a loop device
    losetup /dev/loop0 vol10m
  4. create the encrypted volume (will ask for passphrase)
    cryptsetup -y luksFormat /dev/loop0
  5. edit /etc/crypttab:
    enc		/dev/loop0		none		luks
    
  6. now we can use start the encrypted volume
    cryptdisks_start enc
  7. create the filesystem
    mkfs -t ext2 /dev/mapper/enc
  8. mount it
    mount /dev/mapper/enc /mnt
  9. after you're done, umount
    umount /mnt
  10. stop the encrypted volume
    cryptdisks_stop enc
  11. and delete the loop device
    losetup -d /dev/loop0
If you want to use it again:
  1. make it a loop device
    losetup /dev/loop0 vol10m
  2. now we can use start the encrypted volume, using /etc/crypttab
    cryptdisks_start enc
  3. mount it
    mount /dev/mapper/enc /mnt
  4. after you're done, umount
    umount /mnt
  5. stop the encrypted volume
    cryptdisks_stop enc
  6. and delete the loop device
    losetup -d /dev/loop0

Encrypt a whole disk, simple partition and mount it at boot

  1. cfdisk /dev/sdb
  2. luksformat -t ext4 /dev/sdb1
  3. cat /etc/crypttab:
    #target name      source device   key file        options
    backup          /dev/sdb1       none            luks
    
  4. cat /etc/fstab:
    #file system  mount point   type  options       dump  pass
    /dev/mapper/backup      /backup         ext4    defaults        0       2
    

If you want to mount without rebooting:

# cryptsetup luksOpen /dev/sdb1 backup