Setting Up RAID 0 from the Command Line

In this section, you learn how to set up a RAID 0 from the command line. As its first step, you install the partitions of the Linux RAID type. Then you use the /etc/raidtab configuration file to configure the software RAID.

1. In fdisk, create two partitions of the same size. After creating the partitions, use the t command from within the fdisk interface to set the partition type to Linux RAID. If you want to be able to boot from the software RAID, you need to set both partitions to the type fd. If you are not planning to use the RAID to boot from, you can omit changing the partition type.

2. Now create the /etc/raidtabfile. This file must contain the complete definition of the RAID array. For a RAID 0 array, this would include the RAID level, the number of RAID disks and other parameters, and an indication of the devices that need to be added to the array. Listing 8-1 shows what this should look like in a RAID 0 configuration.

Listing 8-1. Example of/etc/raidtab raiddev /dev/md0 raid-level 0 nr-raid-disks 2 persistent superblock 1 chunk-size 4

device /dev/sdb1 raid-disk 0 device /dev/sdc1 raid-disk 1

3. After specifying the array in the raidtab, you need to create it. You can do this with the command mkraid /dev/md0, which will create the RAID according to the specifications you have made in /etc/raidtab.

4. When the device has been created, you can see its parameters in /proc/mdstat. This file always displays the current status of the array and therefore is an excellent method to monitor if everything goes well. When the RAID device has been added, you can treat it like an ordinary storage device and create a file system on it. Next you can mount it and work on it.

Was this article helpful?

0 0

Post a comment