Rebuild Procedure (disaster recovery)


The straightforward, low‑risk process for rebuilding the RAID5 array and restoring the system exactly as it was. The workflow captures the important metadata first, rebuilds the array with the same parameters, recreates the aligned ext4 filesystem, and restores data using integrity‑preserving tools. Once mounted, services are brought back online and validated to ensure permissions, ACLs, and the media pipeline all function correctly. A clear backup strategy and verification steps keep the system recoverable and dependable long‑term.


Goal: Recreate the RAID5 array and restore data from backups with minimal risk and clear verification steps.

1. Document current state (before teardown)


2. Prepare replacement drives (wipe and partition)

bash

sudo sgdisk -Z /dev/sdX

bash

sudo sgdisk -n1:0:0 -t1:fd00 /dev/sdX

Why: identical partition type and alignment avoids stripe misalignment and performance loss.


3. Create mdadm array

bash

sudo mdadm --create /dev/md0 \
  --level=5 \
  --raid-devices=5 \
  --chunk=512 \
  --bitmap=internal \
  /dev/sda /dev/sdb /dev/sdc /dev/sdd /dev/sde

bash

sudo mdadm --detail --scan | sudo tee -a /etc/mdadm/mdadm.conf
sudo update-initramfs -u

Why: use the same chunk size, layout, and bitmap to match original performance and rebuild behavior.


4. Create filesystem with stripe alignment

bash

sudo mkfs.ext4 -E stride=128,stripe-width=512 /dev/md0

Why: stride/stripe‑width alignment reduces write amplification and improves throughput.


5. Mount and restore data

bash

sudo mkdir -p /media/plutus
sudo mount /dev/md0 /media/plutus

bash

sudo rsync -aHAX --progress /path/to/backup/ /media/plutus/

Why: restore in a controlled way; preserve permissions and ACLs.


6. Recreate fstab entry

bash

sudo blkid /dev/md0
# then edit /etc/fstab and add:
# UUID=<uuid> /media/plutus ext4 defaults,noatime,nofail 0 2

bash

sudo umount /media/plutus
sudo mount -a
df -h /media/plutus

Why: ensures consistent mounts across reboots and avoids device node drift.


7. Restart services and validate imports

bash

sudo systemctl start sonarr radarr prowlarr qbittorrent-nox nzbget

bash

systemctl status sonarr radarr prowlarr qbittorrent-nox nzbget
journalctl -u sonarr -n 200
# Test a sample import cycle in Sonarr/Radarr

bash

sudo systemctl restart smbd
sudo testparm -s
getfacl /media/plutus | head -n 20

Why: confirm services can read/write and that the pipeline functions end‑to‑end.


Safety note

Backups & Durability Strategy (Concise)

Appendix — Useful Commands (copy/paste)

bash

# RAID status
sudo mdadm --detail /dev/md0
cat /proc/mdstat

# SMART health (per drive)
sudo smartctl -a /dev/sda

# Filesystem metadata
sudo tune2fs -l /dev/md0
sudo dumpe2fs -h /dev/md0

# Services
systemctl status sonarr radarr prowlarr qbittorrent-nox nzbget
journalctl -u sonarr -f

# Samba
sudo testparm -s
smbclient -L localhost -N

# Rebuild watch
watch -n 10 cat