0

I have a dedicated server containing 4x500GB HDD running on Centos 6. My main disk got full and it caused MySQL server to terminate, for which I had to clear some space to solve it (temporarily).

Below is the result for running the following command parted -l

Model: ATA MB0500EBNCR (scsi)
Disk /dev/sda: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End    Size    Type      File system     Flags
 1      1049kB  525MB  524MB   primary   ext2            boot
 2      525MB   492GB  491GB   primary   ext4
 3      492GB   496GB  4295MB  primary   linux-swap(v1)
 4      496GB   500GB  4295MB  extended
 5      496GB   500GB  4294MB  logical   ext4


Model: ATA MB0500EBNCR (scsi)
Disk /dev/sdb: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start  End  Size  Type  File system  Flags


Model: ATA MB0500EBNCR (scsi)
Disk /dev/sdc: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start  End  Size  Type  File system  Flags


Model: ATA MB0500EBNCR (scsi)
Disk /dev/sdd: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start  End  Size  Type  File system  Flags

This folder "/home/admin/domains/mydomain.com/public_html/Documents" is large in size and I would like to move it to another partition. (From "sda" to "sdb")

What is the proper way to do so while maintaining the URL path to the files on the new partition? mydomain.com/Documents

1

There are a few options for this.

Quick and dirty

The q&d approach (good for coming up with a better solution afterwards without constantly worrying) can be one of the following.

a) Symlink. A very easy approach. Copy the files to your target directory. Rename away the source directory. Then ln -s NEWDIR /home/admin/domains/mydomain.com/public_html/Documents where NEWDIR is the absolute path to your newly chosen storage location.

b) Bind-Mount. It is possible that the symlink approach fails (the documents will show up as inaccessible). This is a side-effect of the server configuration (whether the webserver is allowed to follow symlinks or not). In case the server does not follow the symlink, do this instead (after copying+renaming as before or in case you tried the symlink first: after deleting the symlink with rm /home/admin/domains/mydomain.com/public_html/Documents): mkdir /home/admin/domains/mydomain.com/public_html/Documents && mount -o bind NEWDIR /home/admin/domains/mydomain.com/public_html/Documents

Edit: When doing the bind-mount and not following the steps to the "actual solution" (for whatever reason), additionally add the mount to the /etc/fstab s.t. it persists after a server reboot.

Actual solution

All common webservers can be configured to read files from different directories. Edit the configuration to point to the new directory and restart/reload the server. It can then serve files from adifferent place under the same URL.

Cleanup

In case you followed my advice to "move away" files first, after everything works, this copy can be deleted.

1
  • Thanks. I mounted my other disk to the Documents folder in /etc/fstab
    – Tony AS
    Nov 15 '19 at 17:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.