Skip to content

Instantly share code, notes, and snippets.

@taoy
Last active December 11, 2015 07:17
Show Gist options
  • Save taoy/aa09e79070f745fe9b3f to your computer and use it in GitHub Desktop.
Save taoy/aa09e79070f745fe9b3f to your computer and use it in GitHub Desktop.
mount-encrypted file on debian
#!/bin/bash
sudo /sbin/losetup /dev/loop2 ~/Documents/.encrypt/encrypted.img
sudo /sbin/cryptsetup luksOpen /dev/loop2 encrypted
sudo mount -t ext4 /dev/mapper/encrypted ~/Documents/drive/
#!/bin/bash
sudo umount /dev/mapper/encrypted
sudo /sbin/cryptsetup luksClose encrypted
sudo /sbin/losetup -d /dev/loop2
# Create image file for encrypted device
$ dd if=/dev/zero of=$HOME/Documents/.encrypted/encrypted.img bs=32K count=6480
# Assign image file to loop device
$ sudo /sbin/losetup /dev/loop2 ~/Documents/.encrypted/encrypted.img
# Crypt setup the associated device (the file)
$ sudo /sbin/cryptsetup luksFormat /dev/looop2
# Open the file as a device.
$ sudo /sbin/cryptsetup luksOpen /dev/loop2 encrypted
# Format.
$ sudo /sbin/mkfs -t ext4 /dev/mapper/encrypted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment