Skip to content

Instantly share code, notes, and snippets.

@xanoni
Last active August 14, 2021 07:27
Show Gist options
  • Select an option

  • Save xanoni/c6821c0d78fc957e0d47a8d865d3330a to your computer and use it in GitHub Desktop.

Select an option

Save xanoni/c6821c0d78fc957e0d47a8d865d3330a to your computer and use it in GitHub Desktop.

Revisions

  1. xanoni revised this gist Aug 14, 2021. 1 changed file with 1 addition and 48 deletions.
    49 changes: 1 addition & 48 deletions luks-create-4k-drive.sh
    Original file line number Diff line number Diff line change
    @@ -1,48 +1 @@
    #! /usr/bin/env -S bash -ex

    #DRIVE="/dev/sdd2"
    #LABEL="croot"
    #OFFSET=65528 # 2nd partition

    DRIVE="/dev/sdd3"
    LABEL="cblocks"
    #OFFSET=64256 # 3rd partition

    OFFSET=$((1024*8))
    BS=4096
    #BS=512

    CIPHER="xchacha12,aes-adiantum-plain64"
    #CIPHER="xchacha20,aes-adiantum-plain64"
    KEY_SIZE=256

    #CIPHER="aes-xts-plain64"
    #KEY_SIZE=512

    HASH="sha512"
    ITER_TIME=4000

    umount "/mnt/${LABEL}" || true
    cryptdisks_stop "${LABEL}"

    cryptsetup \
    --cipher="${CIPHER}" --label="${LABEL}" --key-size="${KEY_SIZE}" \
    --hash="${HASH}" --sector-size="${BS}" --offset="${OFFSET}" \
    --iter-time="${ITER_TIME}" --debug \
    luksFormat "${DRIVE}"

    cryptsetup \
    --persistent --allow-discards --debug \
    luksOpen "${DRIVE}" "${LABEL}"

    #mkfs.ext4 "/dev/mapper/${LABEL}"
    mkfs.ext4 -b "${BS}" "/dev/mapper/${LABEL}"

    mkdir "/mnt/${LABEL}" || true

    mount "/dev/mapper/${LABEL}" "/mnt/${LABEL}"

    # Nocrypt
    #mkfs.ext4 -b "${BS}" "${DRIVE}"
    #mkdir "/mnt/${LABEL}" || true
    #mount "${DRIVE}" "/mnt/${LABEL}"
    Moved here: https://github.com/xanoni/RaspberryPi-4B-LUKS-Scripts/blob/main/scripts/luks-create-4k-drive.sh
  2. xanoni created this gist Aug 10, 2021.
    48 changes: 48 additions & 0 deletions luks-create-4k-drive.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,48 @@
    #! /usr/bin/env -S bash -ex

    #DRIVE="/dev/sdd2"
    #LABEL="croot"
    #OFFSET=65528 # 2nd partition

    DRIVE="/dev/sdd3"
    LABEL="cblocks"
    #OFFSET=64256 # 3rd partition

    OFFSET=$((1024*8))
    BS=4096
    #BS=512

    CIPHER="xchacha12,aes-adiantum-plain64"
    #CIPHER="xchacha20,aes-adiantum-plain64"
    KEY_SIZE=256

    #CIPHER="aes-xts-plain64"
    #KEY_SIZE=512

    HASH="sha512"
    ITER_TIME=4000

    umount "/mnt/${LABEL}" || true
    cryptdisks_stop "${LABEL}"

    cryptsetup \
    --cipher="${CIPHER}" --label="${LABEL}" --key-size="${KEY_SIZE}" \
    --hash="${HASH}" --sector-size="${BS}" --offset="${OFFSET}" \
    --iter-time="${ITER_TIME}" --debug \
    luksFormat "${DRIVE}"

    cryptsetup \
    --persistent --allow-discards --debug \
    luksOpen "${DRIVE}" "${LABEL}"

    #mkfs.ext4 "/dev/mapper/${LABEL}"
    mkfs.ext4 -b "${BS}" "/dev/mapper/${LABEL}"

    mkdir "/mnt/${LABEL}" || true

    mount "/dev/mapper/${LABEL}" "/mnt/${LABEL}"

    # Nocrypt
    #mkfs.ext4 -b "${BS}" "${DRIVE}"
    #mkdir "/mnt/${LABEL}" || true
    #mount "${DRIVE}" "/mnt/${LABEL}"