LINUX: Best way to put folder on a seperate drive?

westrock2000

[H]F Junkie
Joined
Jun 3, 2005
Messages
9,433
I have a computer that has Linux on a single spinner drive. I also have a extra 32GB SSD sitting around. I would like to move /var/www to this spare drive (help Apache with I/O). What is the best way to do this that will have no impact on paths (keep /var/www even though on a different sda dev)?

I know there is a symbolic link, but didn't know if a /etc/fstab would be more appropriate.

Is there a way to keep the data of the old folder in tact, just redirect to the new device instead? So like in the case of a fstab mount, removing the mount just makes the system point back to the real folder with <old> data in it.
 
You could mount the SSD to /var/www/, on top of the existing data. However, this is generally considered a bad idea. Mounts should really be to empty directories.

Best thing to do is to move the existing data to the SSD. Then, either mount the SSD to /var/www/, or to another location and symlink it. I'd probably do the former, but it doesn't really matter.
 
I would keep it simple - If you want to keep the data in the existing folder intact, just copy it to a new directory (say, /var/www_backup), or tarball it up and keep the archive. Use the SSD as your running archive, and just back it up to your spinner. In the event your SSD fails, just remove the fstab mount and ln your backup directory to the old mount point of the SSD

Having it fail over.... that isn't something I've seen done commonly without something like a RAID or other redundant storage method. If your SSD fails and you need a failover to a different device, it may be possible with a High Availability LVM or something similar.

Past your request for failover, fstab is the preferred method of mounting a physical drive to a particular directory.
 
You can mount the drive just as any drive. Then edit the Apache virtual site configuration to point the root folder to that drives folder (or the drive directly). Chown + chmod privileges and you're done.

That way your original www folder contents stay intact and you don't have to play with symlinks.

Since you won't be doing a lot of writing to the www drive you don't even need to worry about trim (although newer distros automatically enable a weekly fstrim for you when it detects the SSD).
 
Back
Top