Software RAID from Dropbox

Suddenly, your versatile activity ran out of space on your free Dropbox account? Today we’ll try to create a software RAID level 5 based on mdadm, which will be synchronized through Dropbox.

Once, on a sleepy summer morning, I couldn’t wake up physiologically, until I hit my leg against a knife-sharp stool leg and then this idea came to me. Which will help you expand your synchronized space. Proceed:

1. Dropbox setup

I made from one local file system and two synchronized. Therefore, first of all, we register two accounts on the Dropbox website .

Next, we need to launch two demons on one of our cars. And on the dropbox’s wiki there is a script that does everything we need, it remains only to start it, agree to download the daemon, log in and choose a convenient location for the synchronization directory.

dropboxes="dropbox-raid0 dropbox-raid1"
for dropbox in $dropboxes
		if ! [ -d $HOME/$dropbox ]
			mkdir $HOME/$dropbox 2> /dev/null
			ln -s $HOME/.Xauthority $HOME/$dropbox/ 2> /dev/null
	HOME=$HOME/$dropbox /usr/bin/dropbox start -i 2> /dev/null &

The dropboxes variable contains the names of the personal directories in which Dropbox will drop system data.
And so let it be that in / mnt / raid0 / Dropbox there will be a synchronization directory of the first account, and in / mnt / raid1 / Dropbox of the second.

2. Creating an array

Everything is pretty simple here. First you need to create files to store the file system in them:

# dd if=/dev/zero of=raid_array0 bs=1M count=2000

Next, we create a file system in them (what a smart phrase), we agree to create fs in a non-block device:

# mkfs.ext3 raid_array0

Copy this file to synchronization directories (you can even change the file name).

Now we need to mount our fs: Finally, create a RAID array (well, I think it’s clear that we need to put the mdadm package on your system): Well, now the whole array hangs on / dev / md0. And now you need to create a file system for it: Great, you can already safely mount / dev / md0, and you will have 4.2GB that you can synchronize (free space could be increased by choosing ext2 as the file system, but I didn’t do that )

# losetup /dev/loop0 /mnt/raid0/Dropbox/raid_array0
# losetup /dev/loop1 /mnt/raid1/Dropbox/raid_array1
# losetup /dev/loop2 /mnt/raid2/raid_array2

# mdadm -C -v /dev/md0 -l5 -n3 /dev/loop0 /dev/loop1 /dev/loop2

# mkfs.ext3 /dev/md0


3. Incomprehensible mounting

The small problem is that we cannot register your virtual file systems with fstab. So I created a script that contains those three mount commands (using losetup). Moved it to /etc/init.d/ and then with the command: I

# update-rc.d <имя_вашего_скрипта> defaults 98

added it last to the run level with standard parameters, that is, 2, 3, 4, 5 runlevel.
And the topic is that if you write in fstab the mount of the array itself (/ dev / md0), then nothing will come of it, good. Apparently so necessary. I just added the start of the dropbox launch script, mounting the array and that's it. And you can put it in autorun.

A very, very easily and naturally created synchronized array of virtual file systems.


Wiki Dropbox
RAID Wikipedia
Mans to create RAID5

update0: On two machines at the same time the array will not rise adequately (well, you need to stop it, synchronize accounts, collect, although you could write a simple script, but this is later)
Let's still collect synchronized file systems to the array:

# mdadm -A -v --run /dev/md0 /dev/loop0 /dev/loop1

Well, before that, I think it’s clear that you need to mount your fs. Next, you need to create another one, as from the second paragraph. And add it to the array:

# mdadm -a /dev/md0 /dev/loop2

We look at the state of the array:

cat /proc/mdstat

There we will see the remaining time until the array is completely restored

update1: lionsimba emphasized - it is not necessary to create a file system in a file in the second step, after creating the file you can immediately mount it

Also popular now: