Best way to create RAID on an existing system drive

6,671

If you're using LVM for the primary partition you can always add another disk to the pool and then extend into it. Given you're using CentOS I would assume that the system was setup so that you have an LVM partition providing your storage and then their are logical volumes coming from LVM for /home and /.

Example

Here on this CentOS 6.x system I have the following physical volumes being included into LVM.

$ sudo -i

$ pvs
  PV         VG         Fmt  Attr PSize   PFree
  /dev/sda2  VolGroup00 lvm2 a--  465.66G    0 

The HDD /dev/sda2 is part of a single volume group:

$ vgs
  VG         #PV #LV #SN Attr   VSize   VFree
  VolGroup00   1   3   0 wz--n- 465.66G    0 

The logical volumes are as follows:

$ lvs
  LV       VG         Attr   LSize   Origin Snap%  Move Log Copy%  Convert
  LogVol00 VolGroup00 -wi-ao 442.19G                                      
  LogVol01 VolGroup00 -wi-ao  13.69G                                      
  LogVol02 VolGroup00 -wi-a-   9.78G                  

These logical volumes get mounted like so:

$ mount
/dev/mapper/VolGroup00-LogVol00 on / type ext3 (rw)

So you could add another disk to the volume group and then make use of it in which ever logical volume needs the space.

Diagram

                              ss of LVM

The above, hopefully, illustrates how LVM architecturally works. Often times, people will create LVM volume groups which sit on top of RAID arrays. This gives you the ability to expand a filesystem using LVM but with the protection offered through the use of a RAID array for redundancy purposes.

So you could add another physical volume to the VG (volume group). This new physical volume would then show up as new space which could then be allocated to one of the LG's (logical volumes).

Migrating to RAID

  1. I would suggest setting up the RAID along side your existing HDD. You can setup a RAID array as RAID1 (then degrade it by only adding 1 HDD to it.)

  2. Once the RAID array is setup, I'd put LVM on top of it as discussed above, and then migrate the data from the existing HDD to the LVM topped RAID1 array.

  3. Once the data has been migrated in, you can then bring the original disk into the RAID1 array and resync it.

For the nitty gritty details I often refer to this HowtoForge article, titled: How To Set Up Software RAID1 On A Running LVM System (Incl. GRUB2 Configuration) (Ubuntu 10.04). Don't let the reference to Ubuntu scare you away, most of the steps are identical and I find the level of details in this particular article crucial to understanding what you're actually doing for the various steps when migrating to a LVM + RAID1 setup.

References

Share:
6,671

Related videos on Youtube

xcorat
Author by

xcorat

Updated on September 18, 2022

Comments

  • xcorat
    xcorat over 1 year

    I want to add another disk as RAID 1 to test my database performance. I am trying to not re-do the whole system, is it possible?

    Currently I have a single 1TB HDD with one 100GB system partition (and swap, boot) and a 850GB /home partition. I want to if possible, add another 1TB drive and convert the whole system to RAID 1, or atleast raid the /home partition (and discard the other 150GB on the second disk).

    Is it possible? atleast in software RAID (on CentOS 6.4)

  • xcorat
    xcorat over 10 years
    yes. they are logical. is there any guides to doing that? Sorry I have never done it. And that wouldn't work for the whole drive right?
  • Dan Garthwaite
    Dan Garthwaite over 10 years
    This looks reasonably carefully written: community.spiceworks.com/how_to/show/…
  • slm
    slm over 10 years
    @xcorat - The use of LVM + RAID is powerful but requires you master 3 technologies, so often it scares ppl away. You need to understand LVM, mdadm (RAID) and disk partitioning w/in Linux. I would spend the time with another drive experimenting prior to doing this work if you've never done it before.
  • slm
    slm over 10 years
    @xcorat - The LVM you can add more disks but it's more inline with a RAID0 (it's not RAID at all - but your data is now spread across 2+ disks, so it's more risky).
  • xcorat
    xcorat over 10 years
    Thank you for the great answer. But we thought it's better to raid the whole drive anyway and did it from scratch. I'm sure this will be useful at some point anyway.
  • slm
    slm over 10 years
    @xcorat - yes, once you understand how to setup RAID w/ LVM it's best/easiest to always set them up from the get go. Doing it afterwards though possible, is more work and exposes your data to risks that aren't really worth it in the long run.