Create a 3 TB private cloud

  • Tutorial
I would like to share one way to create a personal cloud based on the three-terabyte WD MyBook Live. No, I won’t even mention wd2go and their “half cloud”, which in essence are only accesses to the NAS itself through WD services using rather clumsy Java applets. This article will talk about an “honest” cloud running on MBL using ownCloud.
This solution is suitable for those who dream of a personal Dropbox analogue, the files in which are not stored “somewhere else”, but on a specific physical medium, and are limited only by its volume, without the need to pay monthly for this amount (neglecting the monthly subscription fee for the Internet and cost of electricity).
Most solutions to this problem require a lot of digging on the Internet and rely on a good knowledge of Linux-systems. In this post I will try to give the most complete and adequate HOW-TO in Russian, which I myself have not found on the Internet. So much had to be done by trial and error at your own peril and risk. The implementation of this solution does not require any fundamental knowledge of Linux, and I will try to paint everything in the most accessible way, in steps.

If you wonder what came of it - welcome to cat.

First of all, I would like to say that you do all the manipulations on your MyBook Live only on your own responsibility. Theoretically, with the wrong sequence of actions, it is possible to make it inoperative, and although in the vast majority of cases,the box can be resurrected , and the data can be saved , anyway, try to backup the contents to another medium. Or, if there is such an opportunity, it is better to work on a blank medium.

The modern WD MyBook Live line is a 800 MHz processor, 256 MB of RAM and a practically full-fledged version of Debian Linux as firmware, although it is no longer supported by Lenny with an admixture of firmware files from WD, and even under the PPC architecture, so tinker with the packages nevertheless it will be necessary, however apt-get, wget and dpkg are the most ordinary here, which means working with repositories is possible to the fullest.

On a habr already there was an article about ownCloud, therefore, I will not dwell on what it is and how it is installed in the general case, I will go straight to the specifics for MBL. First of all, ownCloud is a server application that works as similar as possible to Dropbox, Google Drive and the like, it only hosts on your hardware, which is completely free, and MBL is by no means the worst option for hosting such a solution.

First of all, we will need to enable access to our MBL via SSH for further work. This is done quite simply - by going to the address mybooklive/UI/sshand ticking the SSH protocol:



As you can see, the default password for access is welc0me .
All that remains is to log in via SSH through the terminal (you can use PuTTY on a windows machine):
ssh root@192.168.X.X

First of all, I suggest that you also change the password to a stronger one (all the more so if you will later open access via the Internet) with the passwd command , after which it will be necessary to enter the new password twice.

IMPORTANT!
In no case do you try to upgrade the distribution to the major version, but it’s better to forget about the existence of the full-upgrade, safe-upgrade or any other upgrade commands, this inevitably leads to the fact that you can no longer download the device. I still had to pay for my curiosity by manually disassembling the device and recovering through the unbrick. Nothing fatal, but extremely unpleasant and time-consuming.
Also, I advise you to carefully monitor the packages that you install or uninstall. So, at best, you can drag out a lot of unnecessary garbage, and at worst, when you remove any unnecessary package along with dependencies, you crash something vital. So, for example, if you manage to bang ssh, then the only option to return the box to life also will be through parsing and an unbrick cleanly.
And finally, what you can’t do at all is to touch udev , it’s even dangerous to update it, in this case you run the risk of getting a brick that is not suitable for restoration instead of My Book Live. It’s best to stay away from sin, to prohibit it from updating with the command:
aptitude hold udev

This will freeze this package, thereby preventing the possibility of updating it.

Then, we will need to prepare a platform for installing third-party software. And the key here will be the removal of wd-nas packages, so that apt-get does not swear in the future for every trifle. Oddly enough, this information is not available anywhere, except for an official source :
rm -f /var/lib/dpkg/info/wd-nas.*

This will eliminate the firmware dependent packages.

