Imported usable scripts from the private temporary repository

This commit is contained in:
Michele Cereda
2021-10-16 23:39:07 +02:00
parent c086c1ab27
commit 2a1357055c
4 changed files with 71 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
#!/usr/bin/env sh
: ${DEVICE:?not set}
: ${LABEL:?not set}
: ${MOUNT_OPTIONS:-compress-force=zstd}
[[ ${EUID} -eq 0 ]] || (echo "Please rerun this script with root privileges" && exit 1)
[[ -f "${DEVICE}" ]] || echo "${DEVICE} not found"
cryptsetup luksFormat "${DEVICE}"
cryptsetup luksOpen "${DEVICE}" "${LABEL}"
mkfs.btrfs --label "${LABEL}" "/dev/mapper/${LABEL}"
mount --types btrfs --options "${MOUNT_OPTIONS}" "/dev/mapper/${LABEL}" "/mnt/${LABEL}"
umount "/mnt/${LABEL}"
cryptsetup luksClose "${DEVICE}"