Suddenly, your versatile activities did not have enough space on your free Dropbox account? Today we will try to create a level 5 software RAID based on mdadm that will be synchronized via Dropbox.
Once, on a sleepy summer morning, I could not wake up physiologically until I kicked my foot on a stool leg, sharp like a knife, and then this idea came to me. Which will help you to expand the synchronized space. Let's start:
1. Setup Dropbox
I did from one local file system and two synchronized ones. Therefore, first of all we register two accounts on the
Dropbox site.
Then we need to launch two demons on one of our cars. And in the wiki of the dropbox itself there is a script that does everything we need, it remains only to launch it, agree with downloading the daemon, log in and choose a convenient location for the synchronization directory.
')
The variable dropboxes contains the names of personal directories in which Dropbox will dump system data.
So let it be that in / mnt / raid0 / Dropbox there will be the synchronization directory of the first account, and in / mnt / raid1 / Dropbox the second.
2. Creating an array
It's all pretty simple. First you need to create files to store the file system in them:
# dd if=/dev/zero of=raid_array0 bs=1M count=2000
Then we create in them an already file system (what a clever phrase), we agree to create fs in a non-block device:
# mkfs.ext3 raid_array0
Copy this file to sync directories (you can even change the file name).
Now we need to mount our fs:
# losetup /dev/loop0 /mnt/raid0/Dropbox/raid_array0
# losetup /dev/loop1 /mnt/raid1/Dropbox/raid_array1
# losetup /dev/loop2 /mnt/raid2/raid_array2
Finally, we create a RAID array (well, I think it’s clear that you need to put the mdadm package into your system):
# mdadm -C -v /dev/md0 -l5 -n3 /dev/loop0 /dev/loop1 /dev/loop2
Great now the whole array hangs on / dev / md0. And now you need to create a file system for it:
# mkfs.ext3 /dev/md0
Great, you can already mount / dev / md0, and you will have 4.2 GB which can be synchronized
(the free space could be increased by choosing ext2 as the file system, but I did not do that) .
3. Incomprehensible mount
A minor problem is that your virtual file systems cannot be registered with fstab. So I created a script that contains those three mount commands (using losetup). I moved it to /etc/init.d/ and then with the command:
# update-rc.d <__> defaults 98
I added the last one to the launch level with standard parameters, that is, 2, 3, 4, 5 runlevel.
And the point is that if you put in the fstab 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 script, mounting the array and that's it. And you can put it in autostart.
Us, very easily and naturally created a synchronizing array of virtual file systems.
Paddock
Wiki dropboxRAID WikipediaFishechkiMans to create a RAID5update0: On two machines at the same time, the array will not adequately rise (well, you need to stop it, synchronize accounts, build, although you could write a simple script, but that later)
Let's still collect synchronized file systems into an array:
# mdadm -A -v --run /dev/md0 /dev/loop0 /dev/loop1
Well, before that I think it is clear that you need to mount your fs. Next you need to create another one, as from the second item. And add it to the array:
# mdadm -a /dev/md0 /dev/loop2
Look at the state of the array:
cat /proc/mdstat
There we will see the remaining time until the complete recovery of the array
update1: lionsimba emphasized - it is not necessary to create the file system in the file in the second step, after creating the file, you can immediately mount