The next step, we will need to add two links to the list of available repositories. This is most conveniently done in the nano editor , with the command:
nano /etc/apt/sources.list

And here is what needs to be added:
deb http://ftp.us.debian.org/debian/ squeeze main 
deb-src http://ftp.us.debian.org/debian/ squeeze main 

Maybe someone will have questions, why add squeeze repositories if the version of WD MBL itself is lenny? My answer is simply because lenny is no longer supported since February 2012, and most of the necessary packages for it have long been outdated, which can lead to unsolvable dependencies (I had to roll back to the factory settings after the first unsuccessful attempt). There are a lot of tips on the Internet on what other repositories you can add, including test branches, but I advise you not to get too carried away, because without knowing what you are doing, you can turn this quick box into a lifeless brick.
To avoid confusion, I quote the contents of my sources.list, with which everything works
deb archive.debian.org/debian lenny main
deb-src archive.debian.org/debian lenny main
deb ftp.us.debian.org/debian squeeze main
deb-src ftp.us.debian.org/debian squeeze main

After adding the necessary lines and saving the list of repositories, you need to try updating with the command:
apt-get update


Do not forget that ownCloud is nevertheless written in PHP, so for its full operation we will need to install a number of necessary packages, including the current version of PHP5 and several necessary modules:
apt-get install php5 php5-gd php-xml-parser php5-intl zlib1g

The installer may swear on untrusted packages. This is because the signed keys for the Debian repositories are no longer relevant. There is a solution to this problem , however, you can ignore the warning by simply clicking on “Y” a couple of times. Also, during the installation process, conflicts of different versions of packages are possible, some of which were preinstalled in the system. By default, preference will be given to already installed packages (this is Debian), so it is quite possible to agree with this decision (although nothing bad should happen even if you replace these packages with new ones).

If everything went well, it's time to go directly to installing your ownCloud. This is a fairly simple part. You need to go to the directory / www /and download the web installer there using wget. And also, make sure that the appropriate group write permissions are set:
cd /var/www/
wget https://download.owncloud.com/download/community/setup-owncloud.php --no-check-certificate
chmod 755 setup-owncloud.php
chgrp www-data /var/www
chmod g+w /var/www

Next, you need to go to the address in the browser mybooklive/setup-owncloud.php to continue the installation. You can install your ownCloud in any directory, but in order not to get confused in the future, I advise you nevertheless to put it in the / owncloud / directory of the same name .
If at the end of the installation, you will see
similar picture

don't be scared. We installed all the required modules at the last step, but in order for them to work, you just need to restart the apache web server:
/etc/init.d/apache2 restart

Although I would not do it at the moment, because a little later we will restart it anyway.
After we have decided on the installation directory, it remains only to finish the file with external access for http and SSL https, and also return the group rights to / www / . To do this, you will need to register the following lines:

                AllowOverride All
                Options +FollowSymLinks
        
                Order deny,allow
                Deny from all
        

between similar modules ...in the following files:
nano /etc/apache2/sites-enabled/000-wdnas

nano /etc/apache2/sites-enabled/000-wdnas-ssl

Now you can restart the Apache and return the access rights for / www / :
/etc/init.d/apache2 restart
chmod g-w /var/www

Technically, the data of the newly installed owncloud is located on the hard drive, but logically it belongs to the MBL system partition, which has a 2 GB limit. In order to be able to use the entire available volume under owncloud (honestly, I have no idea who and why it might be needed and how many years all 3TB data clogged will be synchronized), and not be limited to the system partition, we will make a symbolic link to the main DataVolume section, previously stopping the Apache for the time of our manipulations:
/etc/init.d/apache2 stop
mv /var/www/owncloud/data /DataVolume/owncloud_data
chgrp www-data /DataVolume/owncloud_data
chmod 770 /DataVolume/owncloud_data
ln -s /DataVolume/owncloud_data /var/www/owncloud/data

