From 91ae9d6146b2c062c9d145705bd75900eca04258 Mon Sep 17 00:00:00 2001 From: Michele Cereda Date: Wed, 22 Mar 2023 20:35:13 +0100 Subject: [PATCH] chore: added article about mounting and using an encrypted device --- .../mount and use an encrypted device.md | 54 +++++++++++++++++++ ...sh => create-an-encrypted-btrfs-device.sh} | 0 ...e.sh => create-an-encrypted-zfs-device.sh} | 0 3 files changed, 54 insertions(+) create mode 100644 knowledge base/mount and use an encrypted device.md rename scripts/{create-a-crypted-btrfs-device.sh => create-an-encrypted-btrfs-device.sh} (100%) rename scripts/{create-a-crypted-zfs-device.sh => create-an-encrypted-zfs-device.sh} (100%) diff --git a/knowledge base/mount and use an encrypted device.md b/knowledge base/mount and use an encrypted device.md new file mode 100644 index 0000000..0a56652 --- /dev/null +++ b/knowledge base/mount and use an encrypted device.md @@ -0,0 +1,54 @@ +# Mount and use an encrypted device + +## Table of contents + +1. [TL:DR](#tldr) +1. [Further readings](#further-readings) +1. [Sources](#sources) + +## TL:DR + +```sh +# Encrypt the device. +cryptsetup luksFormat '/dev/sda' + +# Open the encrypted device. +# 'mapper_name' is any name you want. It will be used by the device mapper. +cryptsetup open '/dev/sda' 'mapper_name' + +# Format the volume. +mkfs.btrfs -f --label 'label' '/dev/mapper/mapper_name' + +# Mount the volume. +mkdir -p 'path/to/mount/point' +mount -t 'filesystem' -o 'mount,options' '/dev/mapper/mapper_name' 'path/to/mount/point' + +# Do something. +btrfs subvolume create 'path/to/subvolume/in/mount/point' +chown 'user':'group' 'path/to/subvolume/in/mount/point' + +# Umount the volume. +umount 'path/to/mount/point' + +# Close the device. +cryptsetup close '/dev/mapper/mapper_name' +``` + +## Further readings + +## Sources + +All the references in the [further readings] section, plus the following: + +- script: [Create an encrypted BTRFS device] +- script: [Create an encrypted ZFS device] + + + + +[further readings]: #further-readings + +[create an encrypted btrfs device]: scripts/create-an-encrypted-btrfs-device.sh +[create an encrypted zfs device]: scripts/create-an-encrypted-btrfs-device.sh + + diff --git a/scripts/create-a-crypted-btrfs-device.sh b/scripts/create-an-encrypted-btrfs-device.sh similarity index 100% rename from scripts/create-a-crypted-btrfs-device.sh rename to scripts/create-an-encrypted-btrfs-device.sh diff --git a/scripts/create-a-crypted-zfs-device.sh b/scripts/create-an-encrypted-zfs-device.sh similarity index 100% rename from scripts/create-a-crypted-zfs-device.sh rename to scripts/create-an-encrypted-zfs-device.sh