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

   Device Boot    Start       End    Blocks   Id  System
/dev/hda1   *         1       960   7711168+  83  Linux
/dev/hda2           961      1027    538177+   5  Extended
/dev/hda5           961      1027    538146   82  Linux swap

Disk /dev/hdb: 255 heads, 63 sectors, 1027 cylinders
Units = cylinders of 16065 * 512 bytes
 
n - new partition
l - logical

t - toggle
partition number: 5
Hex code: 82 (linux swap
 
 

mkswap /dev/hdb2

Mirroring an existing linux drive without erasing that drive.

existing partition = /dev/hda1
blank hard drive = /dev/hdb

Mirror /dev/hda1 to /dev/hdb1

fdisk /dev/hdb
Disk /dev/hdb: 255 heads, 63 sectors, 1027 cylinders
Units = cylinders of 16065 * 512 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/hdb1             1       960   7711168+  83  Linux
/dev/hdb2           961      1027    538177+   5  Extended
/dev/hdb5           961      1027    538146   82  Linux swap

1. Create the raidtab file for the new mirror set
2. Create a mirror set that only has the "new" hard drive.
3. Extend the mirror to the "old" hard drive.   This will syncronize the old hard drive information to the new hard drive.
 

vi /etc/raidtab
raiddev /dev/md0
        raid-level      1
        nr-raid-disks   2
        nr-spare-disks  0
        chunk-size     4
        persistent-superblock 1
        device          /dev/hda1
        raid-disk       0
        device          /dev/hdb1
        raid-disk       1
 
 

Change raid-disk for /dev/hda1 to failed-disk
 

mkraid /dev/md0

Change failed-disk for /dev/hda1 to raid-disk

vi /etc/raidtab
cat /proc/mdstat
raidhotadd --all /dev/md0 /dev/hda

[root@mail /root]# cat /proc/mdstat
Personalities : [raid1]
read_ahead 1024 sectors
md0 : active raid1 hda[2] hdb1[1] 7711104 blocks [2/1] [_U] recovery=0% finish=5
3.3min
unused devices: <none>
[root@mail /root]# cat /proc/mdstat
Personalities : [raid1]
read_ahead 1024 sectors
md0 : active raid1 hda[2] hdb1[1] 7711104 blocks [2/1] [_U] recovery=0% finish=5
3.4min
unused devices: <none>
[root@mail /root]# cat /proc/mdstat
Personalities : [raid1]
read_ahead 1024 sectors
md0 : active raid1 hda[2] hdb1[1] 7711104 blocks [2/1] [_U] recovery=0% finish=5
2.2min
unused devices: <none>
[root@mail /root]# cat /proc/mdstat
Personalities : [raid1]
read_ahead 1024 sectors
md0 : active raid1 hda[0] hdb1[1] 7711104 blocks [2/2] [UU]