Question

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?

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.


Submit an answer


This textbox defaults to using Markdown to format your answer.

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

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

jarland
DigitalOcean Employee
DigitalOcean Employee badge
November 25, 2018
Accepted 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 :)

Jarland

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.