User Tools

Site Tools


doc:appunti:linux:sa:raid

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
doc:appunti:linux:sa:raid [2014/02/05 17:34] niccolodoc:appunti:linux:sa:raid [2022/06/21 13:04] – [Rename an MD device permanently] niccolo
Line 5: Line 5:
 ==== Cambiare dimensione a una partizione ext3 ==== ==== Cambiare dimensione a una partizione ext3 ====
  
-<code> +Vedere la pagina **[[resize2fs]]**.
-resize2fs -p /dev/hda7 <newsize> +
-</code> +
- +
-Vedere ''**man resize2fs**'' per come si specifica la size, mi pare che il suffisso ''**s**'' che dovrebbe indicare settori da 512 byte non sia onorato per bene (confusione con i //blocchi// del filesystem?). +
- +
-Forse conviene che la partizione non sia montata? +
  
 ===== Parametri Boot (per GRUB o LILO) relativi al RAID ===== ===== Parametri Boot (per GRUB o LILO) relativi al RAID =====
Line 21: Line 15:
 </code> </code>
  
-===== Gestione volumi RAID =====+===== Gestione RAID con mdadm =====
  
-==== Utilizzo di mdadm ====+=== Creazione di un volume RAID1 ===
  
-Invece dei vecchi raidtools si usa il nuovo ''mdadm''.+Con il comando seguente viene creato e immediatamente attivato un volume **RAID1** in modalità **degradata**, cioè con un solo disco attivo: 
 + 
 +<code> 
 +mdadm --create /dev/md10 --run --level=1 --raid-devices=2 /dev/sdb3 missing 
 +</code>
  
 === Aggiungere una partizione ad un volume RAID === === Aggiungere una partizione ad un volume RAID ===
 +
 +Per aggiungere un componente ad un volume RAID, ad esempio per ripristinare un volume degradato:
  
 <code> <code>
Line 33: Line 33:
 </code> </code>
  
 +=== Avviare un volume in modalità degradata ===
  
 +Se non è possibile montare un volume RAID nella sua completezza (ad esempio perché un componente di un RAID1 è guasto), il volume non viene attivato automaticamente. Per forzare l'operazione è necessario passare il parametro **%%--run%%**.
  
 +**ATTENZIONE**! Senza il parametro ''%%--run%%'' il volume viene assemblato (con un nome di device assegnato automaticamente, in generale non con quello richiesto), ma non viene avviato. Il contenuto del volume non è quindi leggibile e il volume appare vuoto.
  
 +<code>
 +mdadm /dev/md17 --assemble /dev/sdc7 --run
 +</code>
  
 +=== Rimuovere un componente da un volume RAID ===
  
 +Per rimuovere un componente, ad esempio da un volume RAID1, è necessario prima marcarlo come guasto (fail), dopo sarà possibile rimuoverlo dal RAID, che continuerà a lavorare in modalità degradata:
 +
 +<code>
 +mdadm --manage /dev/md0 --fail /dev/sdb2
 +mdadm --manage /dev/md0 --remove /dev/sdb2
 +</code>
  
  
Line 129: Line 142:
 Obviously you need to change this parameter **before** the md kernel subsystem assembles the RAID volumes. Obviously you need to change this parameter **before** the md kernel subsystem assembles the RAID volumes.
  
 +==== Mdadm problem with Debian Jessie and degraded raid1 ====
  
 +**Regression - mdadm in jessie will not boot degraded raid1 array**. See Debian bug [[https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=784823|#784823]]. This is a workaround, as suggested by [[http://serverfault.com/questions/688207/how-to-auto-start-degraded-software-raid1-under-debian-8-0-0-on-boot|this post]]:
  
 +<file>
 +cd /etc/initramfs-tools/scripts/local-top
 +cp /usr/share/initramfs-tools/scripts/local-top/mdadm .
 +patch --verbose --ignore-whitespace <<'EndOfPatch'
 +--- mdadm
 ++++ mdadm
 +@@ -76,7 +76,15 @@
 +   if $MDADM --assemble --scan --run --auto=yes${extra_args:+ $extra_args}; then
 +     verbose && log_success_msg "assembled all arrays."
 +   else
 +-    log_failure_msg "failed to assemble all arrays."
 ++    log_warning_msg "failed to assemble all arrays, attempting individual starts..."
 ++    for dev in $(cat /proc/mdstat | grep '^md' | cut -d ' ' -f 1); do
 ++      log_begin_msg "attempting mdadm --run $dev"
 ++      if $MDADM --run $dev; then
 ++        verbose && log_success_msg "started $dev"
 ++      else
 ++        log_failure_msg "failed to start $dev"
 ++      fi
 ++    done
 +   fi
 +   verbose && log_end_msg
 +
 +EndOfPatch
 +update-initramfs -u
 +</file>
 +
 +Somewhere on the net there is a suggestion to use the ''md-mod.start_dirty_degraded=1'' kernel command line, but this is not the case, because it is used to force starting degraded and dirty RAID5 and RAID6 volumes. Another hint about a ''BOOT_DEGRADED=true'' options in initramfs config seems to be Ubuntu specific.
 +
 +The problem is that the initramfs hook script provided by the mdadm package does:
 +
 +<code>
 +mdadm --assemble --scan --run --auto=yes
 +</code>
 +
 +which actually does not run the array if it is degraded (where the previous start was not).
 +
 +==== Rename an MD device permanently ====
 +
 +To geneate the configuration file **/etc/mdadm/mdadm.conf** you can use the tool **/usr/share/mdadm/mkconf**, which gathers information from the existing RAID volumes. The information are read from the **superblock** of the MD arrays and contains the **name** and **homehost**, so the file created contains lines like this:
 +
 +<file>
 +ARRAY /dev/md/125  metadata=1.2 UUID=d92a8066:fc45b7d3:f916e674:3a695968 name=hostname:125
 +</file>
 +
 +Editing ''mdadm.conf'' to rename a device (e.g. changing from **/dev/md/125** to **/dev/md/5**) will work on the next reboot (remember to update initramfs), but eventually ''mkconf'' will restore the name ''/dev/md/125'' on the next run. To change the name permanently you have to stop the RAID device and update the superblock:
 +
 +<code>
 +mdadm --stop /dev/md/125
 +mdadm --assemble /dev/md/5 --name=5 --homehost=newhostname --update=name /dev/sda5 /dev/sdb5
 +</code>
  
 ===== Filesystem has unsupported feature(s) ===== ===== Filesystem has unsupported feature(s) =====
Line 173: Line 239:
 tune2fs -j /dev/md3 tune2fs -j /dev/md3
 </code> </code>
 +
 +===== Forzare fsck al reboot =====
 +
 +Su un server remoto o privo di monitor/tastiera conviene **impostare il fix automatico di eventuali errori nel filesystem**, senza richiesta di intervento manuale. Questo soprattutto prima di forzare un ''fsck'' al reboot.
 +
 +Fino a **Debian 7 Wheezy** era sufficiente impostare in **''/etc/default/rcS''**:
 +
 +<file>
 +FSCKFIX=yes
 +</file>
 +
 +Da quando si usa il sistema di //init// **systemd** (cioè da **Debian 8 Jessie**) tale file non viene più preso in considerazione, esistono invece le //unit// chiamate **systemd-fsck@.service** e **systemd-fsck-root.service** (vedere **man 8 systemd-fsck**). Tale servizio riconosce alcuni parametri passati al kernel che si possono aggiungere - eventualmente separata da spazi - in **''/etc/default/grub''** (ricordarsi poi di eseguire **update-grub**):
 +
 +<file>
 +GRUB_CMDLINE_LINUX="fsck.repair=yes"
 +</file>
 +
 +Controllare anche in **''/etc/fstab''** che il **sesto campo** sia diverso da zero: 1 per il rootfs, 2 per gli altri.
 +
 +Con tune2fs è possibile verificare ogni quanti reboot viene fatto il check e quando è stato fatto l'ultimo:
 +
 +<code>
 +tune2fs -l /dev/sda3
 +...
 +Mount count:              18
 +Maximum mount count:      38
 +Last checked:             Wed May  9 18:57:29 2012
 +...
 +</code>
 +
 +Un metodo di forzare il check è aumentare artificialmente il Mount count:
 +
 +<code>
 +tune2fs -C 100 /dev/sda3
 +</code>
 +
 +Oppure creare il file
 +
 +<code>
 +touch /forcefsck
 +</code>
 +
 +Un altro sistema è forzare il check sulla richiesta di reboot:
 +
 +<code>
 +shutdown -rF now
 +</code>
 +
 +===== Filesystem Features =====
 +
 +Se ci sono differenze fra il sistema su cui si esegue il **mkfs.ext4** e il sistema su cui si esegue il **grub-install**, si potrebbe incorrere nel seguente errore:
 +
 +<code>
 +grub-install /dev/sda
 +Auto-detection of a filesystem of /dev/sda2 failed
 +</code>
 +
 +Il caso visto sopra è dovuto al fatto che il filesystem è stato creato sull'host avviato con S.O. **64bit**, mentre il grub-install è stato eseguito in un chroot di un sistema a **32bit**.
 +
 +Con **%%tune2fs -l%%** è possibile vedere le //Filesystem features//, quindi è possibile creare il filesystem con le opzioni opportune. Ad esempio il nostro problema è stato risolto eseguendo:
 +
 +<code>
 +mkfs.ext4 -O 'uninit_bg,^64bit,^metadata_csum' /dev/sda2
 +</code>
 +
 +
doc/appunti/linux/sa/raid.txt · Last modified: 2024/04/17 12:44 by niccolo