Create a disk file with random data
$ truncate -s 50G encrypted_backup.disk
Setup encryption for that device file
$ cryptsetup --verbose --verify-passphrase -s 512 luksFormat encrypted_backup.disk
WARNING!
========
This will overwrite data on encrypted_backup.disk irrevocably.
Are you sure? (Type uppercase yes): YES
Enter passphrase:
Verify passphrase:
Command successful.
Map it to a location using device mapper:
$ sudo cryptsetup luksOpen encrypted_backup.disk home_mount
[sudo] password for tuxdna:
Enter passphrase for encrypted_backup.disk:
$ ls /dev/mapper/
home_mount
Format the filesystem
$ sudo mkfs.ext3 /dev/mapper/home_mount
mke2fs 1.43.3 (04-Sep-2016)
Creating filesystem with 13106688 4k blocks and 3276800 inodes
Filesystem UUID: 7cd67ee5-ece5-4664-b10e-2af8649753c2
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424
Allocating group tables: done
Writing inode tables: done
Creating journal (65536 blocks): done
Writing superblocks and filesystem accounting information: done
Mount it now:
$ mkdir mntpoint
$ sudo mount /dev/mapper/home_mount mntpoint