Implementing RAID function with software under Linux (2)


3. Automatically execute RAID0 settings

Add RAID0 load and file system add-on to the Init.sysinit file, so that as soon as the system starts, RAID is executed first, so users do not have to Installed by hand.

Users should add the following two commands to the Init.sysinit file.

/sbin/mdrun -ar

mount /dev/md0 /opt

Of course, if you don't feel trouble, you can manually run the above command to start it manually. Soft RAID disk.

Second, the more recent version of Linux

If you have a newer version of Linux, which already comes with the Raidtools tool, then you don't have to download the software and compile it yourself. You can do this when you use it:

1. Create a file /etc/raidtab (for example, make RAID0), the contents of the file are as follows:

raiddev /dev/md0

Raid-level 0

nr-raid-disks 2

persistent-superblock 1

chunk-size 4

device /dev/hdb1

raid-disk 0

device /dev/hdd1

raid-disk 1

2. Run the following command:

#mkraid /dev /md0

This will generate a new device:


To enable the soft RAID method:

#raidstart /dev/md0

The rest of the operations are the same as above.

If the version of the Linux system you are using is new, maybe neither of the above is suitable for you, then you can use the third method to use soft RAID.

Third, the latest version of Linux

I installed Red Hat Linux 6.1 on a PC, when I compiled Raidtools0.42, 0.50beta2, I could not find the required header file. After copying the required header files, the compilation will still not pass. It turns out that because the new version uses a new set of functions, the situation is slightly different. However, in the new version, Raidtools is provided. In the /sbin directory, there are a series of tools for Raidtools, including a set of tools such as Mkraid, Raid0run, Raidstop, and Raidstart. If you want to compile yourself, you can find the latest version of Raidtools from the Chinese free software library, compile the 0.9 version of Raidtools, and compile normally.

The new version of Raidtools is slightly different. I use the Raidtools that comes with the system. The method of making soft RAID is as follows:

1. Create the file /etc/raidtab, the contents of the file are as follows:

raiddev /dev/md0

raid-level 0

nr-raid-disks 2

persistent-superblock 0

chunk-size 8

device /dev/hdb1

raid-disk 0

device /dev/hdd1

raid-disk 1

2. To generate a soft RAID device, run the following command:

# mkraid -c /etc/raidtab /dev/md0

After running the following command to view the current RAID running status:

[root@rh61 /proc]# cat mdstat

If the system displays the following:

Personalities : [raid0]

read—ahead 1024 Sectors

md0 : active raid0 hdd1[1] hdb1[0] 2202416 blocks 8k chunks

unused devices:

means your RAID0 is up and running.

3. Create a new file system

Now, in order to use the newly generated device, we should create an Ext2 file system on the new RAID disk. The command to create a new file system is as follows:

[root@rh61 /sbin]# mkfs.ext2 /dev/md0

After about two or three minutes, the new file system is generated correctly. You can start using it now. The usage is as follows:

[root@rh61 /sbin]# mount -t ext2 /dev/md0 /opt

Mount the /dev/md0 device to the /opt installation point on.

After that, I installed Sybase on this soft RAID disk. After testing, I found that the performance of the entire RAID0 system is not bad.

Copyright © Windows knowledge All Rights Reserved