RAID with SSD USB Sticks

Normally it is always a risk to carry important data around on USB sticks. They can be lost, broken, or accidentally deleted. This article describes how to build a disk array with data mirroring from two USB sticks.


Normal USB sticks have a limited number of overwrite operations on each cell. So every USB stick will break after a while. With some technology, we will avoid this in such a way that the risk of losing data is minimized.


What are we going to do about it? We will build a software RAID out of both USB sticks, Linux can do that by default. And this is how it works:

We connect both USB sticks of the same size to the computer and use lsblk to see which devices are involved:

$ lsblk 

sdc      8:32   1 119,3G  0 disk 
├─sdc1   8:49   1 119,2G  0 part 
sdd      8:48   1 119,3G  0 disk 
└─sdd1   8:49   1 119,2G  0 part 

In our case we are talking about the devices sdc and sdd each with about 119 GB space. The software RAID works on the basis of partitions. These partitions must be present, although not necessarily formatted.

Since we now want to convert these USB sticks into a highly available drive, we now write the disk array signatures to the sticks as user root with the command mdadm:

sudo mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdc1 /dev/sdd1

We answer questions with y. Now the data from the partition of the first stick is synchronized with the data from the partition of the second stick. This can be observed as well:

$ cat /proc/mdstat 

Personalities : [raid1] 
md0 : active raid1 sdd1[1] sdc1[0]
      124975104 blocks super 1.2 [2/2] [UU]
      [>....................]  resync =  4.5% (5634304/124975104) finish=9.8min speed=201225K/sec
      bitmap: 1/1 pages [4KB], 65536KB chunk

unused devices: <none>

Already during this process we can see that our RAID device now exists:

$ ls -l /dev/md0 

brw-rw---- 1 root disk 9, 0 26. Okt 13:24 /dev/md0

Since our device already exists, we can now create a file system on it:

$ sudo mkfs.ext4 /dev/md0

Now we can, if we want, set a label so that our new RAID is displayed with a nice name in the file explorers when we plug in the USB sticks:

$ sudo e2label /dev/md0 data

Delete RAID again

If you want to remove the whole RAID again, you have to unhook the file system first, then stop the array and then erase the super blocks on the two sticks:

$ sudo umount -l /dev/md0
$ sudo  mdadm --stop /dev/md0
mdadm: stopped /dev/md0

$ sudo mdadm --zero-superblock /dev/sdc1
$ sudo mdadm --zero-superblock /dev/sdd1