Best practices using block storage on DO?

April 26, 2016 4.5k views
DigitalOcean Ubuntu

Hi, I am currently a Beta User of the Block Storage option on DO.

I would like to know how do I save something on a Block Storage drive.

Specifically I would like to set up OwnCloud to use a block storage drive exceeding the 20gb on a 512 mb sever. I have confirmed that this server is properly configured to use Block Storage, just don't know how to change storage drive.

I would ultimately like to know (if possible) how to move the drive with all of the data to a different sever.

Thanks In Advance.

1 Answer


Thanks for participating on our Block Storage Beta. To replicate your use case I used DigitalOcean's One-Click OwnCloud install, which set up the droplet for me, the next step was to add a drive.

After creating and attaching a drive to your droplet, which you said you already did, you need to format and mount it, as explained on the beta tutorial, lets see how it would work on our one-click OwnCloud setup.

SSH into your droplet and find out the block device name that was given to the drive with the command lsblk, like so:

root@owncloud-512mb-nyc1-01:~# lsblk
sda      8:0    0  11G  0 disk 
vda    253:0    0  20G  0 disk 
└─vda1 253:1    0  20G  0 part /

In my case I have a 11GB drive, it got named sda. Now that I know its name, I can format and mount it. Formating will erase all the data in it (I'm assuming this is a brand new drive and doesn't contain your data) and prepare the filesystem on it. I'll do that with the command mkfs and I'll use the ext4 filesystem, which is the default on most Linux distros:

mkfs -t ext4 /dev/sda

Now I need to mount it on a folder, so it will be visible to the droplet filesystem and I can put files on it. To do that first I need to create a folder, in my case it will be on /mnt/owncloud_data.

mkdir -p /mnt/owncloud_data

It's common practice to create a folder inside /mnt to mount your block devices, but you could choose other folders. Now that I have my folder I can mount the block device on it, like so:

mount -o discard,defaults /dev/sda /mnt/owncloud_data

If I run lsblk again I'll see that it's name on the mountpoint for sda:

root@owncloud-512mb-nyc1-01:~# lsblk
sda      8:0    0  11G  0 disk /mnt/owncloud_data
vda    253:0    0  20G  0 disk 
└─vda1 253:1    0  20G  0 part /

Now I'm ready to use my drive to store my OwnCloud files. I'm not an OwnCloud expert, so I used the instructions on this YouTube video to change it's configuration (thanks locslikes). Remember their recommendation about backing up your files before you do this kind of change.

By default, the OwnCloud one-click droplet will use the folder /var/www/owncloud/data to store files, I need to move it to my drive. To do so I'll stop Apache and them move the folder, like so:

service apache2 stop
mv /var/www/owncloud/data /mnt/owncloud_data

You should see a new folder inside /mnt/owncloud_data like so:

root@owncloud-512mb-nyc1-01:~# ls -l /mnt/owncloud_data/
total 20
drwxrwx--- 4 www-data www-data  4096 Apr 27 19:43 data
drwx------ 2 root     root     16384 Apr 27 19:53 lost+found

Now we change OwnCloud's configuration to point to the new folder, modifying the file /var/www/owncloud/config/config.php. Open it with your favorite editor and change the line:

  'datadirectory' => '/var/www/owncloud/data',


  'datadirectory' => '/mnt/owncloud_data/data',

Save the file and restart Apache:

service apache2 start

Access your droplet IP, log into OwnCloud and the files you upload will be stored on your new block storage drive instead of the droplet local storage.

In the future I could detach the drive from this droplet, attach it to another OwnCloud droplet, mount it without formatting, changing the config just like we did above and my data would be available on the new droplet. The steps are pretty much the same, just make sure you don't format the drive :)

Just remember that Block Storage is still in beta, some details might change when we make updates and we don't provide a SLA for your data, so you should not use it for production applications yet. Also, we are aware that the process of formating and mouting is cumbersome and not user friendly, we are working to make it easier in the near future.

I hope this was helpful.

Best regards,

DigitalOcean's ownCloud One-Click application provides a quick way to set up file sharing and other cloud services on a server you control. This tutorial will guide you through the steps to finish configuring your site, including setting your domain name, installing an SSL certificate, and enabling file encryption.
  • Thanks so much for the detailed explanation! It was really helpful.

  • Using my own money, I would absolutely love to help test the above as well as give feedback for a new one-click install instance that incorporates:

    1. OwnCloud + DO droplet + Size A Block Storage
    2. OwnCloud + DO droplet increase in size after deployment and files uploaded from Size A to Size X.
    3. outlined below possibly? Cannot wait for this! Among the other many use-cases, this is a gamechanger for OwnCloud and self-cloud storage users who love DO. Thanks for the great work!

    3? Also, can the DO + OwnCloud one-click install be updated to include addition of HTTPS everywhere from LetsEncrypt as well as using 4096 bit keys while requiring TLS greater than X? Basically, min allow for a deployed owncloud DO droplet with an A+ on Thank you!

    • Hello,

      After the storage product is launched we will revisit our one-click apps and consider which ones could benefit from it. Regarding adding LetsEncrypt to the images, I'll pass the feedback along, it's a good point.

      Best regards

Have another answer? Share your knowledge.