How can I create one large partiton over two drives in CentOS?
You need to use LVM (Logical Volume Manager)
First of all , you must be aware that if any of the physical disk fail , the Big 4TB volume will fail too. Backup your data first!
Basically , all you need to do is to partition your data (/dev/sda2 and /dev/sdb1) partition in lvm format then :
- create two physical volumes (
pvcreate /dev/sda2 /dev/sdb1
) - create one volume group with the two physical volumes (
vgcreate VG_DATA /dev/sda2 /dev/sdb1
) - create one logical volume (
lvcreate -l 100%FREE -n DATA VG_DATA
) - create the filesystem on your new volume (
mkfs.ext3 /dev/VG_DATA/DATA
) - mount the volume (
mount /dev/VG_DATA/DATA /data
)
There are dozen of sites with howtos lvm like this one.
Lvm is a lot more than these 4 commands , read the fine manual if you want advanced configuration. I hope it will help you
I personally feel LVM
is overkill for this simple task, I would suggest setting up mdadm
to create a RAID
array.
Now you have two options:
- either a linear array, which will literally produce a concatenated partition based on two source partitions
- or
RAID-0
, which has the additional limitation that the source partitions must be of the same size but provides a substantial performance boost to reading and writing.
However beware, if either disk fails at least half and possibly all of your data will be lost. If you use a linear array some may be recoverable, with RAID-0
it will all almost certainly be destroyed, decide which of these trade-offs you want when deciding the type of array you choose.
Next, you need to create a large partition on each disk, you can do this with fdisk or any other tool, and I wont go into detail here as there are better guides elsewhere.
Then you run mdadm
in the form of:
# for a RAID-0 Array
mdadm --create --verbose /dev/md0 --level=stripe /dev/sda1 /dev/sdb2
# for a linear Array
mdadm --create --verbose /dev/md0 --level=linear /dev/sda1 /dev/sdb2
Where /dev/sda1
and /dev/sdb2
are replaced with the partitions we created in the previous step. I then suggest taking a quick browse of the mdadm man page to learn how you may need to maintain this array.
You may choose to use LVM
instead as Max has suggested and that may well serve you better if you end up with an extremely complex configuration but I do not feel it is really needed for a simple case like yours, raid may also provide substantial performance improvements over LVM if configured correctly, however that goes beyond the scope of this answer.