How To: Software RAID & LVM CentOS 7 Install

Hi, this is my first post on ictDude and i’m going to show you how to install CentOS 7  in a software RAID Level 1 (mirror) configuration with LVM. If You dont have two disks on stock  or don’t want to screw things up i will start with a virtual machine intro.  I’ll setup a two fixed size virtual drives and move on with a fresh RAID Level 1 LVM CentOS 7 install.

If You find this post helpful, leave a comment and like me on facebook.

Requirements for this tutorial ( hardware setup ):

  • Two Hard Disks
  • CentOS CD/DVD/Bootable USB installation media

OR ( virtual machine setup )

  • VirtualBox installer
  • CentOS 7 iso file

Virtual Machine Setup Intro:

Download CentOS 7 netinstall iso from HERE
( i have chosen netinstall for this tutorial but feel  free to pick any of the available iso that suits your needs)

Download and install VirtualBox from HERE 

New VM Button in VirtualBox

Start Oracle VM VirtualBox and click New to start a VM wizard.

VM name

Enter the Name of Your Virtual Machine. Select Linux from the Type dropdown. Set RedHat (64 bit) as a Version – you won’t find CentOS on this list but RedHat  is basically a commercial version of CentOS. Click Next.

Choose RAM size for your virtual machine. As this is just a install testbed i will leave 512MB. Click Next

Choose Create a virtual hard drive now (this will create 1 of 2 virtual drives required for RAID1 setup) Click Create

Choose VDI as a type of file and click Next. Choose a Fixed size in an storage step and click Next. As this is a first drive i suggest setting proper name for it: in my case ictDude_01_a.  Select the size of the disk: I’ll leave 8GB ( this is 8GB per drive so 16GB on your host hard disk in total ). Click Create.

Now VM is created but we need to repeat previous steps for the second disk:
On the left you’ll see a list of virtual machines. Newly created VM has a “Powered Off” status. Right click on it’s name and from context menu select Settings. From the list on the left choose storage. On the right you have one disk (in my case ictDude_01_a) in SATA controller section. Right Click on SATA controller and Add Hard Disk and then Create new disk.

Now we’re going to repeat above steps for second disk:

Choose VDI as a type of file and click Next. Choose Fixed size in an storage step and click Next. Set a name for a second drive: in my case ictDude_01_b. Select the size of the disk: I’ll leave 8GB ( this is 8GB per drive so 16GB in total ). Click Create.

VM Drives for RAID

We have two virtual hard drives. Before we power up our VM, we need to mount an iso file with CentOS 7 on a virtual CD/DVD drive. Click on Empty device on Controller: IDE, and in attributes section click CD icon, then Choose a virtual CD/DVD disk. Navigate and open CentOS 7 iso file. Empty turned into Centos-7.. label. Click OK.

We are good to go with an OS installation.

Important Note for beginners: Use right Ctrl key to switch between Host(Your system) and Guest(virtual Machine)

start

Click Your VM from the list on left and Start with an green arrow button.

 

CentOs 7 Installation with RAID1 and LVM

Once You Boot Up with a CentOS 7 Installation media choose Install CentOS.

CentOS 7 Language

On a welcome screen choose installer language and click Continue.

ictDude_01
Now you’re on installation summary. Let’s take a look at each installation item marked with warning icon.

ictDude_011

Network & Hostname
In upper right corner switch device ON.
In the lower left corner enter hostname.
After that click Done in the upper left corner.

ictDude_021

Date & Time
Choose your region, city, time format, time and date.
You can choose Your city directly by clicking on the map.
If You have internet connection, you can switch on Network Time, to synchronize date & time with NTP server.

After that click “Done” in the upper left corner.

ictDude_0231

Installation Source
Since i have chosen netinstall iso, i will specify here a mirror for OS download. Pick a  mirror from your country or nearby countries:

http://isoredirect.centos.org/centos/7/isos/x86_64/

change URL to have os instead of isos

Ex.
 centos.hitme.net.pl/7/isos/x86_64/
to
 centos.hitme.net.pl/7/os/x86_64/

Click Done.

Software Selection
Choose the base environment that suits you. Ex. minimal.
Click Done.

Now we have to prepare RAID for system installation.

ictDude_02331

Installation Destination
Check both disks from “Local Standard Disks” area.
Ensure both disks are checked.
Select I will configure partitioning.
Click Full disk summary and bootloader…
Ensure first disk is checked.

Since we have mirror RAID, you can check only one, but both disks will have a bootloader.
Click Done

ictDude_0133
Select LVM as a partitioning Scheme.

