====== Riepilogo comandi Raid per GNU/Linux ====== Autore: **//Fabio Di Matteo//** \\ Ultima revisione: **//14/03/2018 - 10:35//** \\ \\ ===== Creazione array raid1 ===== Per prima cosa dobbiamo creare le patizioni di tipo **Linux raid autodetect** e grandi quanto l' intero disco (procedura da ripetersi per ogni partizione da unire). In pratica dobbiamo per prima cosa adattare le partizioni ad essere "fuse" dentro un dispositivo raid. fdisk /dev/sda il comando ci fa entrare dentro l'interfaccia di fdisk, ecco di seguito i passi per creare le partizioni: Type n to create a new partition. Type p to select primary partition. Type 1 to create /dev/sda1. Press Enter to choose the default first sector Press Enter to choose the default last sector. This partition will span across the entire drive. Typing p will print information about the newly created partition. By default the partition type is Linux. We need to change the partition type, so type t. Enter fd to set partition type to Linux raid autodetect. Type p again to check the partition type. Type w to apply the above changes. Dopo possiamo unirle in un device raid con il seguente comando: In questo caso un raid di tipo 1, ovvero mirroring. mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1 Una volta creato il device raid prossiamo creare al suo interno le partizioni per la root, swap, boot etc... \\ da ripetere con tutte le partizioni che vogliamo usare in raid . ===== Testare la creazione dell'array ===== cat /proc/mdstat oppure: mdadm --detail /dev/md0 ==== Esaminare le partizioni in raid ==== mdadm -E /dev/sda1 ===== Rimozione di un disco da un array ===== mdadm --set-faulty /dev/md0 /dev/sdb1 mdadm --remove /dev/md0 /dev/sdb1 Ripetere la procedura per ogni partizione contenuta nel disco da rimuovere. ===== Aggiungere un disco ===== Aggiungiamo la partizione sdd1 all'array mdadm --manage /dev/md0 --add /dev/sdd1 ripetiamo la procedura per ogni partizione del nuvo disco. ===== Salvare la configurazione del nostro raid ===== mdadm --detail --scan --verbose >> /etc/mdadm.conf Aggiungera accodera' la configurazione al file /etc/mdadm.conf ===== Fermare il raid ===== mdadm -S /dev/md0 ===== Distruggere l'intero array raid ===== mdadm -S /dev/md0 mdadm /dev/md0 -r /dev/sda mdadm /dev/md0 -r /dev/sdb dd if=/dev/zero of=/dev/sda bs=1M count=1024 dd if=/dev/zero of=/dev/sdb bs=1M count=1024 e eventualmente puo' essere necessario cancellare anche la configurazione di mdadm rm /etc/mdadm/mdadm.conf ===== Testare se gli alert via email funzionano ===== sudo mdadm --monitor --scan --test --oneshot se non funziona assicurrsi che i pacchetti **msmtp** e **msmtp-mta** siano installati. Se così non fosse procedere anche alla configurazione. msmtp --version | grep "System configuration" System configuration file name: /etc/msmtprc un esempio di confirazione: # ------------------------------------------------------------------------------ # msmtp System Wide Configuration file # ------------------------------------------------------------------------------ # A system wide configuration is optional. # If it exists, it usually defines a default account. # This allows msmtp to be used like /usr/sbin/sendmail. # ------------------------------------------------------------------------------ # Accounts # ------------------------------------------------------------------------------ # Sympatico Account account sympatico host smtphm.sympatico.ca from noreply@yourserver.name tls on tls_starttls on tls_trust_file /etc/ssl/certs/ca-certificates.crt auth on user valid_email@bell.net password ******** syslog LOG_MAIL # Rogers Account account rogers host smtp.broadband.rogers.com port 587 from noreply@yourserver.name auth login user valid_email@rogers.com password ******** syslog LOG_MAIL # gmail account # Configuring for gmail is beyond the scope of this tutorial # Googling for "gmail msmtp" should help account gmail host smtp.gmail.com port 587 from noreply@yourserver.name tls on tls_starttls on tls_trust_file /etc/ssl/certs/ca-certificates.crt auth on user password ******** syslog LOG_MAIL # Other ISP Account # Configuring for other ISPs is beyond the scope of this tutorial # Googling for "myisp outlook smtp" should help # ------------------------------------------------------------------------------ # Configurations # ------------------------------------------------------------------------------ # Construct envelope-from addresses of the form "user@oursite.example". #auto_from on #maildomain fermmy.server # Use TLS. #tls on #tls_trust_file /etc/ssl/certs/ca-certificates.crt # Syslog logging with facility LOG_MAIL instead of the default LOG_USER. # Must be done within "account" sub-section above #syslog LOG_MAIL # Set a default account account default : rogers # ------------------------------------------------------------------------------ testare l'ivio di mail: echo "Prava mail..." | msmtp -d youremail@domain.com Ricordarsi inoltre di abilitare il servizio mdadm in systemd.