Raid Helper
Raid Helper
Vorwort: RAID-5 ist nicht sinnvoll in Software abzubilden (XOR sollte im RAID in Hardware gemacht werden). Ich habe dies hier trotzdem gemacht um nicht zusätzliche Hardware (Platten/RAID5 Controller) anschaffen zu müssen.
Partitionierung von einer Platte auf eine andere übertragen
odin:~# sfdisk -d /dev/sda | sfdisk /dev/hda
Platte aus dem RAID entfernen
odin:~# mdadm --manage --remove /dev/md1 /dev/hda2
Platte ins RAID hinzufügen
odin:~# mdadm --manage --add /dev/md1 /dev/hda2
odin:~# cat /proc/mdstat
Personalities : [raid1] [raid6] [raid5] [raid4]
md1 : active raid5 hda2[3] sdb2[1] sda2[2]
214836992 blocks level 5, 64k chunk, algorithm 2 [3/2] [_UU]
[=>...................] recovery = 7.0% (7588176/107418496) finish=30.6min speed=54199K/sec
Platte als HotSpare ins RAID1 hinzufügen
odin:~# mdadm --manage --add /dev/md2 /dev/hda1
odin:~# cat /proc/mdstat
md2 : active raid1 hda1[2](S) sda1[0] sdb1[1]
9767424 blocks [2/2] [UU]
Grub auf BootPlatten neu installieren
odin:~# grub Probing devices to guess BIOS drives. This may take a long time. Done. grub> find /boot/grub/stage1 (hd1,0) (hd2,0) grub> root (hd1,0) Filesystem type is ext2fs, partition type 0xfd grub> setup (hd1) Checking if "/boot/grub/stage1" exists... yes Checking if "/boot/grub/stage2" exists... yes Checking if "/boot/grub/e2fs_stage1_5" exists... yes Running "embed /boot/grub/e2fs_stage1_5 (hd1)"... 17 sectors are embedded. succeeded Running "install /boot/grub/stage1 (hd1) (hd1)1+17 p (hd1,0)/boot/grub/stage2 /boot/grub/menu.lst"... succeeded Done. grub> root (hd2,0) Filesystem type is ext2fs, partition type 0xfd grub> setup (hd2) Checking if "/boot/grub/stage1" exists... yes Checking if "/boot/grub/stage2" exists... yes Checking if "/boot/grub/e2fs_stage1_5" exists... yes Running "embed /boot/grub/e2fs_stage1_5 (hd2)"... 17 sectors are embedded. succeeded Running "install /boot/grub/stage1 (hd2) (hd2)1+17 p (hd2,0)/boot/grub/stage2 /boot/grub/menu.lst"... succeeded Done. grub> quit odin:~#
Was ist "(auto-read-only)" bei cat /proc/mdstat ?
odin:~# cat /proc/mdstat
Personalities : [raid1] [raid6] [raid5] [raid4]
md1 : active (auto-read-only) raid5 hda2[0] sda2[2] sdb2[1]
214836992 blocks level 5, 64k chunk, algorithm 2 [3/3] [UUU]
md2 : active raid1 sda1[0] hda1[2](S) sdb1[1]
9767424 blocks [2/2] [UU]
# auto-read-only verhindert in den ?nächsten? Stunden einen rebuild, beheben kann man dies mit
odin:~# mdadm --readwrite /dev/md1
odin:~# cat /proc/mdstat
Personalities : [raid1] [raid6] [raid5] [raid4]
md1 : active raid5 hda2[0] sda2[2] sdb2[1]
214836992 blocks level 5, 64k chunk, algorithm 2 [3/3] [UUU]
md2 : active raid1 sda1[0] hda1[2](S) sdb1[1]
9767424 blocks [2/2] [UU]
unused devices:
Spare tauschen
odin:~# mdadm /dev/md2 --fail /dev/sdb1
mdadm: set /dev/sdb1 faulty in /dev/md2
odin:~# cat /proc/mdstat
Personalities : [raid1] [raid6] [raid5] [raid4]
md1 : active raid5 hda2[0] sda2[2] sdb2[1]
214836992 blocks level 5, 64k chunk, algorithm 2 [3/3] [UUU]
md2 : active raid1 sda1[0] hda1[2] sdb1[3](F)
9767424 blocks [2/1] [U_]
[>....................] recovery = 1.5% (149632/9767424) finish=6.4min speed=24938K/sec
unused devices:
odin:~# mdadm /dev/md2 --remove /dev/sdb1
mdadm: hot removed /dev/sdb1
odin:~# cat /proc/mdstat
Personalities : [raid1] [raid6] [raid5] [raid4]
md1 : active raid5 hda2[0] sda2[2] sdb2[1]
214836992 blocks level 5, 64k chunk, algorithm 2 [3/3] [UUU]
md2 : active raid1 sda1[0] hda1[2]
9767424 blocks [2/1] [U_]
[==>..................] recovery = 11.2% (1099776/9767424) finish=4.5min speed=31671K/sec
unused devices:
odin:~# mdadm /dev/md2 --add /dev/sdb1
mdadm: re-added /dev/sdb1
odin:~# cat /proc/mdstat
Personalities : [raid1] [raid6] [raid5] [raid4]
md1 : active raid5 hda2[0] sda2[2] sdb2[1]
214836992 blocks level 5, 64k chunk, algorithm 2 [3/3] [UUU]
md2 : active raid1 sdb1[2](S) sda1[0] hda1[3]
9767424 blocks [2/1] [U_]
[==>..................] recovery = 13.7% (1348288/9767424) finish=4.5min speed=31144K/sec
unused devices:
und nun noch einmal grub auf alle "3" Platten installieren
odin:~# grub Probing devices to guess BIOS drives. This may take a long time. grub> find /boot/grub/stage1 (hd0,0) (hd1,0) (hd2,0) grub> root (hd0,0) Filesystem type is ext2fs, partition type 0xfd grub> setup (hd0) Checking if "/boot/grub/stage1" exists... yes Checking if "/boot/grub/stage2" exists... yes Checking if "/boot/grub/e2fs_stage1_5" exists... yes Running "embed /boot/grub/e2fs_stage1_5 (hd0)"... 17 sectors are embedded. succeeded Running "install /boot/grub/stage1 (hd0) (hd0)1+17 p (hd0,0)/boot/grub/stage2 /boot/grub/menu.lst"... succeeded Done. grub> root (hd1,0) Filesystem type is ext2fs, partition type 0xfd grub> setup (hd1) Checking if "/boot/grub/stage1" exists... yes Checking if "/boot/grub/stage2" exists... yes Checking if "/boot/grub/e2fs_stage1_5" exists... yes Running "embed /boot/grub/e2fs_stage1_5 (hd1)"... 17 sectors are embedded. succeeded Running "install /boot/grub/stage1 (hd1) (hd1)1+17 p (hd1,0)/boot/grub/stage2 /boot/grub/menu.lst"... succeeded Done. grub> root (hd2,0) Filesystem type is ext2fs, partition type 0xfd grub> setup (hd2) Checking if "/boot/grub/stage1" exists... yes Checking if "/boot/grub/stage2" exists... yes Checking if "/boot/grub/e2fs_stage1_5" exists... yes Running "embed /boot/grub/e2fs_stage1_5 (hd2)"... 17 sectors are embedded. succeeded Running "install /boot/grub/stage1 (hd2) (hd2)1+17 p (hd2,0)/boot/grub/stage2 /boot/grub/menu.lst"... succeeded Done. grub> quit odin:~#
RAID 1 aus zwei Dateien
dd if=/dev/zero of=/export/ftp_space1/raid1_file0 bs=10240 count=10240 dd if=/dev/zero of=/export/ftp_space2/raid1_file1 bs=10240 count=10240 losetup /dev/loop0 /export/ftp_space1/raid1_file0 losetup /dev/loop1 /export/ftp_space1/raid1_file1 mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/loop0 /dev/loop1 mkfs.ext3 /dev/md0 mount /dev/md0 /export/ftpraid0