Need Help Managing My Hard Drives

Posted February 11, 2017 9.8k views
NginxCentOSLinux CommandsStorage

Hello Everyone. First i am inexperienced with Linux and Cent-OS. So please forgive my ignorance.

I will try my best to explain my problem and what i actuaclly want.

I have a dedicated server with 3 Hard Drives and 1 SSD. The Centos 7 is installed on the 80 GB SSD and now three hard drives are free.

Among these three hard drives two are on raid controller. Which logically means i have two extra hard drives, (As raid will show two same hard drives as one).

Now i have two hard drives free which i want to use to store my data. But the problem is that, previously i was storing my data in /var/www/html

And now if i start uploading my files to /var/www/html the SSD will get full which i dont want. Even if i bind one of my hard drives to that directory the SSD will get full.

So Here IS The Question.

  1. How Can I Use Both Of My These Extra hard Drives to work on a same directory. I made a previous thread about this and one of the mod also replied thanks to him, but i messed up and had to reinstall OS.
  2. After making these two hard drives work together, where should i point them? so that my SSD dosent gets full.

Or in simple words, I want my two extra hard drives work together and i upload files to them and users access them through Nginx web server but i dont want to upload files to my SSD.

I hope i made clear what i want.** And please if you have solution type all of the commands because i am inexperienced.**

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.

Submit an Answer
3 answers

Do you initialized and partitioned your 2 hard drives? I see that you have 3 partitions on SSD, but I don’t see any on other hard drives.
If you didn’t, you can follow DigitalOcean tutorial - How To Partition and Format Storage Devices in Linux.

Once you do this, or if you are already done, you can proceed.

/var/ and all other directories and files there (/var/www/html and so on) are on root / file system. Your root file system is on your SSD.
To overcome this, you have two possibilities.
You can change your nginx server block to use another location for /var/www/html. Location of files are defined by root directive.
Example server block:

