S3 Compatible Storage on USB RAID1 with Raspberry Pi 4 Model B

The following commands provide all the steps necessary to create an almost inaudible S3 compatible storage. I use it as a target for ArqBackup. The base for this installation is a default Raspbian Image. I’ve connected two Western Digital 4 TB USB drives. I was putting two disks to a single USB Hub results in a slowdown. Now each drive to a dedicated port without any hub. I use Y-Cables to provide sufficient power to them.

Setup Raid

RAID - Install

sudo apt install mdadm -y

RAID - Cleanup

lsblk -o NAME,SIZE,FSTYPE,TYPE,MOUNTPOINT
cat /proc/mdstat
sudo mdadm --stop /dev/md0
sudo mdadm —zero-superblock /dev/sda
sudo mdadm —zero-superblock /dev/sdb

sudo fdisk -l
sudo fdisk /dev/sda
...
sudo fdisk /dev/sda
...

RAID - Create

sudo mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/sda /dev/sdb
sudo mkdir -p /mnt/raid1
sudo mkfs.ext4 -E lazy_itable_init=0,lazy_journal_init=0 /dev/md0
sudo mount /dev/md0 /mnt/raid1/
ls -l /mnt/raid1/
/etc/fstab
/dev/md0 /mnt/raid1/ ext4 defaults,noatime 0 1
sudo mdadm --detail --scan | sudo tee -a /etc/mdadm/mdadm.conf

Setup Minio

Mimio - Add User and Folders

sudo useradd --system minio-user --shell /sbin/nologin
sudo mkdir /mnt/raid1/minio
sudo mkdir /etc/minio
sudo chown minio-user:minio-user /mnt/raid1/minio
sudo chown minio-user:minio-user /etc/minio

Mimio - Download

cd /tmp
curl -O  https://dl.minio.io/server/minio/release/linux-arm/minio
sudo mv minio /usr/local/bin
sudo chmod +x /usr/local/bin/minio
sudo chown minio-user:minio-user /usr/local/bin/minio

Mimio - Config

/etc/default/minio
MINIO_VOLUMES="/mnt/raid1/minio"
MINIO_OPTS="-C /etc/minio --address nas.fritz.box:443"

Mimio - Install Service

cd /tmp
curl -O https://raw.githubusercontent.com/minio/minio-service/master/linux-systemd/minio.service
sudo mv minio.service /etc/systemd/system
sudo systemctl daemon-reload
sudo systemctl enable minio
sudo -u minio-user bash
cd /usr/local/bin
./minio server /mnt/raid1/minio -C /etc/minio --address <FQDN>:443

Endpoint: https:// AccessKey: <…> SecretKey: <…>

Mimio - Allow Firewall

sudo setcap 'cap_net_bind_service=+ep' /usr/local/bin/minio

Mimio - Self signed SSL

cd /etc/minio/certs
vi openssl.conf:

[req]
distinguished_name = req_distinguished_name
x509_extensions = v3_req
prompt = no
 
[req_distinguished_name]
C = US
ST = VA
L = Somewhere
O = MyOrg
OU = MyOU
CN = <FQDN>
 
[v3_req]
subjectAltName = @alt_names
 
[alt_names]
IP.1 = 127.0.0.1
IP.2 = 10.0.1.45
DNS.1 = nas.fritz.box
DNS.2 = nas

openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout private.key -out public.crt -config openssl.conf
sudo chown minio-user:minio-user /usr/local/bin/minio
sudo chown minio-user:minio-user /etc/minio/certs/private.key 
sudo chown minio-user:minio-user /etc/minio/certs/public.crt