I recently installed CentOS remotely on a machine in the UK.  Now, I want to configure the drives to run raid 0 for /www.

1. create the partitions (and possibly reboot)
2. mdadm -C /dev/md0 --level=raid0 --raid-devices=2 /dev/hda3 /dev/hdc1
3. mkfs.ext3 /dev/md0
4. create /etc/mdadm.conf
echo 'DEVICES /dev/hda3 /dev/hdc1' > /etc/mdadm.conf
mdadm --detail --scan >> /etc/mdadm.conf
4. create mount point: mkdir /www
5. Add line to /etc/fstab: /dev/md0                /www                       ext3    defaults        1 1
6. mount /www

I have two drives /dev/hda and /dev/hdc.  /dev/hda has a swap and ext3 partition (the os) on it already.

[root@uk1 conf.d]# <strong>ls -la /dev/hd*</strong>
brw-r----- 1 root disk  3, 0 Mar  7 11:21 /dev/hda
brw-r----- 1 root disk  3, 1 Mar  7 11:21 /dev/hda1
brw-r----- 1 root disk  3, 2 Mar  7 11:21 /dev/hda2
brw-r----- 1 root disk 22, 0 Mar  7 11:21 /dev/hdc

Create some partitions with fdisk:

[root@uk1 /]# <strong>fdisk /dev/hda</strong>

Command (m for help): <strong>p</strong>

Disk /dev/hda: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1        6374    51199123+  83  Linux
/dev/hda2            6375        7011     5116702+  82  Linux swap / Solaris

Command (m for help): <strong>n</strong>
Command action
e   extended
p   primary partition (1-4)
<strong>p</strong>
Partition number (1-4): <strong>3</strong>
First cylinder (7012-30401, default 7012):<em>Hit Enter</em>
Using default value 7012
Last cylinder or +size or +sizeM or +sizeK (7012-30401, default 30401): <strong>+200G</strong>
Value out of range.
Last cylinder or +size or +sizeM or +sizeK (7012-30401, default 30401): <strong>+180G</strong>

Command (m for help): <strong>w</strong>
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
[root@uk1 /]# <strong>fdisk /dev/hdc</strong>

The number of cylinders for this disk is set to 30401.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): <strong>p</strong>

Disk /dev/hdc: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System

Command (m for help): <strong>n</strong>
Command action
e   extended
p   primary partition (1-4)
<strong>p</strong>
Partition number (1-4): <strong>1</strong>
First cylinder (1-30401, default 1):<em>Hit Enter</em>
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-30401, default 30401): <strong>+180G</strong>

Command (m for help): <strong>w</strong>
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@uk1 /]# <strong>ls /dev/hd*</strong>
/dev/hda  /dev/hda1  /dev/hda2  /dev/hdc  /dev/hdc1

So we notice that /dev/hda3 is not showing. So we can’t create the raid array till it’s available. So we reboot.

[root@uk1 cameron]# ls /dev/hd*
/dev/hda  /dev/hda1  /dev/hda2  /dev/hda3  /dev/hdc  /dev/hdc1

And so we continue…

mdadm -C /dev/md0 --level=raid0 --raid-devices=2 /dev/hda3 /dev/hdc1

Which outputs:

mdadm: /dev/hdc1 appears to contain an ext2fs file system
    size=80192K  mtime=Sat Mar  6 13:45:53 2010
Continue creating array? y
mdadm: array /dev/md0 started.
[root@uk1 ~]#

now add the following line to /etc/fstab:

 /dev/md0                /www                       ext3    defaults        1 1

then:

mkdir /www
mount /www

done.

Leave a Reply