add links and formatting

This commit is contained in:
openoms
2023-04-01 09:18:24 +02:00
parent 39f8ed6dc6
commit 2b2852c69c

View File

@@ -1,12 +1,17 @@
# Create a ZFS pool to be used as a Raspiblitz disk
<!-- omit from toc -->
# Create a ZFS pool to be used as a Raspiblitz data disk
## Documentation
```
man zpool create
man zpool-features
man zfsprops
man zfs-load-key
```
- [Install ZFS](#install-zfs)
- [Create the encryption key](#create-the-encryption-key)
- [Create a pool](#create-a-pool)
- [Examples](#examples)
- [A four disk setup](#a-four-disk-setup)
- [Mount to /mnt/hdd](#mount-to-mnthdd)
- [Attach a new disk to an existing pool](#attach-a-new-disk-to-an-existing-pool)
- [ZFS encryption key operations](#zfs-encryption-key-operations)
- [Temperature monitoring](#temperature-monitoring)
- [Import an existing ZFS pool](#import-an-existing-zfs-pool)
- [Documentation](#documentation)
## Install ZFS
* https://openzfs.github.io/openzfs-docs/Getting%20Started/Debian/index.html#installation
@@ -29,39 +34,19 @@ apt install -y zfs-dkms zfsutils-linux
zpool status
```
## Preparation
## Create the encryption key
* could use a CLN hsm_secret, see https://twitter.com/openoms/status/1480881081851207683
```
# create encryption key
dd if=/dev/urandom of=/root/.zpoolraw.key bs=32 count=1
chmod 400 /root/.zpoolraw.key
# list physical disks
lsblk --scsi
# get the IDS
ls -la /dev/disk/by-id
# Working with a four disk setup - need identical sizes in the mirrrors
DISK1="/dev/disk/by-id/ata-name-and-id-of-disk1"
DISK2="/dev/disk/by-id/ata-name-and-id-of-disk2"
DISK3="/dev/disk/by-id/ata-name-and-id-of-disk3"
DISK4="/dev/disk/by-id/ata-name-and-id-of-disk4"
# Clear the partition table:
sgdisk --zap-all $DISK1
sgdisk --zap-all $DISK2
sgdisk --zap-all $DISK1
sgdisk --zap-all $DISK2
# Clean a disk which was previously used with zfs:
wipefs -a $DISK
```
## Creata a pool
## Create a pool
* see for the basic options
```
man zpoolconcepts
```
* [Why you should use mirror vdevs not raidz](https://jrs-s.net/2015/02/06/zfs-you-should-use-mirror-vdevs-not-raid)
### Examples
* edit the last line of the `zpool create` command
* the pool is named `fourdiskpool` - can change this
@@ -78,6 +63,28 @@ man zpoolconcepts
$DISK1
```
### A four disk setup
* needs identical sizes in the mirrors
```
# list physical disks
lsblk --scsi
# get the IDS
ls -la /dev/disk/by-id
DISK1="/dev/disk/by-id/ata-name-and-id-of-disk1"
DISK2="/dev/disk/by-id/ata-name-and-id-of-disk2"
DISK3="/dev/disk/by-id/ata-name-and-id-of-disk3"
DISK4="/dev/disk/by-id/ata-name-and-id-of-disk4"
# Clear the partition table:
sgdisk --zap-all $DISK1
sgdisk --zap-all $DISK2
sgdisk --zap-all $DISK1
sgdisk --zap-all $DISK2
# Clean a disk which was previously used with zfs:
wipefs -a $DISK1
```
```
zpool create \
@@ -111,7 +118,7 @@ zpool list
```
### Mount to /mnt/hdd
```
* ```
# create a dataset named hdd (so it can be mounted as /mnt/hdd)
zfs create fourdiskpool/hdd
@@ -156,7 +163,7 @@ zpool status
```
## ZFS encryption key operations
```
* ```
# backup the key
xxd /root/.zpoolraw.key
00000000: 30cc f221 94e1 7f01 cd54 d68c a1ba f124 0..!.....T.....$
@@ -173,8 +180,8 @@ chmod 0400 .zpoolraw.key
srm .zpoolraw_hex.txt
```
## temperature monitoring
```
## Temperature monitoring
* ```
sudo sudo apt install hddtemp nvme-cli
sudo hddtemp /dev/sd?
sudo nvme smart-log /dev/nvme0 | grep "^temperature"
@@ -187,7 +194,7 @@ sudo smartctl -d auto -a /dev/nvme1
sudo smartctl -d auto -a /dev/nvme1
```
## import an existing ZFS pool
## Import an existing ZFS pool
* https://openzfs.github.io/openzfs-docs/Getting%20Started/Debian/index.html
```
zpool import
@@ -204,3 +211,16 @@ cronjob="@reboot sudo /sbin/zfs load-key -a; sudo /sbin/zfs mount -la"
# list the active crontab for admin
crontab -u admin -l
```
## Documentation
- [OpenZFS on Debian](https://openzfs.github.io/openzfs-docs/Getting%20Started/Debian/index.html)
- [Capacity calculator](https://wintelguy.com/zfs-calc.pl)
- [Why you should use mirror vdevs not raidz](https://jrs-s.net/2015/02/06/zfs-you-should-use-mirror-vdevs-not-raid)
- [ZFS manager plugin for Cockpit](https://github.com/45Drives/cockpit-zfs-manager)
```
man zpoolconcepts
man zpool create
man zpool-features
man zfsprops
man zfs-load-key
```