server {
        listen 80 default_server;
        listen [::]:80 default_server;

        root /var/www/html;
        index index.html index.htm index.nginx-debian.html;

        server_name _;

        location / {
                try_files $uri $uri/ =404;

Root directive is what you want to change. After change is:

server {
        listen 80 default_server;
        listen [::]:80 default_server;

        root /mnt/www/html;
        index index.html index.htm index.nginx-debian.html;

        server_name _;

        location / {
                try_files $uri $uri/ =404;

This is most easiest solution. Change /mnt/www/html with location where you mounted hard drive. There you also need to upload files.

Second and riskier solution is to try to mount your hard drive to /var/www. In that case, you can go with default nginx config, but you should change /mnt/data from above linked tutorial to /var/www. Please be very careful when doing so! There is risk behind this, I didn’t tested this myself, but AFAIK it should work in theory!

by Justin Ellingwood
Preparing a new disk for use on a Linux system can be quick and easy. There are many tools, filesystem formats, and partitioning schemes that may complicate the process if you have specialized needs, but if you want to get up and running quickly, it's fairly...
  • Thank you very much XmudrII, no one was even bothering to reply to my this basic questions. I posted this question on many forums. But anways thanks alot to you.

    XmudrII i can do that mounting my hard drive to/mnt/ww/html but how can i mount 2 hard drives because when i mount one the other one gets removed automatically.

    • You’re welcome. =)
      This is OK behavior, that’s how mounting works. Look at the following ServerFault Question - Can we mount multiple disks as one directory?, it could help you.

      If you decide to go with LVM (which could be better IMO), you can learn more about it in DigitalOcean tutorial - An Introduction to LVM Concepts, Terminology, and Operations.

      by Justin Ellingwood
      LVM, or Logical Volume Management, is a storage device management technology that gives users the power to pool and abstract the physical layout of component storage devices for easier and flexible administration. Utilizing the device mapper Linux kernel framework, the...
      • Thanks alot mate, i am almost there, i am using CentOS 7 and when i type

        mhddfs /mnt/sdb1,/mnt/sdc1 /mnt/www/html -o allow_other

        the output is bash: mhddfs: command not found. So i tried yum install mhddfs.

        And the output was

        Loaded plugins: fastestmirror
        Loading mirror speeds from cached hostfile

        • base:
        • extras:
        • updates: No package mhddfs available. Error: Nothing to do

        I searched on google to install it by wget and get the link, but i found out that its not available for centos7 and only for centos 6. what should i do?

        • I never tried or needed mhddfs on CentOS 7, neither I can find more information about it on it, but you can try building from source.
          mhddfs README should help you do it.
          Important part of it:

          It's neccessary for install to have:
          1. FUSE header files
          2. GCC  
          3. libc6 header files
          4. uthash header files
          5. libattr1 header files (optional)
          Run 'make' in the source directory produces mhddfs binary. 
          Put the binary into /usr/bin or /usr/local/bin and now you
          can use it.
          Please read FUSE documentation for a further conception.
          GET IT
          Last version of the mhddfs drivers you can get at 

          SVN version is located at:
          To checkout SVN files run:
          svn co mhddfs

          Try this, and hope it will work. If not, I guess you’re out of luck with mhddfs and you have to go with LVM volumes.

          • Thank you very very much for replying again, i have no idea how to make this work. Should i install ubuntu 16. ? i think Mhdds is available for ubuntu right?

            I am not using LVM, because its hard to because i have to create first a logical group then a volume in it, and then bind it. I did it last time but was not successful

          • xMudrii sorry for asking, can you please give me a LVM guide i want to give it a try. i know i have to use Google, but there are lots of variations in those guides.

        • Sadly to hear you wasn’t able to get mhddfs working on CentOS 7.
          About LVM and CentOS 7, there are many tutorials there. DigitalOcean doesn’t have one, but I found some configuration examples you can take a lot at RedHat Customer Portal.

          As of Ubuntu, I don’t have what to recommend there. Choosing distro is your own, what you like and what you have experience. Personally, I like Ubuntu much more, repos have many more packages, and it’s easy to find excellent tutorial.
          If you decide to go that route, AFAIK, Ubuntu does have mhddfs (at least on Ubuntu Desktop). Also, for Ubuntu, DigitalOcean has great LVM tutorial.

          Good luck. =)

          by Justin Ellingwood
          LVM, or Logical Volume Management, is a storage device management technology that gives users the power to pool and abstract the physical layout of component storage devices for easier and flexible administration. Utilizing the device mapper Linux kernel framework, the...
          • Thanks again for replying. In the above tutorial he uses the GFS2 file system
            mkfs.gfs2 -p locknolock -j 1 /dev/newvolgroup/newlogical_volume

            As you can see in this command, do i have to use GFS2 too? i am asking because when i type this command the output is
            mkfs.gfs2: command not found

            And yum is not install GFS

          • Ok i installed GFS, but should i use GFS2? or ext4?

        • File system you choose depends on you, what you want. I would try ext4, as I guess you use it on other partitions and is more common.

          • When i type mkfs.ext4 -p locknolock -j 1 /dev/newvolgroup/newlogical_volume

            The output is
            mkfs.ext4: invalid option – ‘p’
            Usage: mkfs.ext4 [-c|-l filename] [-b block-size] [-C cluster-size]
            [-i bytes-per-inode] [-I inode-size] [-J journal-options]
            [-G flex-group-size] [-N number-of-inodes]
            [-m reserved-blocks-percentage] [-o creator-os]
            [-g blocks-per-group] [-L volume-label] [-M last-mounted-directory]
            [-O feature[,…]] [-r fs-revision] [-E extended-option[,…]]
            [-t fs-type] [-T usage-type ] [-U UUID] [-jnqvDFKSV] device [blocks-count]

        • Just a mkfs.ext4 /dev/newvolgroup/newlogical_volume should do the job. Make sure you verify above path before executing command.

        • Glad to hear that!
          Go with /mnt/www. Once you mount it, create there directory called html. This is much more flexible, for example if you decide someday to extend with another domain or subdomain.

        • That’s great!

          Now, the funny part. To make mount work automatically on startup, you have to change fstab file. Be very careful, one wrong change, you left system unbootable.
          It’s a good practice to backup fstab file before proceeding:

          • sudo cp /etc/fstab /etc/fstab.bak

          As you done this, open it with your favorite text editor:

          • sudo nano /etc/fstab

          I’m not sure is there nano on CentOS. If you can’t find it, you can use vi, but it’s not typical text editor, so if you never worked with it, better install nano.
          Don’t touch any default lines, at the end of file, add following:

          /dev/newvolgroup/newlogical_volume /mnt/www ext4 defaults 0 0

          Make sure above path matches your volume path!
          Save file and exit.

          You can reboot system to test does it work.
          Good luck. =D

          • Looks good? let me restart and then check

          • Yeap its mounted after reboot.

            i will be using this directory and space for Nginx, and basically i will upload files here and then these files will be downloaded from this server, so is there anything else i need to do?

            I really really from the bottom of my heart thank you. You have helped me lots. And i wish i help people here on digitalforum as you did. i will try my best to contribute here. And if there is something i can do for you please let me know.

            Really you solved my big problem as i am totally inexperienced with Linux.

        • It should be, go ahead, try, best of luck to you. =D

        • You’re welcome! =) I’m so glad that you got it working. =)
          This it, just make sure you don’t forget to set nginx’s root correctly, as I explained in first answer.

Why are you asking this on the DigitalOcean community?

Because i always found helpful guides here. am i doing something wrong?

  • @Zulqarnainkhan

    You’re not doing anything wrong by asking a few questions, at least not in my opinion.

    That being said, the DigitalOcean Community is more or less geared towards current/potential DigitalOcean customers, so it can be a little harder to diagnose issues that exist on custom setups or configurations not hosted on their platform.

    I personally don’t mind helping either way, so no harm.

    • Ahhh sorry i understand now. Anyways thanks for the help. I finally got some clue about what i have to do. So thanks XmudrII for helping, i hope he can lead me to the end. :D