Setting up a software RAID array: Difference between revisions
(→Creating the partitions: use hdc) |
|||
Line 49: | Line 49: | ||
mknod /dev/md0 b 9 0 | mknod /dev/md0 b 9 0 | ||
Create the | Create the array. | ||
mdadm --create - | mdadm --create --level=1 --raid-devices=2 /dev/md0 /dev/hda1 /dev/hdc1 | ||
== Monitorin sync status == | == Monitorin sync status == |
Revision as of 11:55, 17 October 2007
This document will show how to create hard disk mirroring using cheap IDE disks.
This document was written for alpine-1.3.8 or later. It is tested with alpine-1.7.7.
I will setup 1 raid device for use as physical storage for lvm .
Loading needed modules
Start with loading the ide-disk and raid1 kernel modules. If you use SATA or SCSI disks you will not need the ide-disk module.
modprobe ide-disk modprobe raid1
Add them to /etc/modules so they get loaded during next reboot.
echo ide-disk >> /etc/modules echo raid1 >> /etc/modules
Creating the partitions
I will use /dev/hde and /dev/hdg in this document but you will probably use /dev/hda and /dev/hdc. Note that the disks should not be connected on the same IDE bus (sharing the same IDE cable). To find what disks you have available, look in /proc/partitions or look at the /dev/disk* links that the mdev system has created.
ls -l /dev/disk* lrwxrwxrwx 1 root root 3 Oct 17 13:23 /dev/disk -> hda lrwxrwxrwx 1 root root 3 Oct 17 13:23 /dev/disk0 -> hda lrwxrwxrwx 1 root root 3 Oct 17 13:23 /dev/disk1 -> hdc
Create the partitions using fdisk.
fdisk /dev/hda
I will create one single partition of type Linux raid autodetect. Use n in fdisk to create the partition and t to set type. Logical volumes will be created later. My partition table looks like this ('p' to print partition table):
Device Boot Start End Blocks Id System /dev/hda1 1 17753 8388261 fd Linux raid autodetect
Use w to write and quit. Do the same with your second disk.
fdisk /dev/hdc
Mine looks like this:
Device Boot Start End Blocks Id System /dev/hdc1 1 17753 8388261 fd Linux raid autodetect
Setting up the raid array
Install mdadm to set up the arrays.
apk_add mdadm
If you use an alpine version earlier than 1.7.3 you need to make the /dev nodes before creating the arrays.
mknod /dev/md0 b 9 0
Create the array.
mdadm --create --level=1 --raid-devices=2 /dev/md0 /dev/hda1 /dev/hdc1
Monitorin sync status
You should now be able to see the array syncronize by looking at the contents of /proc/mdstat.
~ $ cat /proc/mdstat Personalities : [raid1] md1 : active raid1 hdg2[1] hde2[0] 38582592 blocks [2/2] [UU] [==>..................] resync = 10.5% (4056192/38582592) finish=68.5min speed=8388K/sec md0 : active raid1 hdg1[1] hde1[0] 499840 blocks [2/2] [UU] unused devices: <none>
You don't need to wait til it is fully syncronized to continue.
Saving config
Create the /etc/mdadm.conf file so mdadm knows how your raid setup is:
mdadm --detail --scan > /etc/mdadm.conf
To make sure the raid devices start during the next reboot run:
rc_add -s 10 -k mdadm-raid
The -s 10 option is to make sure that the raid arrays are started early, before things like lvm and localmount.
Use lbu commit as usual to save configs to usb or floppy.
You should now be able to create swap on /dev/md0 and a filesystem on /dev/md1 using the mkswap and mkfs.* commands.