View this PageEdit this PageUploads to this PageVersions of this PageHomeRecent ChangesSearchHelp Guide

Sustituir un disco RAID roto (cuando el otro todavia funciona)

Caso de hdc roto


Suponiendo que se haya roto el secundario y que se esté usando grub (en caso de usar lilo, basta con ejecutar el lilo una vez que se han sincronizado los discos).

  1. Apagar el PC
  2. Sustituir el disco roto por uno nuevo
  3. Volver a encencer el PC
  4. Copiar la configuración de particiones existente (/dev/hda) al disco duro nuevo (/dev/hdc)
    # sfdisk -d /dev/hda > /tmp/partitions.hda
    # sfdisk /dev/hdc < /tmp/partitions.hda
  5. Comprobar las particiones en raid existentes:
    # cat /proc/mdstat
  6. Dar de alta las nuevas particiones. Suponiendo que estén en raid la 1, 5 y 6:
    # mdadm --add /dev/md1 /dev/hdc1
    # mdadd --add /dev/md5 /dev/hdc5
    # mdadm --add /dev/md6 /dev/hdc6
  7. Esperar a que haya terminado de sincronizar los discos
    # watch cat /proc/mdstat
  8. [SI USA GRUB] Reinstalar el grub en ambos discos (se podría hacer sólo en el segundo, pero por si acaso... ;ver notas sobre instalación de GRUB con RAID)
    # grub --no-floppy
    grub> find /grub/stage1
    grub> root (hd0,0)
    grub> setup (hd0)
    grub> device (hd0) /dev/sdb
    grub> root (hd0,0)
    grub> setup (hd0)
    grub> quit
  9. [SI USA LILO] Reinstalar el lilo en el segundo disco
    # lilo
Y esto es todo.

Caso de hda roto


En caso de fallar el primer disco, habría que intercambiar hda y hdc, y hd1 por hd0. (Sin probar)

Caso de que se "ha perdido el array"


Es interesante este post, por el que indica que basta con cambiar en el /etc/init.d/mdadm-raid la línea que dice "$MDADM --assemble --scan --auto=yes" por:
mdadm --assemble --scan --homehost=`cat /etc/hostname` --auto=yes --auto-update-homehost

Para comprobar que efectivamente una partición formaba parte del array:
# mdadm --examine --scan /dev/sda7

Si lo era, entonces se puede montar de forma aislada

# mdadm --assemble /dev/md3 /dev/sda7
# mdadm --run /dev/md3

Y por último añadir la otra parte del RAID (si ya has hecho las particiones del segundo disco porque este estaba vacío).

# mdadm --add /dev/md3 /dev/sdb7

Si quieres deshacer un array

# mdadm --stop /dev/md3

Si es que las particiones las has generado "de otra manera" (p.ej. con un fdisk y luego copiado el S.O. con un tar), hay que corregir el fichero /etc/mdadm/mdadm.conf:
# cd /etc/mdadm
# mdadm --examine --scan --verbose | grep ARRAY > lista
# ( grep "DEVICE\|CREATE\|MAILADDR" mdadm.conf | /usr/bin/head -2 ; cat lista ; grep "DEVICE\|CREATE\|MAILADDR" mdadm.conf | /usr/bin/tail -2 ; cat lista ) > mdadm.conf2
# mv mdadm.conf mdadm.conf.old
# mv mdadm.conf2 mdadm.conf
# rm lista


Ejemplo de menu.lst para el GRUB con RAID


Obtenido de http://www.doorbot.com/guides/linux/x86/grubraid/ y de http://linuxplanet.com/linuxplanet/tutorials/5361/5/
/mnt/boot/grub/menu.lst
default 0
fallback 1
timeout 3
color cyan/blue white/blue
title Debian GNU/Linux, kernel 2.6.16-2-686
        root (hd0,0)
        kernel /vmlinuz-2.6.16-2-686 root=/dev/md2 md=2,/dev/sda6,/dev/sdb6 ro
        initrd /initrd.img-2.6.16-2-686
        savedefault
        boot
title Debian GNU/Linux, kernel 2.6.16-2-686 - mirrored disk
        root (hd1,0)
        kernel /vmlinuz-2.6.16-2-686 root=/dev/md2 md=2,/dev/sdb6 ro
        initrd /initrd.img-2.6.16-2-686
        savedefault
        boot
title Debian GNU/Linux, kernel 2.6.16-2-686 (single-user mode)
        root (hd0,0)
        kernel /vmlinuz-2.6.16-2-686 root=/dev/md2 ro single
        initrd /initrd.img-2.6.16-2-686
        savedefault
        boot


Hay otro ejemplo de GRUB y de cómo instalarlo en:
http://lopezivan.blogspot.com/2008/03/raid-1-en-un-sistema-ya-instalado.html

menu.lst
# Línea original
#title Debian GNU/Linux, kernel 2.6.18-4-686
#root (hd0,0)
#kernel /vmlinuz-2.6.18-4-686 root=/dev/sda6 ro
#initrd /initrd.img-2.6.18-4-686
#savedefault

# Nuevas líneas
title Debian GNU/Linux, kernel 2.6.18-4-686 (HD1)
root (hd1,0)
kernel /vmlinuz-2.6.18-4-686 root=/dev/md2 ro
initrd /initrd.img-2.6.18-4-686
savedefault

title Debian GNU/Linux, kernel 2.6.18-4-686 (HD0)
root (hd0,0)
kernel /vmlinuz-2.6.18-4-686 root=/dev/md2 ro
initrd /initrd.img-2.6.18-4-686
savedefault


Grub
shian:~# grub

grub> root (hd0,0)
Filesystem type is ext2fs, partition type 0x83

grub> setup (hd0)
Checking if "/boot/grub/stage1" exists... no
Checking if "/grub/stage1" exists... yes
Checking if "/grub/stage2" exists... yes
Checking if "/grub/e2fs_stage1_5" exists... yes
Running "embed /grub/e2fs_stage1_5 (hd0)"... 15 sectors are embedded.
succeeded
Running "install /grub/stage1 (hd0) (hd0)1+15 p (hd0,0)/grub/stage2 /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... no
Checking if "/grub/stage1" exists... yes
Checking if "/grub/stage2" exists... yes
Checking if "/grub/e2fs_stage1_5" exists... yes
Running "embed /grub/e2fs_stage1_5 (hd1)"... 15 sectors are embedded.
succeeded
Running "install /grub/stage1 (hd1) (hd1)1+15 p (hd1,0)/grub/stage2 /grub/menu.lst"... succeeded
Done.


initramfs
shian:~# update-initramfs -u
update-initramfs: Generating /boot/initrd.img-2.6.18-4-686

NOTA: Si el update-initramfs dice que "has been altered" (significa que ha sido generado con una utilidad diferente del update-initramfs) y el update-initramfs no se atreve a tocarlo, como dicen en este thread, hay que pasar el parámetro adicional "-t" para que lo sobreescriba igualmente:
shian:~# update-initramfs -u
/boot/initrd.img-2.6.18-4-686 has been altered. Cannot update.
shian:~# update-initramfs -t -u
update-initramfs: Generating /boot/initrd.img-2.6.18-4-686


Link to this Page