Pushing My Owncloud File Size To 3 GB

owncloud-logoBy default, Owncloud is configured to handle files up to a size of 512 MB. While that’s probably good enough for most, I do run into this limit rather often. There are instructions how to increase the limit from an Owncloud point of view but when I recently wanted to transfer a 2.7 GB file my setup failed outside of Owncloud. It took me a bit before I found out how to fix it so I thought I put together all things I have now learned about how to configure a system for large file transfers in Owncloud with a number of security and privacy tips thrown in for good measure.

My Security Setup

A few words about my setup before I come to the heart of the matter. As a security conscious type my Owncloud server has a plain Ubuntu Linux system partition and an encrypted LUKS partition for data, including the Owncloud data directory. After system startup I have to mount the encrypted partition manually and type in the password, as storing the password on the server would defeat the whole approach.

Another security measure I have taken is that the /tmp directory used by many applications, including Owncloud, does not reside on the non-encrypted home partition. This is necessary as file uploads are first written into this directory before Owncloud copies the files to its data directory. This directory can’t be on the encrypted partition as it needs to be available during system startup. As a consequence I map a resizable RAM disk (‘tmpfs’) over this directory. This way any temporary data is only held in RAM and never on an non-encrypted disk partition.

Parameters to Change for 3 GB Files

To go beyond the 512 MB file size limit in Owncloud I had to modify parameters in 3 corners of the system. The first place is Owncloud itself which has three variables for file size limitations in the access control file (.htaccess) in the /var/www/owncloud directory. These have to be changed as follows:

php_value upload_max_filesize 3000M
php_value post_max_size 3000M
php_value memory_limit 3000M

It’s important to remember that each time Owncloud is updated this step has to be repeated as the update overwrites the changes.

There are similar variables in /etc/php5/apache2/php.ini which only need to be modified once as these are not overwritten by Owncloud updates:

max_input_time = 360
post_max_size = 3000M
upload_max_filesize = 3000M

It could be that it’s not necessary to modify them as I’ve done uploads in the past that have taken much longer than the max_input_time variable. The other two variables might be overwritten by the changes in .htaccess above. So while these changes might perhaps not be necessary, they don’t hurt either.

And the third thing that I needed to adjust was the size of the RAM disk for the temporary directory. When I configured the server I set the size to a maximum of 1 GB. As files are stored here during file upload via the web page I ran out of space when I tried to upload that 2.7 GB file. As a consequence I modified /etc/fstab to allow up to 3.2 GB of RAM to be used for the temporary directory:

tmpfs /tmp tmpfs size=3200m 0 0

Considering that I only have 4 GB of RAM in my server that’s quite a bit. But the RAM disk is dynamic, i.e. it only takes the 3.2 GB of RAM if it really needs it and it is swapable, i.e. a part of it can be moved to my 4 GB encrypted SWAP partition should it become necessary. Not ideal, agreed, but it works in practice.

And that’s it, after a reboot I can up- and download 3 GB files in Owncloud!

A Few Words About Timeouts

One other thing to check for is if there are any timeouts due to the long upload and download times. In my setup I have fortunately not encountered any with the settings above:

When uploading the 2.7 GB file I had a 50 Mbit/s line available so the upload took around 430 seconds or 7.2 minutes. Downloading files from my Owncloud server takes much longer as my VDSL line uplink at home is limited to 10 Mbit/s in the uplink direction. As a consequence downloading that 2.7 GB file from the Internet takes around 2160 seconds or around 38 minutes. In practice it was probably around 45 minutes. Make it 20 minutes per gigabyte when you give out estimations of how long downloads will take and you are on the safe side. Having said that I was again positively surprised as Owncloud was patient and the file transfer finished successfully. An md5sum check afterward confirmed that all bits made it safely to my Owncloud and back.