Luks Encryption – USB Harddrive

Format the Harddrive

# For security purpose it could be wise to rewrite the harddrive.
# The process time depends on the size of the disk.
# Assume the disk is /dev/sda

# (Option A) Write zero to every block in the harddrive.
sudo dd if=/dev/zero of=/dev/sda bs=4K

# (Option B) For most secure (could takes days).
sudo dd if=/dev/urandom of=/dev/sda bs=4K

# Create partition, use the whole disk.
# If necessary delete old partitions.
sudo fdisk /dev/sda
	n	(create new partition)
	p	(primary)
		(enter to use default values)
	w	(write and exit)

# Create LUKS partition.
sudo cryptsetup luksFormat -c aes -s 256 -h sha256 /dev/sda1

# Open LUKS partition.
sudo cryptsetup luksOpen /dev/sda1 luksUsb

# Format the partition.
sudo mkfs.ext4 -L data /dev/mapper/luksUsb

# Create mount point.
sudo mkdir /mnt/data

Mount the Disk

# Mount partition to change the ownership.
sudo mount /dev/mapper/luksUsb /mnt/data
sudo chown -R [User]:[Group] /mnt/data