Portal
Language
 
Home>Knowledge Base>Linux Specific>How to Create a RAID0 Array with ioDrives in Linux
Information
Article ID14
Created On4/14/2009
Modified8/18/2009
Share With Others
How to Create a RAID0 Array with ioDrives in Linux

How to RAID0 (Striping) 2 or more ioDrives in Linux

 

You can use RAID0 to stripe two or more ioDrives for the added performance of parallel read/writes in Linux. To do so:

 

Confirm that the ioDrive driver is loaded and that it recognizes two or more ioDrives

 

  1. Run fio-status:

 

$ fio-status

Fusion-io driver version 1.2.5

 

This should show both the driver version and a description of the two or more ioDrives you want to use for the RAID0 set.

 

  1. Run ls to verify there are at least two fio block devices in /dev:

 

$ ls /dev/fio*

/dev/fioa  /dev/fiob

 

You should see the two or more drives you want for the set.

 

Create the RAID array

These instructions assume that you will be striping the entire ioDrives for the RAID array.  If you want to use a smaller partition for the array, refer to the section later on if you prefer to only stripe a portion of your ioDrive(s).

 

  1. Use the mdadm command to manage linux md devices (such as your RAID array).  The following command will create a raid array across the devices /dev/fioa and /dev/fiob

 

 

You have now created your RAID0 and you can use it immediately by referencing the block device /dev/md0.  Continue to the next section if you wish to have this array persist after a reboot.

Make the array is persistent (exists after a reboot)

Use the following commands to have your RAID0 array will appear after a reboot.

 

$ sudo sh –c 'echo "DEVICE /dev/fioa /dev/fiob" >/etc/mdadm.conf'

$ sudo sh –c 'mdadm --detail --scan >>/etc/mdadm.conf'

 

Note:  On some versions of Unix, the configuration file is in /etc/mdadm/mdadm.conf, not /etc/mdadm.conf.

 

On most systems, the RAID0 array will be created automatically upon reboot. However, if you have problems accessing /dev/md0 after a reboot, run this command:

 

$ sudo mdadm --assemble –-scan

 

Using your RAID0 Array

 

As a raw volume

Now that you have created your RAID array, you can use it as a normal block device.  For example,  you could use dd to add some data to it:

 

$sudo dd if=/dev/zero of=/dev/md0 bs=4k count=1k

1024+0 records in

1024+0 records out

4194304 bytes (4.2 MB) copied, 0.0139264 s, 301MB/s

 

This command copies a series of zeroes to the start of your array—a total of 1k (1024) blocks of 4k bytes each.

With a filesystem

While you may want to use a raw device as a block device (such as for a database store, for example), it is also useful to store files on it.  To use the device with a filesystem, and then use dd to create a file on it, run these commands:

 

$ sudo mkfs.ext3 -b 4096 /dev/md0

mke2fs 1.41.3 (12-Oct-2008)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

39370752 inodes, 157451680 blocks

7872584 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=4294967296

4806 block groups

32768 blocks per group, 32768 fragments per group

8192 inodes per group

Superblock backups stored on blocks:

        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,

        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,

        102400000

 

Writing inode tables: done                            

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information: done

 

This filesystem will be automatically checked every 29 mounts or

180 days, whichever comes first.  Use tune2fs -c or -i to override.

$ sudo mkdir -p /mnt/raid_fs

$ sudo mount /dev/md0 /mnt/raid_fs

$ cd /mnt/raid_fs

$ df -h .

Filesystem            Size  Used Avail Use% Mounted on

/dev/md0              592G  198M  561G   1% /mnt/raid_fs

$ sudo dd if=/dev/zero of=bigfile bs=4k count=1k

1024+0 records in

1024+0 records out

4194304 bytes (4.2 MB) copied, 0.0118473 s, 354 MB/s

$ ls -lh

total 4.1M

-rw-r--r-- 1 root root 4.0M 2009-04-14 16:07 bigfile

drwx------ 2 root root  16K 2009-04-14 16:06 lost+found

$ df -h .

Filesystem            Size  Used Avail Use% Mounted on

/dev/md0              592G  202M  561G   1% /mnt/raid_fs

 

Use a portion of an ioDrive for striping.

 

To use only a single partition (or portion of your ioDrive capacity) for your RAID0 array, use fdisk to create a 20Gb partition on two different ioDrives (for this example: fioa and fiob).

 

