Difference between revisions of "Software projects/OS/Slackware/Advanced usage/RAID"

From Pandora Wiki
Jump to: navigation, search
Line 5: Line 5:
 
* http://en.wikipedia.org/wiki/RAID
 
* http://en.wikipedia.org/wiki/RAID
 
* We will use the robust native Linux software RAID.
 
* We will use the robust native Linux software RAID.
* It's a feature that can be used on the Pandora, although not as useful than on a PC or a server, so let's have fun with it
+
* It's a feature that can be used on the Pandora, so let's have fun with it
 
* I will cover here only a RAID 1 (mirror) on two SD cards, as it should be the more interesting for a server usage because under read load, you can reach about 27MB/s against 16MB/s on one card.
 
* I will cover here only a RAID 1 (mirror) on two SD cards, as it should be the more interesting for a server usage because under read load, you can reach about 27MB/s against 16MB/s on one card.
 
* A SD + USB drive can also work although untested. As a two SD + USB drive.
 
* A SD + USB drive can also work although untested. As a two SD + USB drive.
Line 48: Line 48:
  
 
= Create the RAID 1 array =
 
= Create the RAID 1 array =
 +
mdadm --create /dev/md0 --level 1 --raid-devices 2 /dev/mmcblk0p3 /dev/mmcblk1p2
  
= Make the RAID permanent =
+
= Format the RAID array =
 +
mkfs.ext2 /dev/md0
 +
 
 +
= Make the RAID configuration permanent =
 +
mdadm --scan > /etc/mdadm.conf
 +
Edit /etc/fstab and add these lines:
 +
/dev/mmcblk1p1  swap  swap  defaults          0  0
 +
/dev/md0        /srv  auto  defaults,noatime  1  1
 +
 
 +
= Final step =
 +
* As root:
 +
mount/dev/md0
 +
mv /srv-save/* /srv/
 +
rm -rf /srv-save/
 +
* That's it, you have now a RAID 1 array on your Pandora :^).
 +
 
 +
= Some Practice =
 +
* If you want to know how to repair a RAID array, let's simulate a failure.
  
 
= Remove a drive from the array =
 
= Remove a drive from the array =

Revision as of 22:32, 17 April 2012

WIP WIP WIP HURRAID

  • Need to properly rebuild one array while completing.

RAID

  • http://en.wikipedia.org/wiki/RAID
  • We will use the robust native Linux software RAID.
  • It's a feature that can be used on the Pandora, so let's have fun with it
  • I will cover here only a RAID 1 (mirror) on two SD cards, as it should be the more interesting for a server usage because under read load, you can reach about 27MB/s against 16MB/s on one card.
  • A SD + USB drive can also work although untested. As a two SD + USB drive.
  • This array will be mounted as /srv , the standard server folder.

Partitioning

  • So you have to partition your system SD card differently than the default SL4P setup.
  • In this example, we will use the recommended minimal 8G card for the slot 1.
  • You can use a different sized card for the right slot. The minimum size is 4G for this second card, and we will use 4G in this example.
  • The RAID 1 partitions must have the same exact size.

Card 1

  • Partition that way:
6G ext2 for the system
256M for the swap

That's all for now, the third partition will be created under Slackware, and will be:

1.5G RAID
  • We will left 256M free. NEVER fill an entire drive with a RAID array. Drives, ie. all 8G, doesn't necessary offer the same exact capacity, so you can get in trouble if you add a drive 32MB short.

Card 2

256M for the swap

That's all for now, the other partitions will be created under Slackware, and will be:

1.5G unformated RAID
2G unused. Do what you want with it.

Install SL4P

  • Uncompress the rootfs on the first SD card, first partition, put the card in your OP, and boot it.
  • Log in.

Backup /srv

  • As root:
mkdir /srv-save
mv /srv/* /srv-save/

Finalizing card 1 setup

  • As root:
cfdisk

Finalizing card 2 setup

  • As root:
cfdisk

Create the RAID 1 array

mdadm --create /dev/md0 --level 1 --raid-devices 2 /dev/mmcblk0p3 /dev/mmcblk1p2

Format the RAID array

mkfs.ext2 /dev/md0

Make the RAID configuration permanent

mdadm --scan > /etc/mdadm.conf

Edit /etc/fstab and add these lines:

/dev/mmcblk1p1   swap   swap   defaults           0  0
/dev/md0         /srv   auto   defaults,noatime   1  1

Final step

  • As root:
mount/dev/md0
mv /srv-save/* /srv/
rm -rf /srv-save/
  • That's it, you have now a RAID 1 array on your Pandora :^).

Some Practice

  • If you want to know how to repair a RAID array, let's simulate a failure.

Remove a drive from the array

  • It's likely to be the one in the right SD slot.

Repair the array

  • Depending the size of your RAID partition and he data on it, it can take a while.