I strongly advise against dropping the link into the Public folder for security reasons.

In fact, we only need to restart the Apache and the main goal will be achieved:
/etc/init.d/apache2 start

Now mybooklive/owncloudwe have our own cloud at the address where you can keep and synchronize a huge number of documents that can be accessed from Win, Mac, Linux, Android and even iOS using native clients for each axis, just setting the client to synchronize with the above address.
It seems like a victory.

However...


In truth, this is far from a victory, but only halfway, because the address mybooklive/owncloudis local, and our cloud will work only within the home network, so there will be very little benefit from it. But what can be done to use ownCloud from everywhere? Of course, the lucky owners of static IPs will say that you just need to replace “mybooklive” in the address with the IP address of the device, having previously forwarded the necessary ports through the router, and they will be right. But not everyone has such a luxury, and the vast majority of users have the most common dynamic IPs that change constantly, so each time the device will have a new address.
Oddly enough, this task has a fairly simple solution. No, don’t even think that we will look in the direction of the inconvenient wd2go service (although there were a couple of ideas how to use it too) - on the contrary, we will work our heads again and use such a useful thing as Dynamic DNS.

For this we need:
  1. Register a domain.
  2. Register on any service that provides DynDNS.
  3. Install DynDNS Client on our MyBookLive

For the first point, even any free third-level domains (googling with a bang) are quite suitable, but of course it is better to register your own domain. There are quite cheap domain zones, for example, a domain in the .pw zone (Palau Islands, although some registrars promote it like a Professional Web ) will cost even a little less than 7 € per year. As an option - look at the stocks on GoDaddy (there you can often grab some tidbit in just 5 bucks).

As the DynDNS server, I personally chose completely free from freedns.afraid.org , because I pay for unused chips from dyn.com/dnseven the minimum subscriber per year, somehow did not want to. For our task, the most minimal functionality is perfect. I will not describe in detail the procedure for registering a domain and linking it to the DynDNS service in the framework of this article. Simply register on the service and on the freedns.afraid.org/domain page find the item “Add A Domain into FreeDNS”, and then add the following ns servers as DNS for your registrar:
NS1.AFRAID.ORG
NS2.AFRAID.ORG
NS3.AFRAID.ORG
NS4.AFRAID.ORG

At the same time, you should not be afraid of the red status of Broken - if everything is fine, it will disappear within 24 hours.

Next, we need to select and install any Dynamic DNS client on MyBookLive. In fact, this is not an easy task, because there are really a lot of similar solutions in Perl, Python, PHP, there are also separate daemons for * nix of all kinds and stripes. Before I found a suitable solution, I had to try a lot of options, but something didn’t suit everywhere - setup through one place, sometimes it doesn’t work well, it’s not compatible with the selected server, sometimes it’s too clumsy with the protocol version. In the end, I decided to stay on the smallest, simplest and simplest client inadyn. Of the advantages - quick work, very small size, compatibility with the selected server, quite flexible configuration, support for the crown, launch in daemon mode and updating the IP at a specified interval. Of the minuses, perhaps the absence of any GUI, and even this is hardly a minus for such a console utility.

It is installed simply by the command:
apt-get install inadyn

It is also important to note that curl may be required for inadyn to work if it was not installed. It is solved as follows:
apt-get install curl

Next, we need to log in to freedns.afraid.org/dynamic under your account and select the Direct URL item opposite the domain that we linked earlier. Note that there will be something similar in the browser line:
http://freedns.afraid.org/dynamic/update.php?OHphN3RsHY0SEFtZ1JrQ2V2Z1pTOjk2NzEwOTTVM1cc=

Are we interested in everything that is to the right of ? . This is a hash valid only for your domain (the values ​​in the example are changed). Copy it somewhere, we will need it soon.
Now create the inadyn configuration file with the command:
nano /etc/inadyn.conf

