Advertisement
Oceans11

A quick rundown on how to encrypt external storage.

Oct 6th, 2013
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.98 KB | None | 0 0
  1. ## This paste belongs to this post: http://wp.me/pNJrg-Ce
  2. ## And is based on this article:
  3. ## https://help.ubuntu.com/community/EncryptedFilesystemsOnRemovableStorage
  4. #
  5. ## Umount is an alias for:
  6. ## sudo umount /path/to/folder
  7. ## badblocks won't work with the device still 'plugged in',
  8. ## so to speak.
  9. ## First use 'dmesg',
  10. ## to determine which /dev you are going to destroy.
  11. ## Then look for it, in your /media folder,
  12. ## as that's the default folder for mounts on ubuntu.
  13. ## In my case.
  14. Umount /media/78BA-A49C/
  15. sudo badblocks -c 10240 -s -w -t random -v /dev/sdc
  16. sudo fdisk /dev/sdc
  17. ## Now inside the partitioner,
  18. ## do the following:
  19. #
  20. ## hit w for write.
  21. #  w
  22. ## Accept changes.
  23. ## And again, do:
  24. #  sudo fdisk /dev/sdc
  25. ## n for new.
  26. #  n
  27. ## p for primary.
  28. #  p
  29. ## 1 for first (a hdd can have 4 partitions max,
  30. ## of which one may be 'logical')
  31. #  1
  32. #  First cylinder: hit enter for the default.
  33. #  last cylinder: hit enter for the default.
  34. #  p
  35. ## See new output, somewhere along the lines of:
  36. #  /dev/sdc1  2048  16252927  8125440  83  Linux
  37. #  w
  38. ## Done setting up partition on 'cardreader/usb thumbstick'
  39. #
  40. ## Enter your passphrase twice, when prompted.
  41. ## Make sure they match!
  42. sudo cryptsetup --cipher aes-xts-plain64 --key-size 512 --hash sha512 --iter-time 5000 --use-random --verify-passphrase luksFormat /dev/sdc1
  43. #
  44. ## Give your 'container' a more meaningful name.
  45. sudo cryptsetup luksOpen /dev/sdc1 mapped-name
  46. ## Enter your 'passphrase', when prompted.
  47. ## Now it's time to create a filesystem on your device.
  48. sudo mkfs -t ext4 -m 1 -O dir_index,filetype,sparse_super /dev/mapper/mapped-name
  49. ## Don't forget to close your luks-device after use.
  50. sudo cryptsetup luksClose mapped-name
  51. #
  52. ## Now take out your usb-thumb-drive or SD-card,
  53. ## and insert it back in.
  54. ## When prompted for a passphrase,
  55. ## type it in.
  56. #
  57. ## Change ownership of the attached storage to yourself.
  58. sudo chown yourname:yourname /media/very-long-string-of-characters
  59. ## All done!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement