Skip to content

Instantly share code, notes, and snippets.

@joekiller
Last active September 25, 2023 00:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joekiller/e8fa5096218c60bebb71ddf0ff87aa78 to your computer and use it in GitHub Desktop.
Save joekiller/e8fa5096218c60bebb71ddf0ff87aa78 to your computer and use it in GitHub Desktop.
raspberry pi nas/server

This is how I did the pi raid.

I am using sda and sdb where each is formatted with an ext4 fs.

Used Raspberry Pi RAID NAS Server Setup and DigitalOcean's How To Create RAID Arrays with mdadm on Ubuntu 22.04

Partitioning during fdisk:

$ sudo fdisk /dev/sda

[m] for help
[o]
[n]
[p]
[1]
[Enter]
[Enter]
[w]

sudo fdisk /dev/sda
sudo mkfs.ext4 /dev/sda1
sudo fdisk /dev/sdb
sudo mkfs.ext4 /dev/sdb1
sudo mdadm --create --verbose /dev/md0 --level=mirror --raid-devices=2 /dev/sda1 /dev/sdb1
cat /proc/mdstat
sudo -i
# insert the raid config
mdadm --detail --scan > /etc/mdadm/mdadm.conf
less /etc/mdadm/mdadm.conf
exit
sudo mkfs.ext4 -v -m .1 -b 4096 -E stride=32,stripe-width=64 /dev/md0
sudo mkdir /mnt/raid1
sudo mount /dev/md0 /mnt/raid1
# chmod my user in as owner
sudo chown user:user /mnt/raid1
sudo update-initramfs -u
# get the uuid for fstab
ls -l /dev/disk/by-uuid
sudo vi /etc/fstab
sudo hdparm -I /dev/md0
cat /proc/mdstat

# turn on monitor blank
sudo raspi-config

fstab entry:

UUID=14c870f3-ae42-4c7d-ab06-0b45ed50048c /mnt/raid1 ext4 defaults,noatime 0 0

test performance

sudo apt install -y hdparm
sudo hdparm -I /dev/md0
sudo hdparm -tT --direct /dev/md0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment