i've auto added a 100gb volume to my droplet for storage, how do i save and retrieve files from the volume, what path would i use?

November 25, 2018 3.5k views
PHP Getting Started DigitalOcean PHP Frameworks Block Storage Ubuntu 18.04 Automated Setups

apologies for the novice question. I am a beginner at all of this.

I’ve been working on an app using the laravel framework with forge/digitalocean, and came to realize I needed much larger storage. After some research found out that digitalocean volumes seemed well enough to store the massive amount of images, json files, etc… I needed for the app.

My question is normally within the framework I can access any file to save it/retrieve it with either a relative/absolute file path, but I can’t seem to figure what the next step is to save files to the newly mounted digitalocean volume i.e. what path to use to save the file to, and of course what path to use to retrieve the file after saving.

I’ve seen some mention of symlinks being used or possibly mounting the volume directly to a laravel directory or creating a new disk in laravels flysystem. But this all seems counter intuitive, and I don’t think trying to save the file with ../../../../../mnt/newlyCreatedVolume is the answer.

Any help or guidance is appreciated.

1 Answer

Hey friend,

Great question! I don’t really use larvel myself but this should be a generic Linux question regardless of that, but just know that this is where I come from when answering it.

Let’s say your Laravel project is in /home/username, and your volume is /dev/sda. I would do this:

mv /home/username /home/username.bak
mkfs.ext4 /dev/sda #(this erases the volume, don't do this if you have data on it right now)
mkdir /home/username
mount /dev/sda /home/username
mv /home/username.bak/* /home/username

And then to top it off, if it’s /home/username because you’re working on the project while under the user “username” and not root, then:

chown -R username. /home/username

Then just keep working on your project in /home/username like nothing happened, run a “df -h” to see that /home/username now has the amount of storage of the block storage volume. To make the mount persist on reboot, do this:

echo "/dev/sda /home/username ext4 defaults 1 2" >> /etc/fstab

Remember that my example has the volume as /dev/sda. You can see the volumes on your droplet by running “fdisk -l” and you can generally tell them apart by their stated size.

Hope this helps :)


  • Excellent, thank you.

    I think this should do the trick.

    • did you stored the medial files, like images and how did you access the file to show images in your project.

      • Yes, I ended up storing a few million json files, a couple hundred thousand images and other various files in high quantity.

        Essentially exactly how jarland described, I followed those instructions. You take the defaulted path of the new mounted volume and create a link into a directory of your project that works like any directory you would have manually created, stored, and retrieved files from. So the result ends up being two directories tied together, a back-end directory which is the actual mounted volume and a front-end directory that is usable as needed. And at that point it is as simple of referencing any image or file in the /public/images directory for example.

        I only real issue I ended up running into was with the inodes of the new volume. i.e “The issue I am noticing at the moment is that after the first 3 million .json files the inode used % is already at 85%, even though the storage usage is only at 12%.” This meant that I couldn’t upload any new files.

        But another forum member; unixynet was able to assist :) link below:


Have another answer? Share your knowledge.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!