This is the second from the series of step-by-step tutorials that describe building Linux Layer 3 home switch/router on Linux. The tutorial shows CentOS 6.0 installation and software RAID 1 - disk mirroring configuration.

Black and white text on the screen will appear as the computer loads the X11 environment for the CentOS install, after 30 seconds or so, we will be presented with the CentOS GUI installer, click Next.

8. Select language you want to use during installation

9. Select keyboard for the system

10. Select storage type

We do not use any special technology (iSCSI or similiar) thus choose "Basic Storage Device" option.

11. Set a hostname

12. Set a time zone

13. Set a root password

14. Select type of installation

As long as want to create our own partitions layout, choose "Create Custom Layout" option.

15. "Data storage device" / "Install Target Device" window

This window is presented only if you have two or more Hard disk drives. We have following Hard Drive Disks installed:

Model / Capacity

ATA ST320423A / 20GB
ATA ST380011A / 80GB

One from the disks has to be selected as "Install Target Device". This disk will be formatted, the bootloader and OS installed on disk. I chose both disk as Install Target Device clicking on the arrow button.

16. Partitions

We are going to create new partitions. Our goal is to create the software RAID 1 - disk mirroring. When one of the disks in the RAID set fails, the other one continues to function. When the failed disk is replaced, the data is automatically cloned to the new disk from the surviving disk.

Device | Size [MB] |

sda (/dev/sda/) 76319
Free

sdb (/dev/sdb/) 9536
Free

First, create two equal size RAID partitions on both drives. As long as we have limited with capacity of smaller disk /dev/sdb/, the size if each RAID partition will be 17GB. The next step creating of RAID device /dev/md0/ which contains both RAID partitions.

CentOS will be installed on this RAID device with mount point / and ext4 file system.

The remaining place 2535MB on /dev/sdb/ will be dedicated for SWAP partition (2 x capacity of RAM).

SWAP partition with the same capacity must be created on /dev/sda/.

If we can live with fact of lost of user's data in case of failute of /dev/sda/, the remaining space on /dev/sda/ can be used for /home directory.

Device | Size [MB] | Mount Point/RAID/Volume | Type |

Raid Devices

md0 (dev/md0) 16998 / ext4

Hard Drives

sda (/dev/sda/)

sda1 17000 md0 software RAID
sda2 2535 swap
sda3 56783 /home ext4

sdb (/dev/sdb/)

sdb1 17000 md0 software RAID
sdb2 2535 swap

Click Next button.

17. Boot Loader modification

This is the last place where we can change the device used for boot loader installation. Click on Change Device and choose RAID Device - /dev/md0/.

Click Next. CentOS installation image will be transferred on RAID device and installed from it.

Note:

In case of /dev/sda failure, CentoOS is unable to boot from the /dev/sdb/. It is trying to read /etc/fstab with entry referring to partiton /home. This partition exists only in /dev/sda thus cannot be found. Linux gives a Repair Filesystem prompt in this situation and we can enter that by providing the root password. The problem is that on “Repair Filesystem” prompt filesystem is mounted as “Read-Only” so we cannot remove no more needed /home from /etc/fstab.

For this reason we need to remount file system with Write permission:

Repair filesystem # mount -w -o remount /

Now we can edit edit /etc/fstab and remove or comment line with /home mount. After reboot the system is normally booted.

18. Update the system

We have now our CentOS installed. Login as root an make update of whole system.

- Comment lines with an old original kernel - 2.6.32-71.el6.i686.
- Comment parameter hiddenmenu to see the whole boot menu at the start.
- Reduce timeout parameter from the default 5 second to 2 seconds to let CentOS boot faster.

Problem:

Cannot boot the new kernel 2.6.32071.29.1el6.i686. The old kernel 2.6.32.-71.el6.i686 is always booted.

0 - halt (Do NOT set initdefault to this)
1 - Single user mode
2 - Multiuser, without NFS (The same as 3, if you do not have networking)
3 - Full multiuser mode
4 - unused
5 - X11
6 - reboot (Do NOT set initdefault to this)

respawn - it will ensure that it will accept another login after you log out.

ttyS0, ttyS1 - serial ports identifiers

9600 - serial line rate in bps

vt100 - the terminal emulation. You can use others, but VT100 is the most common or "standard"