ictDude_01223

Add a new mount point (“+” icon) set mount point /boot and capacity to 512 .
Change Device Type to RAID, and RAID Level to RAID1.

Now we have one RAID device, for /boot
We need another for Logical Volume Group.
From this point you have two options.
You can set whole capacity to ‘/’ mount point, or set capacity per nodes like /home, /var or whatever.
I’ll follow the second option.
My layout:

/          1GB
/home      1GB
/usr       1GB
/usr/local 2GB
/tmp       512MB
swap       1GB
/var       leave empty to fill disk capacity

ictDude_zx01

Add a new mount point ‘/’ set size to whatever you want.
On right area set Device Type to LVM, and at Volume Group ‘centos’ click Modify…

ictDude_0dsadad1
Select Both disks and change RAID Level to RAID1. Save

Make sure that other mount points under ‘/’ (excluding /boot) have type set to LVM, and are in the same volume group with RAID Level 1.
Click Done (twice if neccessary) and then Accept Changes.

ictDude_0331

Ensure that there is no warning sign at any of items on instalation summary screen.
Click Begin Installation.

ictDude_01daictDude_01xx

During installation set up root password and create non-root user.
Once installation is complete, click Reboot button.

Boot into your new system, and log in as a root.

Check RAID Array status with

[root@localhost ~]#cat /proc/mdstat
Personalities : [raid1]
md126 : active raid1 sda2[0] sdb2[1]
      7859136 blocks super 1.2 [2/2] [UU]
      bitmap: 0/1 pages [OKB], 65536KB chunk
md127 : active raid1 sdb1[0] sda1[1]
      524224 blocks super 1.0 [2/2] [UU]

You should now see two md devices with RAID Level 1 .

 

14 thoughts on “How To: Software RAID & LVM CentOS 7 Install

  1. Thanks, I’ve been struggling with the new CentOS 7 installation interface for weeks.

    Do you know how to replace a disk in a software raid 1 setup?

  2. Thank you very much. I’ve been using CenOS 6 for partitioning and RAID and LVM LV creation … until today. I tried it. It works! Thank you again!

  3. Nice.
    Now, how do you do it WITHOUT LVM??
    I’ve been fighting this for days, and getting no where. I don’t want LVM! I don’t care who says what good about it – its unnecessary in most of my situations and I don’t want the extra hassle of it if I have to pull data from a drive manually.
    So I NEVER want LVM. But your method is the only way I’ve located to install a RAID 1 without a lot of manual post-install work.
    What’s happened to Redhat and Centos? The partitioning tools in the install used to offer all kinds of options – RAID among them. But now that I need it – its not there.

    • I did two tests this morning, one with single mount point “/” and one with many mount points. It looks like it created a raid device per mount point (1 md device in test 1, several md devices in test 2) . I don’t know if it is an expected result. I’ll try to compare this with CentOS 6 this evening.

      Here are steps:
      In installation destination step mark two devices (as i did i this tutorial), then select “Standard Partiton” instead LVM as partitioning scheme. Create mount points and choose Device Type RAID and RAID level 1 for each mount point.

    • You can install CentOS 7 in RAID1 without LVM. I’m sure that you’ve missed RAID option. CentOS 7 installer is unintuitive but it offers the same functionality as it was in CentOS 6. Just choose Standard Partition instead LVM. Let me know if You have any problems with it. I did some tests and i had no problems with RAID installation both with or without LVM.

  4. I want to setup a system in a slightly different manner.

    I am relatively new to Linux, so am endeavoring to learn how to setup a system in the best and most efficient possible way, however it is proving difficult to find relevant information.

    I have a VM with 3 disks, as a practice in advance of setting up a normal system

    I wish to use LVM RAID as opposed to LVM on top of MD RAID.

    The use of LVM RAID allows for greater flexibility when it comes to moving or expanding storage.

    I understand that the installer does not support the creation of LVM RAID Volumes during installation but should recognize pre-existing volumes.

    I therefor created a number of Partitions and allocated corresponding Partitions to Volume Groups, 1 RAID0 for SWAP and some RAID5 for boot FS and System.

    When attempting to run the installer and access the pre-existing volumes, the installer recognises the Logical Volumes, but when attempting to select and use the Logical Volumes, the installer Crashes.

    I cannot provide much detail beyond this at this point, as it is difficult to pull information from the VM – I have to restart the VM each time it fails. I have no idea how to extract information from the VM.

    I’d appreciate any guidance you might be able to provide on how to pull info out and resolve this issue

Leave a Reply

Your email address will not be published. Required fields are marked *