mirror of
https://gitea.com/mcereda/oam.git
synced 2026-02-09 05:44:23 +00:00
Improved ZFS-related knowledge base and scripts
This commit is contained in:
@@ -3,10 +3,17 @@
|
|||||||
## TL;DR
|
## TL;DR
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
# create a single device pool
|
# Create a pool from a single device.
|
||||||
zpool create pool_name device
|
zpool create pool_name device
|
||||||
|
|
||||||
# list pools
|
# Create an encrypted pool from multiple devices.
|
||||||
|
sudo zpool create \
|
||||||
|
-o feature@encryption=enabled \
|
||||||
|
-O encryption=on -O keyformat=passphrase \
|
||||||
|
pool_name \
|
||||||
|
/dev/sdb /dev/sdc /dev/sdd
|
||||||
|
|
||||||
|
# List available pools.
|
||||||
zpool list
|
zpool list
|
||||||
|
|
||||||
# show pools configuration and status
|
# show pools configuration and status
|
||||||
@@ -52,6 +59,9 @@ zpool upgrade -a
|
|||||||
# get a pool's properties
|
# get a pool's properties
|
||||||
zpool get all pool_name
|
zpool get all pool_name
|
||||||
|
|
||||||
|
# set a pool's properties
|
||||||
|
zpool set compression=lz4 pool_name
|
||||||
|
|
||||||
# add a vdev to a mirrored pool
|
# add a vdev to a mirrored pool
|
||||||
zpool attach pool_name first_drive_in_existing_mirror new_dev
|
zpool attach pool_name first_drive_in_existing_mirror new_dev
|
||||||
|
|
||||||
@@ -208,12 +218,16 @@ sudo zpool \
|
|||||||
- [aaron toponce's article on zfs administration]
|
- [aaron toponce's article on zfs administration]
|
||||||
- [archlinux wiki]
|
- [archlinux wiki]
|
||||||
- [article on zfs on linux]
|
- [article on zfs on linux]
|
||||||
|
- [OpenZFS docs]
|
||||||
|
- [Creating fully encrypted ZFS pool]
|
||||||
|
|
||||||
[aaron toponce's article on zfs administration]: https://pthree.org/2012/12/04/zfs-administration-part-i-vdevs/
|
[aaron toponce's article on zfs administration]: https://pthree.org/2012/12/04/zfs-administration-part-i-vdevs/
|
||||||
[archlinux wiki]: https://wiki.archlinux.org/index.php/ZFS
|
[archlinux wiki]: https://wiki.archlinux.org/title/ZFS
|
||||||
[article on zfs on linux]: https://blog.heckel.io/2017/01/08/zfs-encryption-openzfs-zfs-on-linux
|
[article on zfs on linux]: https://blog.heckel.io/2017/01/08/zfs-encryption-openzfs-zfs-on-linux
|
||||||
[cheat.sh/zfs]: https://cheat.sh/zfs
|
[cheat.sh/zfs]: https://cheat.sh/zfs
|
||||||
|
[creating fully encrypted zfs pool]: https://timor.site/2021/11/creating-fully-encrypted-zfs-pool/
|
||||||
[gentoo wiki]: https://wiki.gentoo.org/wiki/ZFS
|
[gentoo wiki]: https://wiki.gentoo.org/wiki/ZFS
|
||||||
[how to enable zfs deduplication]: https://linuxhint.com/zfs-deduplication/
|
[how to enable zfs deduplication]: https://linuxhint.com/zfs-deduplication/
|
||||||
|
[openzfs docs]: https://openzfs.github.io/openzfs-docs/
|
||||||
[oracle solaris zfs administration guide]: https://docs.oracle.com/cd/E19253-01/819-5461/index.html
|
[oracle solaris zfs administration guide]: https://docs.oracle.com/cd/E19253-01/819-5461/index.html
|
||||||
[zfs support + kernel, best approach]: https://forum.manjaro.org/t/zfs-support-kernel-best-approach/33329/2
|
[zfs support + kernel, best approach]: https://forum.manjaro.org/t/zfs-support-kernel-best-approach/33329/2
|
||||||
|
|||||||
@@ -5,9 +5,12 @@
|
|||||||
|
|
||||||
: "${MOUNT_OPTIONS:=compress-force=zstd}"
|
: "${MOUNT_OPTIONS:=compress-force=zstd}"
|
||||||
: "${MOUNT_POINT:=/mnt/$LABEL}"
|
: "${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)
|
[[ $EUID -eq 0 ]] || (echo "Re-run this script with root privileges" >&2 && exit 1)
|
||||||
[[ -f "$DEVICE" ]] || echo "${DEVICE} not found"
|
[[ -b "$DEVICE" ]] || (echo "${DEVICE} not found" >&2 && exit 1)
|
||||||
|
|
||||||
cryptsetup luksFormat "$DEVICE"
|
cryptsetup luksFormat "$DEVICE"
|
||||||
cryptsetup open "$DEVICE" "$LABEL"
|
cryptsetup open "$DEVICE" "$LABEL"
|
||||||
@@ -21,5 +24,8 @@ btrfs subvolume create "$MOUNT_POINT/data"
|
|||||||
|
|
||||||
chown "$USER":"$USER" "$MOUNT_POINT/data"
|
chown "$USER":"$USER" "$MOUNT_POINT/data"
|
||||||
|
|
||||||
umount "/mnt/${LABEL}"
|
if [[ "$CLOSE_WHEN_DONE" ]]
|
||||||
cryptsetup close "$DEVICE"
|
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