Configurare /dev/hda e GRUB per RAID1 su Mandriva 2008.0
Preparare /dev/hda
Se tutto è andato bene, dovresti vedere /dev/md0 e /dev/md2 nell’output di:
df -h
[root@server1 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/md2 4.4G 757M 3.4G 18% /
/dev/md0 167M 9.0M 150M 6% /boot
[root@server1 ~]#
L’output di
cat /proc/mdstat
dovrebbe essere simile a questo:
[root@server1 ~]# cat /proc/mdstat
Personalities : [raid1]
md1 : active raid1 hdb5[1]
417536 blocks [2/1] [_U]
md0 : active raid1 hdb1[1]
176576 blocks [2/1] [_U]
md2 : active raid1 hdb6[1]
4642688 blocks [2/1] [_U]
unused devices:
[root@server1 ~]#
Ora dobbiamo cambiare il tipo di partizione delle tre partizioni su /dev/hda in “Linux raid autodetect”:
fdisk /dev/hda
Esempio di sessione interattiva con fdisk (mostrata qui in output):
[root@server1 ~]# fdisk /dev/hda
Command (m for help): <-- t
Partition number (1-6): <-- 1
Hex code (type L to list codes): <-- fd
Changed system type of partition 1 to fd (Linux raid autodetect)
Command (m for help): <-- t
Partition number (1-6): <-- 5
Hex code (type L to list codes): <-- fd
Changed system type of partition 5 to fd (Linux raid autodetect)
Command (m for help): <-- t
Partition number (1-6): <-- 6
Hex code (type L to list codes): <-- fd
Changed system type of partition 6 to fd (Linux raid autodetect)
Command (m for help): <-- w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@server1 ~]#
Adesso aggiungi /dev/hda1, /dev/hda5 e /dev/hda6 ai rispettivi array RAID:
mdadm --add /dev/md0 /dev/hda1
mdadm --add /dev/md1 /dev/hda5
mdadm --add /dev/md2 /dev/hda6
Controlla lo stato di sincronizzazione con:
cat /proc/mdstat
Dovresti osservare che gli array stanno entrando in fase di resync:
[root@server1 ~]# cat /proc/mdstat
Personalities : [raid1]
md1 : active raid1 hda5[2] hdb5[1]
417536 blocks [2/1] [_U]
resync=DELAYED
md0 : active raid1 hda1[0] hdb1[1]
176576 blocks [2/2] [UU]
md2 : active raid1 hda6[2] hdb6[1]
4642688 blocks [2/1] [_U]
[======>..............] recovery = 34.4% (1597504/4642688) finish=1.0min speed=50349K/sec
unused devices:
[root@server1 ~]#
Nota: per monitorare in tempo reale puoi usare:
watch cat /proc/mdstat
Per uscire da watch, premi CTRL+C.
Attendi che la sincronizzazione termini. Alla fine l’output di /proc/mdstat sarà simile a:
[root@server1 ~]# cat /proc/mdstat
Personalities : [raid1]
md1 : active raid1 hda5[0] hdb5[1]
417536 blocks [2/2] [UU]
md0 : active raid1 hda1[0] hdb1[1]
176576 blocks [2/2] [UU]
md2 : active raid1 hda6[0] hdb6[1]
4642688 blocks [2/2] [UU]
unused devices:
[root@server1 ~]#
Poi aggiorna /etc/mdadm.conf alla nuova configurazione:
cp -f /etc/mdadm.conf_orig /etc/mdadm.conf
mdadm --examine --scan >> /etc/mdadm.conf
/etc/mdadm.conf dovrebbe ora assomigliare a questo:
cat /etc/mdadm.conf
| # mdadm configuration file # # mdadm will function properly without the use of a configuration file, # but this file is useful for keeping track of arrays and member disks. # In general, a mdadm.conf file is created, and updated, after arrays # are created. This is the opposite behavior of /etc/raidtab which is # created prior to array construction. # # # the config file takes two types of lines: # # DEVICE lines specify a list of devices of where to look for # potential member disks # # ARRAY lines specify information about how to identify arrays so # so that they can be activated # # You can have more than one device line and use wild cards. The first # example includes SCSI the first partition of SCSI disks /dev/sdb, # /dev/sdc, /dev/sdd, /dev/sdj, /dev/sdk, and /dev/sdl. The second # line looks for array slices on IDE disks. # #DEVICE /dev/sd[bcdjkl]1 #DEVICE /dev/hda1 /dev/hdb1 # # If you mount devfs on /dev, then a suitable way to list all devices is: #DEVICE /dev/discs/*/* # # # # ARRAY lines specify an array to assemble and a method of identification. # Arrays can currently be identified by using a UUID, superblock minor number, # or a listing of devices. # # super-minor is usually the minor number of the metadevice # UUID is the Universally Unique Identifier for the array # Each can be obtained using # # mdadm -D
|
Preparare GRUB
Siamo quasi alla fine. Modifica /boot/grub/menu.lst in modo che il sistema possa avviarsi anche se /dev/hdb fallisce. In pratica copia il primo blocco kernel che usa (hd1,0), incollalo sotto e sostituisci hd1 con hd0. Commenta gli altri blocchi kernel.
vi /boot/grub/menu.lst
Esempio di menu.lst risultante:
| timeout 10 color black/cyan yellow/cyan default 0 fallback 1 title linux kernel (hd1,0)/vmlinuz BOOT_IMAGE=linux root=/dev/md2 resume=/dev/md1 initrd (hd1,0)/initrd.img title linux kernel (hd0,0)/vmlinuz BOOT_IMAGE=linux root=/dev/md2 resume=/dev/md1 initrd (hd0,0)/initrd.img #title linux #kernel (hd0,0)/vmlinuz BOOT_IMAGE=linux root=/dev/hda6 resume=/dev/hda5 #initrd (hd0,0)/initrd.img #title failsafe #kernel (hd0,0)/vmlinuz BOOT_IMAGE=failsafe root=/dev/hda6 failsafe #initrd (hd0,0)/initrd.img
|
Poi aggiorna l’initrd:
mv /boot/initrd-`uname -r`.img /boot/initrd-`uname -r`.img_orig2
mkinitrd /boot/initrd-`uname -r`.img `uname -r`
Quindi riavvia il sistema:
reboot
Dovrebbe avviarsi senza problemi.
Congratulazioni: hai configurato correttamente il RAID1 software su una macchina Mandriva 2008.0 in esecuzione.
Importante: esegui un backup delle configurazioni critiche prima di modificare tabelle di partizione o GRUB.
Controlli rapidi e suggerimenti
- Verifica stato RAID: cat /proc/mdstat
- Verifica array e UUID: mdadm -D /dev/md0
- Ricorda di aggiornare /etc/mdadm.conf dopo ogni modifica ai membri dell’array
- Se la sincronizzazione non parte, controlla dmesg e /var/log/messages per errori di disco o di I/O
Mini-metodologia: procedura in 6 passi
- Controlla lo stato corrente con df -h e cat /proc/mdstat.
- Usa fdisk su /dev/hda per impostare il tipo di partizione su fd (Linux raid autodetect).
- Aggiungi le partizioni all’array con mdadm –add.
- Monitora la sincronizzazione (watch cat /proc/mdstat).
- Rigenera /etc/mdadm.conf con mdadm –examine –scan.
- Aggiorna menu.lst per GRUB, rigenera initrd e riavvia.
Checklist operativa (amministratore)
- Backup completo della macchina o snapshot.
- Verificare integrità SMART dei dischi (smartctl).
- Aggiornare tabella partizioni con fdisk e salvare.
- Aggiungere partizioni con mdadm e verificare resync.
- Aggiornare /etc/mdadm.conf.
- Modificare /boot/grub/menu.lst per bootstrap da entrambi i dischi.
- Rigenerare initrd e riavviare.
Cosa può andare storto (e come risolvere)
- Resync lento: controlla attività I/O (iostat) e limiti di banda. Puoi regolare la velocità di recovery tramite /proc/sys/dev/raid/speed_limit_min.
- Disco respinto dall’array: usa mdadm –remove e mdadm –add per sostituire il membro; verifica i cavi e i log del kernel.
- Problemi di avvio dopo modifiche a GRUB: avvia da LiveCD, monta /boot e ripristina menu.lst o reinstalla GRUB su entrambi i dischi.
Box: dati chiave dell’esempio
- /dev/md2: root, 4.4G
- /dev/md0: /boot, 167M
- Partizioni aggiunte: /dev/hda1, /dev/hda5, /dev/hda6
Glossario in una riga
- mdadm: utility per gestire array RAID software su Linux.
- RAID1: mirroring dei dati su due o più dischi.
- /proc/mdstat: interfaccia kernel per lo stato degli array RAID.
- GRUB: bootloader che avvia il kernel Linux.
- initrd: immagine di ramdisk usata all’avvio per caricare moduli necessari.
Riepilogo: esegui i passaggi nell’ordine, monitora la sincronizzazione e assicurati che GRUB possa avviare da entrambi i dischi prima di rimuovere o sostituire un drive.
Materiali simili

Come ottenere la verifica su Threads

Tradurre video con l'AI: guida pratica

NET::ERR_CERT_AUTHORITY_INVALID su Windows 10
Imparare l'inglese con l'AI: 10 app indispensabili
