2024-06-14 18:11:25 +03:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -euxo pipefail
|
|
|
|
|
|
|
|
blkdev="/dev/vdb"
|
2024-06-22 17:50:39 +03:00
|
|
|
mnt=$(mktemp -d)
|
2024-06-14 18:11:25 +03:00
|
|
|
pw=$(genpass)
|
|
|
|
uuid=$(uuidgen)
|
|
|
|
|
|
|
|
# link user and session keyrings so that the key can be found by the kernel
|
|
|
|
keyctl link @u @s
|
|
|
|
|
|
|
|
sfdisk "$blkdev" <<EOF
|
|
|
|
label: gpt
|
|
|
|
type=linux, size=1G
|
|
|
|
type=linux, size=1G
|
|
|
|
type=linux
|
|
|
|
EOF
|
|
|
|
|
|
|
|
udevadm settle
|
|
|
|
|
|
|
|
echo "$pw" | bcachefs format \
|
|
|
|
--verbose \
|
|
|
|
--encrypted \
|
|
|
|
--replicas=2 \
|
|
|
|
--uuid "$uuid" \
|
|
|
|
--fs_label test-fs \
|
|
|
|
"$blkdev"?
|
|
|
|
|
|
|
|
udevadm settle
|
|
|
|
|
|
|
|
echo "$pw" | bcachefs mount -v "UUID=$uuid" "$mnt"
|
|
|
|
|
|
|
|
keyctl search @u user "bcachefs:$uuid"
|