I have a server with three hard drives:
- 250 GB
- 3 TB
- 250 GB
How can I merge multiple hard drives as one bigger volume of ~ 3.5 TB? I am a programmer not a system administrator.
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
Use LVM (Logical Volume Management) on Linux.
You can think of LVM as "dynamic partitions", meaning that you can create/resize/delete LVM "partitions" (they're called "Logical Volumes" in LVM-speak) from the command line while your Linux system is running: no need to reboot the system to make the kernel aware of the newly-created or resized partitions.
First of all you can use
-l option to get info about your current "Disks", then use it to partition your "Disks" and setting the system type of those partitions to "Linux LVM", after you finish the partitioning of the "Disks", use
pvcreate to prepare your new partitions for "LVM".
For more info: https://www.howtoforge.com/linux_lvm
The following can do what you want (also search for "union filsystems"):
There are others but these are or were popular at one time. LVM is dangerous because loss of a drive will destroy the whole filesystem. unionfs doesn't seem to be developed any more. Aufs is complicated and requires compiling kernel stuff. overlayfs has CoW modes and is built in to modern kernels so it's easily available on almost every system and is popular for container style virtual machines (eg. Docker). However, overlayfs has some limitations compared to a normal filesystem. mergerfs uses FUSE so can run in user space and acts like a normal filesystem. Of these choices I would recommend mergerfs or overlayfs depending on your needs.
Concatenating filesystems like this can be useful because it allows the underlying filesystems to be separate entities. This can under certain workloads actually provide more performance than a typical RAID array because it can reduce random access activity (eg. 10 clients accessing 10 separate drives). Failure of individual drives won't lose all the data on all drives. You can also combine a union filesystem with something like SnapRAID to get backup/redundancy.
If you want to "merge" the drives into one contiguous filesystem, the answer above with LVM is probably the best answer, though I would be very cautious doing that. The considerations noted above are very real. (e.g. the loss of one drive could make the data on all drives irretrievable.)
Depending on your usage of the 3 drives, I would think it would be best to go and get a 4TB hard drive and copy all the partitions from the other 3 drives onto it with a utility like "(g)parted" or "dd/ddrescue". This way, you still maintain the original drives should anything go wrong.
Now, if one or more of the 3 drives is a system's root partition (e.g. one or more hard drives is a system's OS drive that you will want to boot to after the "merge" operation), I would look at another way to do it, or set up the 4TB drive to boot the OS partition(s) via grub.
The other answers provide answers to your question. However your need may be better met by RAID.
combining both 250GB drives into a software raid1, giving you 250 GB (~228 GB effectively) of redundant storage for the data you care about. This could be your OS, and your personal files. Then use the single 3TB drive as a /data store, knowing that it is less-protected.
Purchase a second 3TB drive and raid1 the two big drives, giving you 2.6TB effective storage, but protected against failure of a single drive. Can combine with raid1 of the two 250 GB drives for a fully redundant system / data separation. Best idea if you can afford it.
Raid5 over the three drives, giving effective storage of ~500GB and wasting most of the 3TB drive. Wasteful
JBOD / linear raid This will give the full 3.5TB (about 3.1 TB effectively) but failure of any drive will dump the entire contents of the whole filesystem. This is bad - don't do it - only mentioned for completeness.
Do note that NONE of these suggestions replace a proper backup routine. Raid protects against drive failure, not file deletion or loss by burglary or fire.
LVM on top is another layer up the abstraction tree - and will achieve similar goals but without the resiliency of raid.