openssl rand 4096 > sdc.key
cryptsetup luksFormat -d sdc.key /dev/sdc
cryptsetup luksOpen -d sdc.key /dev/sdc sdc
pvcreate /dev/mapper/sdc
vgcreate sdc-vg /dev/mapper/sdc
lvcreate -l 99%FREE -n sdc2T sdc-vg
printf 'sdc /dev/sdc /root/sdc.key luks,discard,lvm=sdc\n' >> /etc/crypttab
Last active
February 11, 2021 08:35
-
-
Save nexus166/cc962080201df2ac435632b2b793e3c9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -xeuo pipefail | |
DISK="${1}" | |
_DISKNAME="$(basename "${DISK}")" | |
openssl rand 4096 >"${_DISKNAME}.key" | |
yes YES | cryptsetup luksFormat -d "${_DISKNAME}.key" "${DISK}" || true | |
cryptsetup luksOpen -d "${_DISKNAME}.key" "${DISK}" "${_DISKNAME}" | |
pvcreate "/dev/mapper/${_DISKNAME}" | |
vgcreate "${_DISKNAME}-vg" "/dev/mapper/${_DISKNAME}" | |
lvcreate -l 99%FREE -n "${_DISKNAME}-crypt" "${_DISKNAME}-vg" | |
printf '%s %s %s luks,discard,lvm=%s\n' "${_DISKNAME}" "${DISK}" "$(realpath "${_DISKNAME}".key)" "${_DISKNAME}" | tee -a /etc/crypttab |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
convert to thinpool for PVE