#! /bin/bash

if [[ $# -ne 2 ]] || [[ ! -b "$2" ]]; then
    echo "Usage: [sudo] $0 NAME DEVICE

Prepares DEVICE as a cryptographic volume for dm-crypt. The dm-crypt volume will be associated with /dev/mapper/NAME.

You will probably need to run this with sudo.

Use this script at your own risk: it will destroy anything on DEVICE! Furthermore, if you've already run this script, and then run it again with a different password, it will not warn you. It will probably just go ahead and break any pre-existing information you had. Really, really, really consider using LUKS.

This script will not prepare the partition for use. You will need to create a filesystem before mounting for the first time." | fmt -w66
    exit
fi

dd if=/dev/urandom of="$@" bs=16M
cryptsetup create "$1" "$2"

