📄 software-raid.howto.txt
字号:
The RAID tools and patches are in the daemons/raid/alpha subdirectory. The kernels are found in the kernel subdirectory. Patch the kernel, configure it to include RAID support for the level you want to use. Compile it and install it. Then unpack, configure, compile and install the RAID tools. Ok, so far so good. If you reboot now, you should have a file called /proc/mdstat. Remember it, that file is your friend. See what it contains, by doing a cat /proc/mdstat. It should tell you that you have the right RAID personality (eg. RAID mode) registered, and that no RAID devices are currently active. Create the partitions you want to include in your RAID set. Now, let's go mode-specific. 3.2. Linear mode Ok, so you have two or more partitions which are not necessarily the same size (but of course can be), which you want to append to each other. Set up the /etc/raidtab file to describe your setup. I set up a raidtab for two disks in linear mode, and the file looked like this: raiddev /dev/md0 raid-level linear nr-raid-disks 2 persistent-superblock 1 device /dev/sdb6 raid-disk 0 device /dev/sdc5 raid-disk 1 Spare-disks are not supported here. If a disk dies, the array dies with it. There's no information to put on a spare disk. Ok, let's create the array. Run the command mkraid /dev/md0 This will initialize your array, write the persistent superblocks, and start the array. Have a look in /proc/mdstat. You should see that the array is running. Now, you can create a filesystem, just like you would on any other device, mount it, include it in your fstab and so on. 3.3. RAID-0 You have two or more devices, of approximately the same size, and you want to combine their storage capacity and also combine their performance by accessing them in parallel. Set up the /etc/raidtab file to describe your configuration. An example raidtab looks like: raiddev /dev/md0 raid-level 0 nr-raid-disks 2 persistent-superblock 1 chunk-size 4 device /dev/sdb6 raid-disk 0 device /dev/sdc5 raid-disk 1 Like in Linear mode, spare disks are not supported here either. RAID-0 has no redundancy, so when a disk dies, the array goes with it. Again, you just run mkraid /dev/md0 to initialize the array. This should initialize the superblocks and start the raid device. Have a look in /proc/mdstat to see what's going on. You should see that your device is now running. /dev/md0 is now ready to be formatted, mounted, used and abused. 3.4. RAID-1 You have two devices of approximately same size, and you want the two to be mirrors of each other. Eventually you have more devices, which you want to keep as stand-by spare-disks, that will automatically become a part of the mirror if one of the active devices break. Set up the /etc/raidtab file like this: raiddev /dev/md0 raid-level 1 nr-raid-disks 2 nr-spare-disks 0 chunk-size 4 persistent-superblock 1 device /dev/sdb6 raid-disk 0 device /dev/sdc5 raid-disk 1 If you have spare disks, you can add them to the end of the device specification like device /dev/sdd5 spare-disk 0 Remember to set the nr-spare-disks entry correspondingly. Ok, now we're all set to start initializing the RAID. The mirror must be constructed, eg. the contents (however unimportant now, since the device is still not formatted) of the two devices must be synchronized. Issue the mkraid /dev/md0 command to begin the mirror initialization. Check out the /proc/mdstat file. It should tell you that the /dev/md0 device has been started, that the mirror is being reconstructed, and an ETA of the completion of the reconstruction. Reconstruction is done using idle I/O bandwidth. So, your system should still be fairly responsive, although your disk LEDs should be glowing nicely. The reconstruction process is transparent, so you can actually use the device even though the mirror is currently under reconstruction. Try formatting the device, while the reconstruction is running. It will work. Also you can mount it and use it while reconstruction is running. Of Course, if the wrong disk breaks while the reconstruction is running, you're out of luck. 3.5. RAID-4 Note! I haven't tested this setup myself. The setup below is my best guess, not something I have actually had up running. You have three or more devices of roughly the same size, one device is significantly faster than the other devices, and you want to combine them all into one larger device, still maintaining some redundancy information. Eventually you have a number of devices you wish to use as spare-disks. Set up the /etc/raidtab file like this: raiddev /dev/md0 raid-level 4 nr-raid-disks 4 nr-spare-disks 0 persistent-superblock 1 chunk-size 32 device /dev/sdb1 raid-disk 0 device /dev/sdc1 raid-disk 1 device /dev/sdd1 raid-disk 2 device /dev/sde1 raid-disk 3 If we had any spare disks, they would be inserted in a similar way, following the raid-disk specifications; device /dev/sdf1 spare-disk 0 as usual. Your array can be initialized with the mkraid /dev/md0 command as usual. You should see the section on special options for mke2fs before formatting the device. 3.6. RAID-5 You have three or more devices of roughly the same size, you want to combine them into a larger device, but still to maintain a degree of redundancy for data safety. Eventually you have a number of devices to use as spare-disks, that will not take part in the array before another device fails. If you use N devices where the smallest has size S, the size of the entire array will be (N-1)*S. This ``missing'' space is used for parity (redundancy) information. Thus, if any disk fails, all data stay intact. But if two disks fail, all data is lost. Set up the /etc/raidtab file like this: raiddev /dev/md0 raid-level 5 nr-raid-disks 7 nr-spare-disks 0 persistent-superblock 1 parity-algorithm left-symmetric chunk-size 32 device /dev/sda3 raid-disk 0 device /dev/sdb1 raid-disk 1 device /dev/sdc1 raid-disk 2 device /dev/sdd1 raid-disk 3 device /dev/sde1 raid-disk 4 device /dev/sdf1 raid-disk 5 device /dev/sdg1 raid-disk 6 If we had any spare disks, they would be inserted in a similar way, following the raid-disk specifications; device /dev/sdh1 spare-disk 0 And so on. A chunk size of 32 KB is a good default for many general purpose filesystems of this size. The array on which the above raidtab is used, is a 7 times 6 GB = 36 GB (remember the (n-1)*s = (7-1)*6 = 36) device. It holds an ext2 filesystem with a 4 KB block size. You could go higher with both array chunk-size and filesystem block-size if your filesystem is either much larger, or just holds very large files. Ok, enough talking. You set up the raidtab, so let's see if it works. Run the mkraid /dev/md0 command, and see what happens. Hopefully your disks start working like mad, as they begin the reconstruction of your array. Have a look in /proc/mdstat to see what's going on. If the device was successfully created, the reconstruction process has now begun. Your array is not consistent until this reconstruction phase has completed. However, the array is fully functional (except for the handling of device failures of course), and you can format it and use it even while it is reconstructing. See the section on special options for mke2fs before formatting the array. Ok, now when you have your RAID device running, you can always stop it or re-start it using the raidstop /dev/md0 or raidstart /dev/md0 commands. Instead of putting these into init-files and rebooting a zillion times to make that work, read on, and get autodetection running. 3.7. The Persistent Superblock Back in ``The Good Old Days'' (TM), the raidtools would read your /etc/raidtab file, and then initialize the array. However, this would require that the filesystem on which /etc/raidtab resided was mounted. This is unfortunate if you want to boot on a RAID. Also, the old approach led to complications when mounting filesystems RAID devices. They could not be put in the /etc/fstab file as usual, but would have to be mounted from the init-scripts. The persistent superblocks solve these problems. When an array is initialized with the persistent-superblock option in the /etc/raidtab file, a special superblock is written in the beginning of all disks participating in the array. This allows the kernel to read the configuration of RAID devices directly from the disks involved, instead of reading from some configuration file that may not be available at all times. You should however still maintain a consistent /etc/raidtab file, since you may need this file for later reconstruction of the array. The persistent superblock is mandatory if you want auto-detection of your RAID devices upon system boot. This is described in the Autodetection section. 3.8. Chunk sizes
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -