Skip to content

Commit f1dd723

Browse files
committed
add get-first-two-disks.sh
1 parent be1a7cf commit f1dd723

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/get-first-two-disks.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/sh
2+
set -x
3+
4+
# The two smallest disks are always used as the boot and root pool
5+
# as a ZFS mirror.
6+
# This script automates:
7+
# - Finding the first two smallest disks (excluding Floppy and virtual disks)
8+
# - TODO install ing the root & boot pools onto them
9+
# - Based on manual steps in OpenZFS docs:
10+
# https://openzfs.github.io/openzfs-docs/Getting%20Started/Fedora/Root%20on%20ZFS.html#:~:text=page%20for%20examples.-,Declare%20disk%20array,-DISK%3D%27/dev
11+
12+
13+
# For each disk found, get it's /dev/disk/by-id address by querying udevadm
14+
# Initilize DISK list
15+
DISK=""
16+
17+
DISK_ADDRESSES=$(lsblk --bytes --json -S -o type,name,label,size,model,serial,wwn,uuid | jq -r 'limit(2; [.blockdevices[] | select(.type=="disk" and (.model | contains("Floppy") or contains("Flash Disk") | not))] | sort_by(.size) | .[]) | .name')
18+
19+
for DISK_ADDRESS in $DISK_ADDRESSES
20+
do
21+
DISK_UDEV_PATH=/dev/$(udevadm info --query=symlink --name=/dev/"$DISK_ADDRESS"| cut -d ' ' -f 1)
22+
# Append disk to $DISK list
23+
DISK="$DISK $DISK_UDEV_PATH"
24+
done
25+
26+
echo DISK is now set to: "$DISK"
27+
28+
29+
30+

0 commit comments

Comments
 (0)