Setting up a software RAID array: Difference between revisions

From Alpine Linux
(mark as obsolete add to category storage)
(tested on alpine-2.0.2. Should it still be marked obsolete?)
Line 3: Line 3:
This document will show how to create hard disk mirroring using cheap IDE disks.
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. It is tested with alpine 1.8.1.1.
This document was written for alpine-1.3.8 or later. It is tested with alpine-1.7.7. It is tested with alpine 1.8.1.1. It is tested with alpine-2.0.2


I will setup 1 raid device for use as physical storage for [[Setting up Logical Volumes with LVM | lvm]] .
I will setup 1 raid device for use as physical storage for [[Setting up Logical Volumes with LVM | lvm]] .
Line 47: Line 47:


  apk_add mdadm
  apk_add mdadm
In alpine 1.8.1.1 you have to run "mdev -s" to update your /dev entries.


If you use an alpine version earlier than 1.7.3 you need to make the /dev nodes before creating the arrays.
If you use an alpine version earlier than 1.7.3 you need to make the /dev nodes before creating the arrays.
Line 52: Line 54:
  mknod /dev/md0 b 9 0
  mknod /dev/md0 b 9 0


In alpine 1.8.1.1 you have to run "mdev -s" to update your /dev entries.


Create the array.
Create the array.

Revision as of 14:41, 19 October 2010

This material is obsolete ...

Please feel free to help us make an up-to-date version. (Discuss)

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. It is tested with alpine 1.8.1.1. It is tested with alpine-2.0.2

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

In alpine 1.8.1.1 you have to run "mdev -s" to update your /dev entries.

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

Monitoring 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] 
md0 : active raid1 hdc1[1] hda1[0]
      8388160 blocks [2/2] [UU]
      [=========>...........]  resync = 45.3% (3800064/8388160) finish=0.3min  speed=200003K/sec

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-update add mdadm-raid

Or, on Alpine 1.8 or earlier:

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.

The raid device /dev/md0 is now ready to be used with lvm or mkfs.