$ sudo fdisk /dev/fioa

 

The number of cylinders for this disk is set to 39203.

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): n

Command action

   e   extended

   p   primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-39203, default 1): 1

Last cylinder, +cylinders or +size{K,M,G} (1-39203, default 39203): +20G

 

Command (m for help): t

Selected partition 1

Hex code (type L to list codes): L

 

 0  Empty           1e  Hidden W95 FAT1 80  Old Minix       bf  Solaris       

 1  FAT12           24  NEC DOS         81  Minix / old Lin c1  DRDOS/sec (FAT-

 2  XENIX root      39  Plan 9          82  Linux swap / So c4  DRDOS/sec (FAT-

 3  XENIX usr       3c  PartitionMagic  83  Linux           c6  DRDOS/sec (FAT-

 4  FAT16 <32M      40  Venix 80286     84  OS/2 hidden C:  c7  Syrinx        

 5  Extended        41  PPC PReP Boot   85  Linux extended  da  Non-FS data   

 6  FAT16           42  SFS             86  NTFS volume set db  CP/M / CTOS / .

 7  HPFS/NTFS       4d  QNX4.x          87  NTFS volume set de  Dell Utility  

 8  AIX             4e  QNX4.x 2nd part 88  Linux plaintext df  BootIt        

 9  AIX bootable    4f  QNX4.x 3rd part 8e  Linux LVM       e1  DOS access    

 a  OS/2 Boot Manag 50  OnTrack DM      93  Amoeba          e3  DOS R/O       

 b  W95 FAT32       51  OnTrack DM6 Aux 94  Amoeba BBT      e4  SpeedStor     

 c  W95 FAT32 (LBA) 52  CP/M            9f  BSD/OS          eb  BeOS fs       

 e  W95 FAT16 (LBA) 53  OnTrack DM6 Aux a0  IBM Thinkpad hi ee  GPT           

 f  W95 Ext'd (LBA) 54  OnTrackDM6      a5  FreeBSD         ef  EFI (FAT-12/16/

10  OPUS            55  EZ-Drive        a6  OpenBSD         f0  Linux/PA-RISC b

11  Hidden FAT12    56  Golden Bow      a7  NeXTSTEP        f1  SpeedStor     

12  Compaq diagnost 5c  Priam Edisk     a8  Darwin UFS      f4  SpeedStor     

14  Hidden FAT16 <3 61  SpeedStor       a9  NetBSD          f2  DOS secondary 

16  Hidden FAT16    63  GNU HURD or Sys ab  Darwin boot     fb  VMware VMFS   

17  Hidden HPFS/NTF 64  Novell Netware  b7  BSDI fs         fc  VMware VMKCORE

18  AST SmartSleep  65  Novell Netware  b8  BSDI swap       fd  Linux raid auto

1b  Hidden W95 FAT3 70  DiskSecure Mult bb  Boot Wizard hid fe  LANstep       

1c  Hidden W95 FAT3 75  PC/IX           be  Solaris boot    ff  BBT           

Hex code (type L to list codes): fd

Changed system type of partition 1 to fd (Linux raid autodetect)

 

Command (m for help): w

The partition table has been altered!

 

Calling ioctl() to re-read partition table.

Syncing disks.

 

Repeat these same steps for /dev/fiob.  Now verify that both partitions are the same size:

 

$ sudo fdisk -l /dev/fioa

 

Disk /dev/fioa: 322.4 GB, 322461106176 bytes

255 heads, 63 sectors/track, 39203 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Disk identifier: 0x00000000

 

    Device Boot      Start         End      Blocks   Id  System

/dev/fioa1               1        2612    20980858+  fd  Linux raid autodetect

$ sudo fdisk -l /dev/fiob

 

Disk /dev/fiob: 322.4 GB, 322461106176 bytes

255 heads, 63 sectors/track, 39203 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Disk identifier: 0xe7909ca3

 

    Device Boot      Start         End      Blocks   Id  System

/dev/fiob1               1        2612    20980858+  fd  Linux raid autodetect

 

Next, create the RAID array, as described before, only this time use the partition names, instead of the raw device names:

 

$ sudo mdadm --create /dev/md0 --level=0 --raid-devices=2  /dev/fioa1 /dev/fiob1

mdadm: array /dev/md0 started.

 

Follow the same instructions given earlier for creating a file system and mounting the array that refer to /dev/md0 for the partitioned array.