mirror of
https://gitea.com/mcereda/oam.git
synced 2026-02-08 21:34:25 +00:00
Improved ZFS-related knowledge base and scripts
This commit is contained in:
@@ -5,9 +5,12 @@
|
||||
|
||||
: "${MOUNT_OPTIONS:=compress-force=zstd}"
|
||||
: "${MOUNT_POINT:=/mnt/$LABEL}"
|
||||
: "${USERNAME:=root}"
|
||||
: "${GROUPNAME:=root}"
|
||||
: "${CLOSE_WHEN_DONE:=true}"
|
||||
|
||||
[[ $EUID -eq 0 ]] || (echo "Please rerun this script with root privileges" && exit 1)
|
||||
[[ -f "$DEVICE" ]] || echo "${DEVICE} not found"
|
||||
[[ $EUID -eq 0 ]] || (echo "Re-run this script with root privileges" >&2 && exit 1)
|
||||
[[ -b "$DEVICE" ]] || (echo "${DEVICE} not found" >&2 && exit 1)
|
||||
|
||||
cryptsetup luksFormat "$DEVICE"
|
||||
cryptsetup open "$DEVICE" "$LABEL"
|
||||
@@ -21,5 +24,8 @@ btrfs subvolume create "$MOUNT_POINT/data"
|
||||
|
||||
chown "$USER":"$USER" "$MOUNT_POINT/data"
|
||||
|
||||
umount "/mnt/${LABEL}"
|
||||
cryptsetup close "$DEVICE"
|
||||
if [[ "$CLOSE_WHEN_DONE" ]]
|
||||
then
|
||||
umount "/mnt/${LABEL}"
|
||||
cryptsetup close "$DEVICE"
|
||||
fi
|
||||
|
||||
26
scripts/create-a-crypted-zfs-device.sh
Executable file
26
scripts/create-a-crypted-zfs-device.sh
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
: ${DEVICE:?not set}
|
||||
: ${POOL_NAME:?not set}
|
||||
|
||||
: "${DATASET:=data}"
|
||||
: "${MOUNT_POINT:=/mnt/${POOL_NAME}}"
|
||||
: "${USERNAME:=root}"
|
||||
: "${GROUPNAME:=root}"
|
||||
: "${UNMOUNT_WHEN_DONE:=true}"
|
||||
|
||||
[[ $EUID -eq 0 ]] || (echo "Re-run this script with root privileges" >&2 && exit 1)
|
||||
[[ -b "$DEVICE" ]] || (echo "${DEVICE} not found" >&2 && exit 1)
|
||||
|
||||
zpool create \
|
||||
-o feature@encryption=enabled \
|
||||
-O mountpoint="$MOUNT_POINT" \
|
||||
-O encryption=on -O keyformat=passphrase \
|
||||
-O compression=zstd \
|
||||
"$POOL_NAME" \
|
||||
"$DEVICE"
|
||||
|
||||
zfs create "${POOL_NAME}/${DATASET_NAME}"
|
||||
chown "$USERNAME":"$GROUPNAME" "${MOUNT_POINT}/${DATASET_NAME}"
|
||||
|
||||
[[ "$UNMOUNT_WHEN_DONE" ]] && zfs unmount "${POOL_NAME}/${DATASET_NAME}"
|
||||
15
scripts/dnf/zfs.install.sh
Normal file
15
scripts/dnf/zfs.install.sh
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
# sources:
|
||||
# - https://openzfs.github.io/openzfs-docs/Getting%20Started/Fedora/index.html
|
||||
|
||||
# needs to be installed before zsf
|
||||
sudo dnf install -y kernel-devel
|
||||
|
||||
# the repo's package is not maintained
|
||||
sudo rpm -e --nodeps zfs-fuse
|
||||
|
||||
sudo dnf install -y https://zfsonlinux.org/fedora/zfs-release$(rpm -E %dist).noarch.rpm
|
||||
sudo dnf install -y zfs
|
||||
echo zfs | sudo tee /etc/modules-load.d/zfs.conf
|
||||
sudo modprobe zfs
|
||||
Reference in New Issue
Block a user