tiistai 27. marraskuuta 2012

Replacing WHS with Raspberry Pi, in-kernel RAID, and USB JBOD.


I just replaced my HP WHS with a Raspberry Pi running Raspbian, in-kernel RAID, and a USB jbod. Thought I'd share the process of getting it working, including setting up SMB and email alerts.


The catalyst for me was my Windows Home Server boot drive failing for the second time, making four drive failures in three years in the WHS. I've come to two conclusions:



  • The HP WHS hardware is hard on drives or I'm just unlucky with drives. Either way, I don't want to use discontinued hardware/software.

  • I don't want to boot from a drive that I'm also using as a data store.


Enter the raspberry pi and an external usb jbod. Equipment:



Pros:



  • Cheap, low power, low heat.

  • Keeps data store separate from boot operating system.

  • On a wireless network it's as fast as any other server since even the modest IO speeds of the Pi and USB 2.0 bus exceed wireless network throughput.


Cons:



  • All IO to/from the RAID, including drive rebuild operations, is limited by the USB 2.0 bus speed and the Pi processor. This means that for rebuild operations or for initially loading it with data, you should consider plugging it into a Linux machine with USB 3.0.


Below are quick instructions for getting things set up. When in doubt read the man pages: mdadm, mdadm.conf, ssmtp, ssmtp.conf, smbpasswd, samba or the links at the bottom.


Download software



apt-get install mdadm ssmtp samba samba-common-bin

Replace these variables below with their values as you follow the instructions.



$EMAIL = your gmail email address $LOCALUSER = your non-root username on the raspberry pi $NUMDRIVES = the number of devices contributing to the raid (should be 3 or 4 for RAID 5) $PASSWORD = your gmail password

Set up ssmtp to use your gmail account


Contents of /etc/ssmtp/ssmtp.conf:



root=$EMAIL mailhub=smtp.gmail.com:587 rewriteDomain= hostname=$EMAIL UseSTARTTLS=YES AuthUser=$EMAIL AuthPass=$PASSWORD FromLineOverride=YES

Contents of /etc/ssmtp/revaliases



root:$EMAIL:smtp.gmail.com:587 $LOCALUSER:$EMAIL:smtp.gmail.com:587

Set up RAID 5


Record which devices under /dev belong to the jbod. Skip this if you already know what they are.



cat /proc/partitions > /tmp/partitions

plug jbod in



diff /tmp/partitions /proc/partitions

You can create partitions with raid auto detect set here or just use the devices as they are. I chose the latter.


Create RAID



/sbin/mdadm --create --verbose /dev/md0 --level=5 --raid-devices=$NUMDRIVES /dev/sda /dev/sdb /dev/sdc (replace devices with the ones found earlier)

Format raid



mkfs.ext4 /dev/md0

Verify that it mounts



mkdir /mnt/raid mount /dev/md0 /mnt/raid df -h /mnt/raid

modify this line in /etc/init.d/mdadm to have the RAID monitor send a test email each time it starts. Think of this as a systems test.



--monitor --pid-file $PIDFILE --daemonise --scan --test ${DAEMON_OPTIONS:-}

Get array UUID



mdadm --detail /dev/md0 | grep UUID

Add uuid/md mapping to /etc/mdadm/mdadm.conf



ARRAY /dev/md0 uuid=xxxxx:xxxxx:xxxxxx:xxxxx

Modify MAILADDR LINE in /etc/mdadm/mdadm.conf



MAILADDR $EMAIL

Have /etc/fstab mount the raid on boot



/dev/md0 /mnt/raid ext4 defaults,noatime 0 0

Set up SMB


Add to /etc/samba/smb.conf:



[raid] comment = External RAID read only = no locking = no guest ok = no path = /mnt/raid valid users = $LOCALUSER

Create smb password for user.



smbpasswd -a $LOCALUSER

Reboot the machine or restart mdadm and samba. When it comes back up you should get a test email and have a working fileserver.


Sources:




submitted by john_ringwals to linux

[link] [41 comments]

Ei kommentteja:

Lähetä kommentti

Huomaa: vain tämän blogin jäsen voi lisätä kommentin.