Using a Secondary Hard Drive on a Dedicated Server

If you have a dedicated server with 2 hard drives, there might come a time where your primary hard drive is starting to become full, and you’d like to utilize your secondary hard drive.

You can either simply create an FTP account with access to your secondary hard drive to start uploading files there for storage, or you can go all out and rearrange your cPanel account to actually use the secondary hard drive for all of their files.

Please note that to follow either of these options you need to have root access on your dedicated server.

Find Disk Usage on Server

Prior to setting up anything on your secondary hard drive, you should understand the current disk usage on your server which is very simple to review following these steps.

  1. Login via SSH as the root user on your server.
  2. Run the following command:
    df -h

    You should get output similiar to this:

    Filesystem            Size  Used Avail Use% Mounted on /dev/sdb1             222G  186G   25G  89% / /dev/sda1             226G  228M  214G   1% /home2 tmpfs                 2.0G     0  2.0G   0% /dev/shm /usr/tmpDSK           485M   12M  448M   3% /tmp

    I have highlighted in red the secondary drive on this server indicated by /home2. You can see we’re using up about 89% of the available disk space on our primary hard drive, with 25GB to spare.

    Let’s say you know you need to upload 30GB worth of files to store on your server, since you still have 214GB free on the secondary hard drive you could use that instead of filling your primary hard drive past capacity.

Rearrange cPanel Account onto Secondary Drive

If you’re running out of hard drive space on your primary drive, and still need to upload website files directly to your cPanel account, you can rearrange the cPanel account to have its home directory on your secondary drive.

You could also just create a separate FTP account on the secondary hard drive if you just needed some more file storage separate from your primary hard drive.

  1. Login to WHM on your dedicated server.
  2. whm click on rearrange an account

    In the top-left search box type rearrange

    Then click on Rearrange an Account

  3. whm select account and click rearrange

    Select a cPanel account you want to move to your secondary drive, and then click on Rearrange

  4. whm select new mount point click move account

    You can see the Current Home Directory is set to /home/example

    Select /home2 from the New mount point for this account drop-down and click Move Account

    DO NOT close WHM or try to interrupt the move process until it fully completes. Depending on the size of your cPanel account this could take some time.

    You should see a success message once the move is complete:

    whm rearrange an account completed

  5. Now whenever you upload files for this cPanel account, it will be uploaded to your secondary drive instead of continuing to fill up the primary one.You can verify this on the server by running:
    file /home/example

    The server should spit back:

    /home/example: symbolic link to `/home2/example'

    This shows that nothing will be uploaded to the primary hard drive on /home for this example cPanel user, as their home directory on the primary drive is simply a symbolic link to their home directory on the secondary drive.

Create Separate FTP Account on Secondary Hard Drive

If you just need to store some files on your server such as database backups, or something you aren’t going to directly use on your website right away. You can simply create a 2nd FTP account on your secondary hard drive to upload these type of files there.

These files would only be accessible over FTP. You wouldn’t be able to access them from cPanel, or via your website. If you need that you can rearrange a cPanel account onto the secondary drive instead.

  1. Login to cPanel for the account you wish to create an FTP account on your secondary drive for.
  2. click on ftp accounts

    Under the Files section, click on FTP Accounts.

  3. create 2nd drive ftp user

    Fill in the details for a new FTP user, in this case you can see I’m naming mine [email protected] and assigning the user’s directory to be /home/example/public_html/2ndDrive

    Then click on Create FTP Account

  4. Now login to your server with the root user via SSH
  5. In this example we created our secondary FTP account on our example cPanel account. The actual settings for this FTP user are stored then in the example user’s proftpd file which you can view with:
    cat /etc/proftpd/example

    This will spit back all the current FTP account settings for this example cPanel user:

    2nddrive:$1$9Xp:502:501:example:/home/example/public_html/2ndDrive:/bin/ftpsh example:$1$nsk:502:501::/home/example:/bin/bash ftp::14:50::/home/example/public_ftp:/bin/ftpsh example_logs:$1$nsk:502:501:example:/usr/local/apache/domlogs/example:/bin/ftpsh

    I’ve trimmed the long password hashes so the text can fit above, but you should see I’ve highlighted in red the 2ndDrive FTP user we created, and it belongs to the example cPanel user and the home directory is set to /home/example/public_html/2ndDrive

  6. Now edit the /etc/proftpd/example file using this command:
    vi /etc/proftpd/example

    Now use your arrow keys to navigate in the vi text-editor till the /home/ line of our new FTP user.

    Hit i on your keyboard to enter INSERT mode, and edit this line to read /home2/example/2ndDrive

    Then hit ESC to exit INSERT mode, and then Shift ZZ to save the file

    edit etc proftpd ftp path

  7. Next you’ll want to create the directory on the secondary hard drive for this FTP user with:
    mkdir -p /home2/example/2ndDrive

    You also want to sure the example cPanel username has ownership of this directory with:

    chown example.example /home2/example/2ndDrive -R
  8. upload file via ftp to secondary drive

    Now if you connect with this [email protected] FTP user in your FTP client, you’ll be presented a blank directory, and you can start uploading files there.

    After your files are upload you can take a look back on the server to verify it ended up on your secondary drive:

    ll /home2/example/2ndDrive

    You should see the file you just uploaded:

     total 39776 drwxr-xr-x 2 example example     4096 Nov 14 14:38 ./ drwxr-xr-x 3 root    root        4096 Nov 14 14:33 ../ -rw-r--r-- 1 example example 40677376 Nov 14 14:39 brackets-sprint-33-WIN.msi

You should now understand how to find out how much disk space is being used on all of the hard drives on your server. Also how to either create a secondary FTP account to utilize the secondary hard drive, or rearranging the entire cPanel account to make the secondary hard drive the user’s new home going forward.

IC
InMotion Hosting Contributor

InMotion Hosting contributors are highly knowledgeable individuals who create relevant content on new trends and troubleshooting techniques to help you achieve your online goals!

More Articles by InMotion Hosting

3 Comments

  • df -h show only one disk can you disk partition system is

    1000GB 
    / 4000
    /boot 250M
    /usr 16000M
    /var 16000M
    /tmp 1024M
    swap (16000M)
    /home fill to disk 

    1000GB 
    / 4000 
    swap (16000M)
    /home2 fill to disk

    when centos installation complete it show 

     

    [[email protected] home]# df -h
    Filesystem Size Used Avail Use% Mounted on
    /dev/sdb1 39G 701M 36G 2% /
    tmpfs 16G 0 16G 0% /dev/shm
    /dev/sdb3 863G 72M 820G 1% /home2
    [[email protected] home]#

    why not showing second disk

Was this article helpful? Let us know!