into which we insert the necessary settings and save:
--username <имя_пользователя>
--password <пароль>
--update_period_sec 60
--forced_update_period 120
--alias <имя_домена>,<хэш>
--background
--dyndns_system default@freedns.afraid.org
--syslog

Who cares, decryption
  • username - here we indicate the name of the user with whom they registered on freedns.afraid.org
  • password - password from there
  • update_period_sec - frequency of checking and updating (if changed) IP in seconds
  • forced_update_period - forced IP refresh rate in seconds
  • alias - a line in which we indicate our domain and its hash, which we wrote earlier, separated by commas
  • background - instruct to execute in the background
  • we leave the string dyndns_system default@freedns.afraid.org unchanged, it tells the program which server the information is working with (indicates the internal exchange protocol)
  • syslog - write events to the system log


Now we need to add inadyn to the crown as an automatic event upon reboot, so that each time MyBookLive reboots, it starts automatically. For this:
crontab -e

Add the line:
@reboot /usr/sbin/inadyn

To check the functionality of the program after our manipulations, you can reload the MBL command
reboot

Then wait 3-5 minutes until it reboots and starts, then check the processes:
ps -A | grep inadyn

We will only have to check the availability of our maybook by domain name with the ping command:
ping 

If everything went fine, and the sent packages arrive, you can safely go in yourdomain.com/owncloudand rejoice at the great accomplishment.
When setting up desktop and mobile clients of owncloud, you must specify the entire string as the address yourdomain.com/owncloudso that they understand where our / owncloud / is located .

PS during the writing of the article, by trial and error, I had to do a full software reset to the factory settings once and disassemble the device twice to resurrect (according to the instructions from here), therefore, I beg you to take all warnings seriously, with an understanding of your own responsibility and the ability to spoil the piece of iron and lose information. Also, do not forget that MyBookLive is, above all, just a budget nas, and you still should not use it as a full-fledged server, there are much more suitable solutions for this.

PPS about any errors or inaccuracies, please write in private messages. The topic is very interesting to me personally, and I do not have much fundamental knowledge in Linux administration, so the comments can be very useful. It is possible that the article will be supplemented, expanded, and if it is in demand, it is possible that it will acquire the second part (there are several more ideas on how to upgrade MyBookLive)

Answers on questions:


Question: Do I need to install apache? There is not a word about this in the article.
Answer: No, apache on MyBookLive is installed by default. When you first connect, the setting takes place via a web interface at: mybooklive.local. It is important that if you incorrectly update or modify apache, you can lose the web interface and find yourself in a situation where it cannot be started without resetting to factory settings. Mindlessly updating it is also not worth it, because you can stumble upon insoluble dependencies, but there are not many alternative options for Lenny, and even for the PPC architecture.

Question: What version of firmware was the experiment conducted on?
Answer:Everything was done on 02.42.03-027, but in theory, it should work with earlier ones. Unfortunately, there is no information on various firmware.

Question: Can Feature Pack Manager affect in any way what is described in the article?
Answer: At its core, fpkmgr is just some kind of advanced package manager that installs the set of packages that the user selects. Transmission from fpkmgr and owncloud worked quietly on my MBL in parallel. Perhaps there are some packages installed using fpkmgr that may conflict, but I still do not have information about this. If someone came across and writes about it, I will include a comment here.

Question: After the steps described in the article, will owncloud shut down when the MBL goes to sleep?
Answer: The most interesting is that judging by the behavior of the LED, he did go to sleep until I turned off the power saving. In fact, it worked with some delay in order to “wake up” and show the contents of owncloud when entering from the browser, although technically I did not study this aspect. With power saving turned off, everything works fine.

Question: I did everything according to the instructions, but when I try to access it says that it is impossible to connect to the server. What to do?
Answer: For propercloud to work properly, you need to forward ports 80 and 443 on the router. How to do this, Google will tell you when port-forwarding is requested.

Materials:

Also popular now: