TEST
This commit is contained in:
@@ -377,10 +377,11 @@ disk_config_generation() {
|
||||
num_parity=0
|
||||
num_content=0
|
||||
|
||||
if (( num_selected == 1 )); then
|
||||
if (( num_selected == 1 )); then # If only one data disk is selected, it is a content disk
|
||||
num_content=1
|
||||
num_parity=0
|
||||
elif (( num_selected > 1 )); then
|
||||
elif (( num_selected > 1 )); then # If more than one data disk is selected
|
||||
# 1 parity for up to 2 content disks.
|
||||
num_parity=$(( (num_selected + 2) / 3 ))
|
||||
num_content=$(( num_selected - num_parity ))
|
||||
fi
|
||||
@@ -484,7 +485,7 @@ EOF
|
||||
|
||||
# --> Generate automatic unlock configuration in ./nix-config/disks/snapraid.nix
|
||||
if [[ "$NUMBER_OF_CONTENT_DISKS" -gt 0 || "$NUMBER_OF_PARITY_DISKS" -gt 0 ]]; then
|
||||
echo -e "\n\n ✅ Adding automatic disk unlocking configuration to './nix-config/disks/snapraid.nix'..."
|
||||
echo -e "\n\n ✅ Generating automatic disk unlocking configuration..."
|
||||
sed -i '$ d' ./nix-config/disks/snapraid.nix
|
||||
|
||||
cat <<EOF >> ./nix-config/disks/snapraid.nix
|
||||
@@ -492,25 +493,30 @@ EOF
|
||||
boot.initrd.luks.devices = {
|
||||
EOF
|
||||
|
||||
for i in $(seq 1 $NUMBER_OF_CONTENT_DISKS); do
|
||||
disk_var="CONTENT_DISK_$i"
|
||||
cat <<EOF >> ./nix-config/disks/snapraid.nix
|
||||
if [[ "$NUMBER_OF_CONTENT_DISKS" -gt 0 ]]; then
|
||||
for i in $(seq 1 $NUMBER_OF_CONTENT_DISKS); do
|
||||
disk_var="CONTENT_DISK_$i"
|
||||
cat <<EOF >> ./nix-config/disks/snapraid.nix
|
||||
"crypted-content-disk-${i}" = {
|
||||
device = "${!disk_var}";
|
||||
keyFile = "/etc/secrets/disks/content-disk-${i}";
|
||||
};
|
||||
EOF
|
||||
done
|
||||
done
|
||||
fi
|
||||
|
||||
for i in $(seq 1 $NUMBER_OF_PARITY_DISKS); do
|
||||
disk_var="PARITY_DISK_$i"
|
||||
cat <<EOF >> ./nix-config/disks/snapraid.nix
|
||||
if [[ "$NUMBER_OF_PARITY_DISKS" -gt 0 ]]; then
|
||||
for i in $(seq 1 $NUMBER_OF_PARITY_DISKS); do
|
||||
disk_var="PARITY_DISK_$i"
|
||||
cat <<EOF >> ./nix-config/disks/snapraid.nix
|
||||
"crypted-parity-disk-${i}" = {
|
||||
device = "${!disk_var}";
|
||||
keyFile = "/etc/secrets/disks/parity-disk-${i}";
|
||||
};
|
||||
EOF
|
||||
done
|
||||
done
|
||||
fi
|
||||
|
||||
cat <<'EOF' >> ./nix-config/disks/snapraid.nix
|
||||
# Automatic data disks unlock <--
|
||||
};
|
||||
|
||||
@@ -1,42 +1,5 @@
|
||||
I am working on a homelab deployer tool. The description of this homelab deployer tool is available in the README.md file, you shall read it to better understand your job. Your job as a NixOS expert will be to help me change the current broken configuration into my wanted configuration.
|
||||
|
||||
# Here is how my script is set up right now
|
||||
### Disks selection
|
||||
My script allows the selection of disks.
|
||||
|
||||
The disks are separated in two categories : boot and data disks. Data disks include content disks and parity disks.
|
||||
|
||||
First, the user choose the boot disks : he can choose one boot disk or two boot disks in a mirror setup. User has to choose at least one boot disk.
|
||||
|
||||
Then, the user chooses data disks. He can choose how many data disks he desires up to 9, or no disks at all. Then the scripts automatically assigns data disks to the content and parity disks according to 2 conditions : <br>
|
||||
- if more than one data disk is selected, the content/parity repartition must be 1 parity disk for up to 2 content disks. <br>
|
||||
- if more than one data disk is selected, the content/parity repartition must be 1 parity disk for up to 2 content disks. <br>
|
||||
If only one data disk is selected, it is a parity disk.
|
||||
|
||||
### RAID configuration
|
||||
If there is only one boot disk selected, the boot disk will be striped. If there are 2 boot disks selected, it will be a mirror.
|
||||
|
||||
The data disks mountpoints are logically set : <br>
|
||||
- /mnt/content-1 <br>
|
||||
- /mnt/content-2 <br>
|
||||
- /mnt/content-3 <br>
|
||||
- /mnt/content-4 <br>
|
||||
- /mnt/content-5 <br>
|
||||
- /mnt/content-6 <br>
|
||||
- /mnt/parity-1 <br>
|
||||
- /mnt/parity-2 <br>
|
||||
- /mnt/parity-3 <br>
|
||||
|
||||
SnapRAID is used to get a RAID configuration working with the content and parity drives even if their size is not the same. MergerFS is used to obtain one clean path to the data storage. The script uses a combination of code to find the UUIDs of the disks to reference them in the final disk-config.nix configuration file.
|
||||
|
||||
### Disks unlocking
|
||||
|
||||
The boot disks are unlocked manually by providing the passphrase on boot.
|
||||
|
||||
The data disks are unlocked manually too.
|
||||
|
||||
The configuration.nix file is broken and need to be fixed.
|
||||
|
||||
# Here is how I want my setup to be
|
||||
|
||||
### Disks selection
|
||||
|
||||
Reference in New Issue
Block a user