RAID0/RAID1 step-by-step, 2.0.36 kernel, .50beta10 tools
--------------------------------------------------------
Make sure raid tools, patches, kernel
are compatible.

# rpm -qa | grep raid
raidtools-0.50beta10-2

# grep _MD /usr/src/linux/.config
CONFIG_BLK_DEV_MD=y
CONFIG_MD_LINEAR=y
CONFIG_MD_STRIPED=y
CONFIG_MD_MIRRORING=y
# CONFIG_MD_RAID5 is not set
----------------------------------------
Select similar whole disk or partition pairs
on different controllers, else poor performance.

# fdisk -l /dev/hd{e,g}
Disk /dev/hde: 255 heads, 63 sectors, 790 cylinders
Units = cylinders of 16065 * 512 bytes

   Device Boot    Start      End   Blocks   Id  System
/dev/hde1             1      510  4096543+   c  Win95 FAT32 (LBA)
/dev/hde2           524      657  1076355   83  Linux native
/dev/hde3           511      523   104422+  82  Linux swap
/dev/hde4           658      790  1068322+  83  Linux native

Disk /dev/hdg: 255 heads, 63 sectors, 790 cylinders
Units = cylinders of 16065 * 512 bytes

   Device Boot    Start      End   Blocks   Id  System
/dev/hdg1             1      510  4096543+   c  Win95 FAT32 (LBA)
/dev/hdg2           524      657  1076355   83  Linux native
/dev/hdg3           511      523   104422+  82  Linux swap
/dev/hdg4           658      790  1068322+  83  Linux native

----------------------------------------
Create configuration file first.  4 md devices max.

# cat /etc/raidtab
# sample raiddev configuration file
raiddev /dev/md0

raid-level                1     # pick one
#raid-level               0     #

nr-raid-disks             2
nr-spare-disks            0
chunk-size                32

device                    /dev/hde4
raid-disk                 0
device                    /dev/hdg4
raid-disk                 1

----------------------------------------
Raid must not be running.

# cat /proc/mdstat
Personalities : [1 linear] [2 raid0] [3 raid1]
read_ahead not set
md0 : inactive
md1 : inactive
md2 : inactive
md3 : inactive

----------------------------------------
Create raid1 structure.  'force' option is used
because partition already had a filesystem.
NOTE: no mkraid if RAID0

# mkraid -f /dev/md0
handling MD device /dev/md0
analyzing super-block
disk 0: /dev/hde4, 1068322kB, raid superblock at 1068224kB
disk 1: /dev/hdg4, 1068322kB, raid superblock at 1068224kB
initializing raid set
clearing device /dev/hde4
clearing device /dev/hdg4
(99% done; ~0:01 left 6:30 elapsed [2730.6 KB/sec])
writing raid superblock
MD ID:                   a92b4efc
Conforms to MD version:  0.36.4
gvalid_words:            12
Raid set ID:             4055f2b1
Creation time:           Sat Jun  5 22:35:37 1999
Update time:             Sat Jun  5 22:42:08 1999
State:                   1 (clean)
Raid level:              1
Individual disk size:    1043MB (1068224kB)
Total number of disks:   2
Number of raid disks:    2
Number of active disks:  2
Number of working disks: 2
Number of failed disks:  0
Number of spare disks:   0

Disk 0: raid_disk 0, state: 6 (operational, active, sync)
Disk 1: raid_disk 1, state: 6 (operational, active, sync)

----------------------------------------
Now add new /dev/md0 device to kernel.

# raidadd -a
# cat /proc/mdstat
Personalities : [1 linear] [2 raid0] [3 raid1]
read_ahead not set
md0 : inactive hde4 hdg4 2136644 blocks
md1 : inactive
md2 : inactive
md3 : inactive

----------------------------------------
Now start raid.  'raid1' will be 'raid0' if RAID0.

# raidrun -a
# cat /proc/mdstat
Personalities : [1 linear] [2 raid0] [3 raid1]
read_ahead 8 sectors
md0 : active raid1 hde4 hdg4 1068224 blocks [2/2] [UU]
md1 : inactive
md2 : inactive
md3 : inactive

----------------------------------------
Don't bother with this.

# fdisk -l /dev/md0
Disk doesn't contain a valid partition table

----------------------------------------
Now make a file system.  Can't do this without
valid md device and raid running.

# mke2fs -b 1024 -m 0 /dev/md0
mke2fs 1.12, 9-Jul-98 for EXT2 FS 0.5b, 95/08/09
Linux ext2 filesystem format
Filesystem label=
134144 inodes, 1068224 blocks
0 blocks (0.00%) reserved for the super user
First data block=1
Block size=1024 (log=0)
Fragment size=1024 (log=0)
131 block groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks: 
        8193, 16385, 24577, 32769, 40961, 49153, 57345, 
        ...
        1040385, 1048577, 1056769, 1064961

Writing inode tables: done     
Writing superblocks and filesystem accounting information: done

----------------------------------------
Finally, mount filesystem as any other.

# grep raid /etc/fstab
/dev/md0        /raid           ext2    defaults        1 2

# mount /raid

# df -k /raid
Filesystem         1024-blocks  Used Available Capacity Mounted on
/dev/md0             1050407      13  1050394      0%   /raid

----------------------------------------
General rules

1. Filesystem operations such as mount, umount, mke2fs, fsck
   are valid if raid is active.  % cat /proc/mdstat
   To start (active): raidadd, raidrun.

2. Raid device operations such as /etc/raidtab edits,
   mkraid, ckraid are valid if raid is inactive.  % cat /proc/mdstat
   To stop (inactive): raidstop.

4. Sources, references:
ftp://ftp.kernel.org/pub/linux/daemons/raid     (use country mirror)
http://ostenfeld.dk/~jakob/Software-RAID.HOWTO/Software-RAID.HOWTO.html

/usr/doc/HOWTO/mini/Software-RAID
/usr/doc/raidtools-0.50beta10

man -k raid
ckraid (8)           - checks and fixes RAID device arrays
mkraid (8)           - initializes RAID device arrays
raidadd, raidrun, raidstop, (8) - command set to manage md devices.
raidtab (5)          - configuration file for md (RAID) devices
[tim@asus ~]$ 

--

Reply via email to