I Would like to increase my /Var which contains my Web site data and Database data already in it. is that possible to increase my /var with a Block Storage Volume WITHOUT LOOSING THE DATA ALREADY IN IT. if so . Kindly Explain the Same
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!
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.
Sign up for Infrastructure as a Newsletter.
Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Hey Sandy!
This is a bit complicated task! However, it is not impossible to accomplish it. I have managed to mount a block-storage volume to /var/ directory of my Droplet without apparent issues. However, with that being said, I highly recommend you to take snapshots of your Droplet and make sure you have local backups(downloaded from Droplet via SFTP or RSYNC or SCP). Here is what I did:
Create a new volume of 10GB(you can choose any size) .
When you are adding the volume, enter the volume name(in my case, I used the volume name as “var”) opt for Manually Format & Mount and click on Create Volume.
Once the Volume is created, you will get a Modal pop up with the mounting instructions. Copy that and save it on a notepad. It will look something like this
Now SSH into your Droplet and perform the following tasks:
snapd
service running in your Droplet:We need to stop this as snapd library files are located at /var/lib/snapd and while we copy, mount and reboot, the Droplet would fail to locate the .snap files due to block device change.
**You would need to gracefully stop any database services like MySQL as well. As I mentioned on the top, please make sure that you have backups in place. I would suggest taking MySQL dumps from your database before stopping the service and save it somewhere outside the Droplet environment. **
/var
to/var_backup
:Please make sure to replace
/dev/disk/by-id/scsi-0DO_Volume_var
with whatever was shown on your Modal pop up initially when you created the volume.Now comes the process of mounting. Here you would face downtime on your website and services. So you will want to plan this out whenever you anticipate less traffic.
Let us rename
/var
to something else:/var/
directory:/var
:(Replace
/dev/disk/by-id/scsi-0DO_Volume_var
as needed)df -h
:/var_backup
or/var_original
to/var
/etc/fstab
file like below:(Please make sure to replace
/dev/disk/by-id/scsi-0DO_Volume_var
as needed)/etc/fstab
file:/var_backup
and/var_orignal
directoryI hope this helped!
Best,
Sandesh
Please please make sure that you have backed up everything before doing the above!