Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I want to create an inexpensive self-hosted private git server with redundant storage. To that end I have bought a Raspberry Pi and configured both git and ssh on the Pi. I can access the Pi both from a LAN and remotely (by forwarding a port on my router to the Pi).

So the git server is already up and running. The last thing to do is redundant storage. Because I have a 7-port USB hub attached to my Pi, I would like to set up a RAID system using multiple identical USB sticks.

I have only conceptual knowledge of RAID. Therefore I do not know how to set it up and more importantly, whether it is possible with USB sticks connected to a hub.

So these are basically my questions

  • Can you set up a RAID system using USB sticks as the storage media
  • What software should I use
  • Where can I find good tutorials / manuals for RAID systems
  • In case RAID is impossible, how can I synchronize data across multiple USB sticks
share|improve this question
    
I believe it can be achieved. Please look into this link. areyouefficient.blogspot.com/2010/12/… –  Ramesh Mar 21 at 23:44

1 Answer 1

up vote 7 down vote accepted

Q#1: Can you set up a RAID system using USB sticks as the storage media

You should be able to use any block storage devices in a RAID. Any standard directions for setting up a RAID using SATA HDD's should be applicable when using USB storage as well. You'll have to set it up so that the USB devices are assembled as members of the RAID array.

Q#2: What software should I use

I would use the mdadm software which is typically included with most Linux distros.

Example

$ sudo mdadm --create --verbose /dev/md0 --level=1 /dev/sda1 /dev/sdb1
mdadm: Note: this array has metadata at the start and
    may not be suitable as a boot device.  If you plan to
    store '/boot' on this device please ensure that
    your boot-loader understands md/v1.x metadata, or use
    --metadata=0.90
mdadm: size set to 976629568K
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.

Change the devices to the ones used by the USB storage devices. Then assemble the array:

$ sudo mdadm --assemble --scan
$ sudo mdadm --assemble /dev/md0 /dev/sda1 /dev/sdb1

Once assembled:

$ sudo mdadm --detail /dev/md0
/dev/md0:
        Version : 1.2
  Creation Time : Fri Jul  5 15:43:54 2013
     Raid Level : raid1
     Array Size : 976629568 (931.39 GiB 1000.07 GB)
  Used Dev Size : 976629568 (931.39 GiB 1000.07 GB)
   Raid Devices : 2
  Total Devices : 2
    Persistence : Superblock is persistent

    Update Time : Fri Jul  5 21:45:27 2013
          State : clean
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

           Name : msit01.mysolutions.it:0  (local to host msit01.mysolutions.it)
           UUID : cb692413:bc45bca8:4d49674b:31b88475
         Events : 17

    Number   Major   Minor   RaidDevice State
       0       8        1        0      active sync   /dev/sda1
       1       8       17        1      active sync   /dev/sdb1

Now format the RAID array with a filesystem:

$ sudo mke2fs /dev/md0
mke2fs 1.42 (29-Nov-2011)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
61046784 inodes, 244157392 blocks
12207869 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
7452 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
        102400000, 214990848

Allocating group tables: done
Writing inode tables: done
Writing superblocks and filesystem accounting information: done

Q#3: Where can I find good tutorials / manuals for RAID systems

A simple search on Google will turn up many options. For example this one: Tutorial: mdadm Software RAID on Ubuntu / Debian Systems.

share|improve this answer
    
This is good. Im curious about detaching devices, considering the subject is removable media. Is it easily handled? –  mikeserv Mar 22 at 2:44
    
One concern (nearly) unique to the Pi is the loss of all RAID drives at once when the USB system crashes. This is similar to having a RAID controller card fail, but is far more common. –  Mark Mar 22 at 5:14
    
Thank you very much. This helped me a lot. I ordered 4 identical 32 GB USB sticks. I intend to set up a RAID level 10 system (two RAID 1 sets combined into a larger RAID 0 unit). How do I go about rebooting? Is everything lost when I reboot the Pi? Is the RAID level 10 system available after reboot? –  cfbaptista Mar 23 at 17:20
    
@cfbaptista - the RAID should persist b/w reboots, it will need to be started up as part of the Pi's booting process using mdadm. –  slm Mar 23 at 17:45
    
Thank you slm, you have been very helpful. I will report back when the USB sticks arrive. –  cfbaptista Mar 23 at 17:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.