LAN2WAN

.: LAN2WAN :.

Aucun commentaire

Installation des paquets

Pour mettre à jour le BIOS des serveurs DELL, nous allons avoir besoin des paquets suivants :

  • libsmbios-bin
  • libsmbios2

Pour les installer, rien de plus simple :

apt-get update
apt-get install libsmbios-bin libsmbios2

Une fois cette installation réalisée, nous pouvons vérifier que nous avons bien les deux binaires qui nous intéressent :

  • /usr/sbin/dellBiosUpdate
  • /usr/sbin/getSystemId

Le premier nous permettra de mettre le BIOS à jour, tandis que le second nous donnera les informations nécessaires à la recherche de la bonne version du BIOS.

Récupération des informations

Attaquons-nous donc à la recherche des informations.
Nous allons donc utiliser la commande '/usr/sbin/getSystemId' qui va nous retourner sur notre serveur :

Libsmbios:    2.0.3
System ID:    0x014A
Service Tag:  DPWxxxx
Express Service Code: 2986399xxxx
Product Name: PowerEdge 1750
BIOS Version: A11
Vendor:       Dell Computer Corporation
Is Dell:      1

Nous pouvons vérifier avec le ServiceTag si une mise à jour du BIOS est disponible ou pas, en se rendant directement sur le site du support DELL.
Nous gagnons du temps en allant directement sur la page des BIOS DELL. Une fois sur celle-ci, nous allons chercher ce qui correspond à notre matériel, soit :

  • system_bios_ven_0x1028_dev_0x014a

Nous constatons qu'un répertoire 'system_bios_ven_0x1028_dev_0x014a_version_a12' est présent, ce qui veut dire que le BIOS 'A12' est présent. Le format d'archivage DELL étant le suivant : 'system_bios_ven_0x1028_dev_SYSTEM_ID_version_BIOS_VERSION'.

Nous allons donc télécharger le fichier 'bios.hdr' présent dans ce répertoire :

cd /usr/local/src/
wget http://linux.dell.com/repo/firmware/bios-hdrs/system_bios_ven_0x1028_dev_0x014a_version_a12/bios.hdr

Upgrade du BIOS

Avant de lancer la mise à jour, nous lancer le module DELL de Debian :

modprobe dell_rbu

Nous pouvons ensuite vérifier sa présence avec la commande :

lsmod | grep dell

Qui devrait nous retourner :

dell_rbu                6028  0
firmware_class          6816  1 dell_rbu

(Les chiffres 6028 & 6816 correspondent à la taille des modules, donc ils peuvent changer).
Maintenant que tout est vérifié, nous pouvons donc lancer notre mise à jour avec la commande :

dellBiosUpdate -u -f bios.hdr

Si il retourne une erreur indiquant qu'il ne trouve pas le binaire 'dellBiosUpdate', il suffira de lancer la commande complète :

/usr/sbin/dellBiosUpdate -u -f bios.hdr

Nous devrions avoir un retour de ce type :

Supported RBU type for this system: (MONOLITHIC, PACKET)
Using RBU v2 driver. Initializing Driver.
Setting RBU type in v2 driver to: MONOLITHIC (FORCED)
Prep driver for data load.
Writing RBU data (4096bytes/dot): ..................................................................................................................................................
Notify driver data is finished.
Activate CMOS bit to notify BIOS that update is ready on next boot.
Update staged sucessfully. BIOS update will occur on next reboot.

Le plus important étant la présence de la dernière ligne, soit 'Update staged sucessfully. BIOS update will occur on next reboot.'.
Nous redémarrons donc l'équipement, et pouvons constater lors du démarrage que le BIOS se met bien à jour.
Une fois que l'équipement est de nouveau joignable, nous pouvons également vérifier avec la commande '/usr/sbin/getSystemId' qui nous retournera ce coup-ci :

Libsmbios:    2.0.3
System ID:    0x014A
Service Tag:  DPWxxxx
Express Service Code: 2986399xxxx
Product Name: PowerEdge 1750
BIOS Version: A12
Vendor:       Dell Computer Corporation
Is Dell:      1

Le BIOS 'A12' est donc bien présent sur l'équipement.

Aucun commentaire

Le but de cette opération et donc d'étendre le stockage actuel en RAID1 de 2x 2To, soit 2To de stockage pour passer à un RAID5 avec 4x 2To, soit environ 6To.
Afin de gagner du temps, nous n'allons pas transférer les données présentes sur le RAID1 vers un disque externe en USB, mais faire un RAID1 et un RAID5 dégradés afin de transférer les données.
L'ajout des nouveaux HDD dans la bête s'est passé sans encombre. Nous pouvons donc maintenant vérifier la présence de ces nouveaux HDD via “fdisk -l” :

Disk /dev/sde: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000

Disk /dev/sde doesn't contain a valid partition table

Disk /dev/sdf: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000

Disk /dev/sdf doesn't contain a valid partition table



Nous voyons bien “/dev/sde” & “/dev/sdf” qui ne disposent d'aucune partition.


Création de la partition

Nous allons donc commencer par créer une partition complète sur l'un de nos nouveaux HDD. Il va nous servir d'étalonnage pour le reste.
thallium:~# fdisk /dev/sde
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x200a1ce9.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

The device presents a logical sector size that is smaller than
the physical sector size. Aligning to a physical sector (or optimal
I/O) size boundary is recommended, or performance may be impacted.

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-243201, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-243201, default 243201):
Using default value 243201

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): fd
Changed system type of partition 1 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.



Nous pouvons vérifier l'état de nos deux HDD :
thallium:~# fdisk -l

Disk /dev/sde: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x200a1ce9

   Device Boot      Start         End      Blocks   Id  System
/dev/sde1               1      243201  1953512001   fd  Linux raid autodetect
Partition 1 does not start on physical sector boundary.

Disk /dev/sdf: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000

Disk /dev/sdf doesn't contain a valid partition table



Copie de la partition

Afin de gagner du temps, et surtout d'avoir des tailles de partitions identiques, nous allons dupliquer celle de notre premier disque (/dev/sde) sur le second (/dev/sdf) :
thallium:~# sfdisk -d /dev/sde | sfdisk /dev/sdf
Checking that no-one is using this disk right now ...
OK

Disk /dev/sdf: 243201 cylinders, 255 heads, 63 sectors/track

sfdisk: ERROR: sector 0 does not have an msdos signature
 /dev/sdf: unrecognized partition table type
Old situation:
No partitions found
New situation:
Units = sectors of 512 bytes, counting from 0

   Device Boot    Start       End   #sectors  Id  System
/dev/sdf1            63 3907024064 3907024002  fd  Linux raid autodetect
/dev/sdf2             0         -          0   0  Empty
/dev/sdf3             0         -          0   0  Empty
/dev/sdf4             0         -          0   0  Empty
Warning: no primary partition is marked bootable (active)
This does not matter for LILO, but the DOS MBR will not boot this disk.
Successfully wrote the new partition table

Re-reading the partition table ...

If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)
to zero the first 512 bytes:  dd if=/dev/zero of=/dev/foo7 bs=512 count=1
(See fdisk(8).)



Nous pouvons vérifier le bon accomplissement de cette modification :
thallium:~# fdisk -l

Disk /dev/sde: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x200a1ce9

   Device Boot      Start         End      Blocks   Id  System
/dev/sde1               1      243201  1953512001   fd  Linux raid autodetect
Partition 1 does not start on physical sector boundary.

Disk /dev/sdf: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdf1               1      243201  1953512001   fd  Linux raid autodetect
Partition 1 does not start on physical sector boundary.



Les deux disques disposent d'un partitionnement identique.


Identification du RAID1

Nous allons maintenant devoir trouver les HDD qui composent notre RAID1 de 2To :
thallium:~# fdisk -l | grep md |grep 2000
Disk /dev/md0 doesn't contain a valid partition table
Disk /dev/md1 doesn't contain a valid partition table
Disk /dev/md2 doesn't contain a valid partition table
Disk /dev/md4 doesn't contain a valid partition table
Disk /dev/md4: 2000.4 GB, 2000396222464 bytes



Nous avons identifié le “/dev/md4”, maintenant, trouvons les disques qui le composent via “cat /proc/mdstat” :
md4 : active raid1 sdb1[0] sdd1[1]
      1953511936 blocks [2/2] [UU]



Nous savons que ce sont les disques “/dev/sdb” & “/dev/sdd”.


Extraction à chaud d'un HDD du RAID1

Pour se faire, nous allons déjà le passer dans le status FAIL, puis ensuite le REMOVE de sa grappe :
mdadm --manage /dev/md4 --fail /dev/sdd1
mdadm --manage /dev/md4 --remove /dev/sdd1



Nous pouvons vérifier qu'il ne fait plus partie de notre grappe RAID via “cat /proc/mdstat” :
md4 : active raid1 sdb1[0]
      1953511936 blocks [2/1] [U_]




Copie de la partition (bis)

Nous allons comme précédemment faire exactement le même partitionnement :
thallium:~# sfdisk -d /dev/sde | sfdisk /dev/sdd
Checking that no-one is using this disk right now ...
OK

Disk /dev/sdd: 243201 cylinders, 255 heads, 63 sectors/track
Old situation:
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start     End   #cyls    #blocks   Id  System
/dev/sdd1          0+ 243200  243201- 1953512001   fd  Linux raid autodetect
/dev/sdd2          0       -       0          0    0  Empty
/dev/sdd3          0       -       0          0    0  Empty
/dev/sdd4          0       -       0          0    0  Empty
New situation:
Units = sectors of 512 bytes, counting from 0

   Device Boot    Start       End   #sectors  Id  System
/dev/sdd1            63 3907024064 3907024002  fd  Linux raid autodetect
/dev/sdd2             0         -          0   0  Empty
/dev/sdd3             0         -          0   0  Empty
/dev/sdd4             0         -          0   0  Empty
Warning: no primary partition is marked bootable (active)
This does not matter for LILO, but the DOS MBR will not boot this disk.
Successfully wrote the new partition table

Re-reading the partition table ...

If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)
to zero the first 512 bytes:  dd if=/dev/zero of=/dev/foo7 bs=512 count=1



Nous vérifions que cela est bien pris en compte via “fdisk -l” :
Disk /dev/sdd: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0xa5552bcd

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1      243201  1953512001   fd  Linux raid autodetect
Partition 1 does not start on physical sector boundary.

Disk /dev/sde: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x200a1ce9

   Device Boot      Start         End      Blocks   Id  System
/dev/sde1               1      243201  1953512001   fd  Linux raid autodetect
Partition 1 does not start on physical sector boundary.

Disk /dev/sdf: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdf1               1      243201  1953512001   fd  Linux raid autodetect
Partition 1 does not start on physical sector boundary.



Nos 3 HDD sont identiques.


Vérification des MD

Comme nous avons pu le constater une grappe RAID est un MD. Il faut donc en avoir de disponible, et si cela n'est pas le cas, en créer un.
Vérifions ce que nous avons en stock :
thallium:~# ll /dev/ |grep md
drwxr-xr-x  2 root root          40 10 janv. 21:31 md
brw-rw----  1 root disk      9,   0 10 janv. 21:32 md0
brw-rw----  1 root disk      9,   1 10 janv. 21:32 md1
brw-rw----  1 root disk      9,   2 10 janv. 21:32 md2
brw-rw----  1 root disk      9,   4 10 janv. 21:32 md4
drwxr-xr-x  2 root root          60 10 janv. 21:31 .mdadm
lrwxrwxrwx  1 root root           3 10 janv. 21:32 root -> md0



Les 4 présents sont déjà utilisés. Nous allons donc devoir en créer un nouveau :
thallium:~# mknod -m 640 /dev/md3 b 9 3



Vérification que celui-ci est bien présent :
thallium:~# ll /dev/ |grep md
drwxr-xr-x  2 root root          40 10 janv. 21:31 md
brw-rw----  1 root disk      9,   0 10 janv. 21:32 md0
brw-rw----  1 root disk      9,   1 10 janv. 21:32 md1
brw-rw----  1 root disk      9,   2 10 janv. 21:32 md2
brw-r-----  1 root root      9,   3 11 janv. 10:39 md3
brw-rw----  1 root disk      9,   4 10 janv. 21:32 md4
drwxr-xr-x  2 root root          60 10 janv. 21:31 .mdadm
lrwxrwxrwx  1 root root           3 10 janv. 21:32 root -> md0




Création du RAID5

Nous allons donc nous lancer dans la création de notre nouveau RAID5 avec 4HDD au final. Par contre, comme indiqué au début, nous allons partir sur du dégradé, afin de faire nos transferts de fichiers entre l'ancien et le nouveau RAID.
Pour ce faire, nous allons donc créer notre RAID5 en précisant qu'un disque est absent :
thallium:~# mdadm --create --verbose /dev/md3 --level=5 --assume-clean --raid-devices=4 missing /dev/sdd1 /dev/sde1 /dev/sdf1
mdadm: layout defaults to left-symmetric
mdadm: chunk size defaults to 512K
mdadm: layout defaults to left-symmetric
mdadm: layout defaults to left-symmetric
mdadm: /dev/sdd1 appears to contain a reiserfs file system
    size = 1953511936K
mdadm: /dev/sdd1 appears to be part of a raid array:
    level=raid1 devices=2 ctime=Sat Oct  8 17:41:53 2011
mdadm: layout defaults to left-symmetric
mdadm: layout defaults to left-symmetric
mdadm: size set to 1953510400K
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md3 started.



Nous pouvons vérifier que notre nouveau RAID5 est présent, et fonctionnel :
thallium:~# cat /proc/mdstat
Personalities : [raid1] [raid6] [raid5] [raid4]
md3 : active (auto-read-only) raid5 sdf1[3] sde1[2] sdd1[1]
      5860531200 blocks super 1.2 level 5, 512k chunk, algorithm 2 [4/3] [_UUU]

md4 : active raid1 sdb1[0]
      1953511936 blocks [2/1] [U_]

md2 : active raid1 sda3[2] sdc3[1]
      943560550 blocks super 1.2 [2/2] [UU]

md1 : active (auto-read-only) raid1 sdc2[0] sda2[1]
      3903680 blocks [2/2] [UU]

md0 : active raid1 sdc1[0] sda1[1]
      29294400 blocks [2/2] [UU]

unused devices: <none>



Au passage, nous pouvons noter que les “md3” & “md4” sont tous les deux en dégradés.


Formatage du volume RAID5

Afin d'avoir un maximum d'espace disque, et un système de fichier qui tient la route, nous allons formater le volume en ReiserFS :
thallium:~# mkfs.reiserfs /dev/md3
mkfs.reiserfs 3.6.21 (2009 www.namesys.com)

A pair of credits:
Nikita Danilov  wrote  most of the core  balancing code, plugin infrastructure,
and directory code. He steadily worked long hours, and is the reason so much of
the Reiser4 plugin infrastructure is well abstracted in its details.  The carry
function, and the use of non-recursive balancing, are his idea.

Joshua Macdonald wrote the first draft of the transaction manager. Yuri Rupasov
did testing  and benchmarking,  plus he invented the r5 hash  (also used by the
dcache  code).  Yura  Rupasov,  Anatoly Pinchuk,  Igor Krasheninnikov,  Grigory
Zaigralin,  Mikhail  Gilula,   Igor  Zagorovsky,  Roman  Pozlevich,  Konstantin
Shvachko, and Joshua MacDonald are former contributors to the project.


Guessing about desired format.. Kernel 2.6.32-5-686-bigmem is running.
Format 3.6 with standard journal
Count of blocks on the device: 1465132800
Number of blocks consumed by mkreiserfs formatting process: 52924
Blocksize: 4096
Hash function used to sort names: "r5"
Journal Size 8193 blocks (first block 18)
Journal Max transaction length 1024
inode generation number: 0
UUID: 72b2d86f-e51c-4fb9-aff9-73e054253d81
ATTENTION: YOU SHOULD REBOOT AFTER FDISK!
        ALL DATA WILL BE LOST ON '/dev/md3'!
Continue (y/n):y
Initializing journal - 0%....20%....40%....60%....80%....100%
Syncing..ok
ReiserFS is successfully created on /dev/md3.




Mise à jour config RAID

Nous devons informer MDADM qu'il doit prendre en compte ce nouveau RAID.
Nous allons commencer par effectuer une copie de sauvegarde du fichier de configuration :
thallium:~# cp -p /etc/mdadm/mdadm.conf /root/mdadm.conf.20130111-1054



Puis relancer un scan avec injection du résultat dans la configuration :
thallium:~# mdadm --misc --detail --brief /dev/md* 2> /dev/null | tee -a /etc/mdadm/mdadm.conf
ARRAY /dev/md0 metadata=0.90 UUID=9d4abe9b:45b62929:7a1a79cd:68e069cf
ARRAY /dev/md1 metadata=0.90 UUID=ed9b1fc4:37d4b75e:7a1a79cd:68e069cf
ARRAY /dev/md2 metadata=1.2 name=thallium:2 UUID=1239bbfa:736a2971:611b4e5a:e9148b29
ARRAY /dev/md3 metadata=1.2 name=thallium:3 UUID=819a977f:37b45a5c:4a67cbb4:8598414f
ARRAY /dev/md4 metadata=0.90 UUID=8019adce:a5db0e7a:7167efe2:badc658a



Nous vérifions que la mise à jour du fichier s'est bien passée, en comparant avec l'ancien fichier :
thallium:~# diff -Nru /root/mdadm.conf.20130111-1054 /etc/mdadm/mdadm.conf
--- /root/mdadm.conf.20130111-1054      2012-01-28 14:59:30.000000000 +0100
+++ /etc/mdadm/mdadm.conf       2013-01-11 10:59:50.000000000 +0100
@@ -33,4 +33,5 @@
 ARRAY /dev/md0 metadata=0.90 UUID=9d4abe9b:45b62929:7a1a79cd:68e069cf
 ARRAY /dev/md1 metadata=0.90 UUID=ed9b1fc4:37d4b75e:7a1a79cd:68e069cf
 ARRAY /dev/md2 metadata=1.2 name=thallium:2 UUID=1239bbfa:736a2971:611b4e5a:e9148b29
+ARRAY /dev/md3 metadata=1.2 name=thallium:3 UUID=819a977f:37b45a5c:4a67cbb4:8598414f
 ARRAY /dev/md4 metadata=0.90 UUID=8019adce:a5db0e7a:7167efe2:badc658a




Création et mise en ligne du point de montage

Il nous faut dans un premier temps créer un point de montage pour effectuer le transfert.
Disposant d'une imagination débordante, nous allons le nommer “md3” :
thallium:~# mkdir /mnt/md3



Nous pouvons dès à présent effectuer le montage :
thallium:~# mount /dev/md3 /mnt/md3



Nous vérifions que le montage s'est bien effectué :
thallium:~# mount
/dev/md0 on / type ext3 (rw,errors=remount-ro)
tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
udev on /dev type tmpfs (rw,mode=0755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620)
/dev/md2 on /mnt/commun type reiserfs (rw)
/dev/md4 on /mnt/nas type reiserfs (rw)
/dev/md3 on /mnt/md3 type reiserfs (rw)



Vérifions de combien d'espace disque nous allons bénéficier suite à cet ajout de disques :
thallium:~# df -h | grep md3
/dev/md3              5,5T   33M  5,5T   1% /mnt/md3




Transfert des données

Maintenant que tout est en place, nous pouvons lancer le transfert des données présentes sur notre RAID1 dégradé (/dev/md4) qui est sur le montage “/mnt/nas”, et transférer tout ça sur notre RAID5 dégradé (/dev/md3) qui lui est sur le montage “/mnt/md3” :
thallium:~# cd /mnt/nas
thallium:~# cp -dpRx . /mnt/md3/



Le transfert va prendre un certain temps, voir même un temps certain … Il faut donc être patient.
Nous pouvons pour plus de sécurité, vérifier que toutes les données sont bien présentes. Pour se faire, nous allons simplement lister les fichiers des deux montages dans un fichier texte, puis les comparer :
thallium:~# cd /mnt/md3
thallium:/mnt/md3# ll -R >> fichiers.hdd
thallium:/mnt/md3# cd /mnt/nas
thallium:/mnt/nas# ll -R >> fichiers.hdd
thallium:/mnt/nas# diff -Nru fichiers.hdd /mnt/md3/fichiers.hdd



N'ayant pas de différence, nous pouvons donc passer à la suite du programme.


Destruction RAID1

Etant donné que tout est transféré, nous pouvons maintenant supprimer notre ancien RAID1. Avant de faire cela, il faut démonter le point de montage :
thallium:~# umount /mnt/nas



Nous allons déjà le passer dans le status FAIL, puis ensuite le REMOVE de sa grappe :
mdadm --manage /dev/md4 --fail /dev/sdb1



Ensuite, nous allons arrêter la grappe en question :
mdadm --manage --stop /dev/md4



Pour finir, nous allons supprimer toutes les informations qui pourraient subsister sur le dernier disque :
mdadm --zero-superblock /dev/sdb1




Copie de la partition (ter)

Nous allons comme précédemment faire exactement le même partitionnement, avec le dernier HDD qui va rejoindre le RAID5 (pour rappel “/dev/sdb”) :
thallium:~# sfdisk -d /dev/sde | sfdisk /dev/sdb
Checking that no-one is using this disk right now ...
OK

Disk /dev/sdb: 243201 cylinders, 255 heads, 63 sectors/track
Old situation:
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start     End   #cyls    #blocks   Id  System
/dev/sdb1          0+ 243200  243201- 1953512001   fd  Linux raid autodetect
/dev/sdb2          0       -       0          0    0  Empty
/dev/sdb3          0       -       0          0    0  Empty
/dev/sdb4          0       -       0          0    0  Empty
New situation:
Units = sectors of 512 bytes, counting from 0

   Device Boot    Start       End   #sectors  Id  System
/dev/sdb1            63 3907024064 3907024002  fd  Linux raid autodetect
/dev/sdb2             0         -          0   0  Empty
/dev/sdb3             0         -          0   0  Empty
/dev/sdb4             0         -          0   0  Empty
Warning: no primary partition is marked bootable (active)
This does not matter for LILO, but the DOS MBR will not boot this disk.
Successfully wrote the new partition table

Re-reading the partition table ...

If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)
to zero the first 512 bytes:  dd if=/dev/zero of=/dev/foo7 bs=512 count=1
(See fdisk(8).)



Nous vérifions que cela est bien pris en compte via “fdisk -l” :
Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1      243201  1953512001   fd  Linux raid autodetect
Partition 1 does not start on physical sector boundary.

Disk /dev/sdd: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0xa5552bcd

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1      243201  1953512001   fd  Linux raid autodetect
Partition 1 does not start on physical sector boundary.

Disk /dev/sde: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x200a1ce9

   Device Boot      Start         End      Blocks   Id  System
/dev/sde1               1      243201  1953512001   fd  Linux raid autodetect
Partition 1 does not start on physical sector boundary.

Disk /dev/sdf: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdf1               1      243201  1953512001   fd  Linux raid autodetect
Partition 1 does not start on physical sector boundary.



Nos 4 HDD sont identiques.


Intégration du HDD dans le RAID5

Nous allons ajouter notre dernier HDD dans la grappe du RAID5, ce qui va avoir pour conséquence reconstruire le RAID et donc de durer très longtemps.
Effectivement, maintenant que le RAID5 va disposer de tous ses disques, il va donc devoir répartir les données et les bits de parités sur l’ensemble des disques de la grappe.
thallium:~# mdadm --manage /dev/md3 --add /dev/sdb1
mdadm: added /dev/sdb1



Nous pouvons vérifier la reconstruction de celui-ci :
thallium:~# cat /proc/mdstat
Personalities : [raid1] [raid6] [raid5] [raid4]
md3 : active raid5 sdb1[4] sdf1[3] sde1[2] sdd1[1]
      5860531200 blocks super 1.2 level 5, 512k chunk, algorithm 2 [4/3] [_UUU]
      [>....................]  recovery =  0.0% (289536/1953510400) finish=337.2min speed=96512K/sec

md2 : active raid1 sda3[2] sdc3[1]
      943560550 blocks super 1.2 [2/2] [UU]

md1 : active (auto-read-only) raid1 sdc2[0] sda2[1]
      3903680 blocks [2/2] [UU]

md0 : active raid1 sdc1[0] sda1[1]
      29294400 blocks [2/2] [UU]

unused devices: <none>




Modifications finales

Maintenant que tout est presque terminé, nous pouvons finaliser les configurations.
Nous devons indiquer le nouveau point de montage dans le fichier “/etc/fstab” afin que celui-ci se monte lors du démarrage.
Nous allons donc avoir un fichier final qui va ressembler à ça :
# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    defaults        0       0
/dev/md0        /               ext3    errors=remount-ro 0       1
/dev/md1        none            swap    sw              0       0
/dev/md2        /mnt/commun     reiserfs        defaults        0       0
/dev/md3        /mnt/nas     reiserfs        defaults        0       0
#/dev/md4        /mnt/nas        reiserfs        defaults        0       0
/dev/scd0       /media/cdrom0   udf,iso9660 user,noauto     0       0
/dev/fd0        /media/floppy0  auto    rw,user,noauto  0       0



Il nous faut également modifier la configuration de MDADM afin de lui indiquer de ne plus chercher de MD4. Notre fichier de configuration “/etc/mdadm/mdadm.conf” sera donc comme celui-ci :
ARRAY /dev/md0 metadata=0.90 UUID=9d4abe9b:45b62929:7a1a79cd:68e069cf
ARRAY /dev/md1 metadata=0.90 UUID=ed9b1fc4:37d4b75e:7a1a79cd:68e069cf
ARRAY /dev/md2 metadata=1.2 name=thallium:2 UUID=1239bbfa:736a2971:611b4e5a:e9148b29
ARRAY /dev/md3 metadata=1.2 name=thallium:3 UUID=819a977f:37b45a5c:4a67cbb4:8598414f
#ARRAY /dev/md4 metadata=0.90 UUID=8019adce:a5db0e7a:7167efe2:badc658a

Aucun commentaire

Copier les partitions

sfdisk -d /dev/sda | sfdisk /dev/sdb

fdisk -l
Disk /dev/sda: 73.2 GB, 73200476160 bytes
255 heads, 63 sectors/track, 8899 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               2          25      192780   fd  Linux
/dev/sda2              26         279     2040255   fd  Linux swap / Solaris
/dev/sda3   *         280        8899    69240150   fd  Linux
Disk /dev/sdb: 73.2 GB, 73200476160 bytes
255 heads, 63 sectors/track, 8899 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               2          25      192780   fd  Linux
/dev/sdb2              26         279     2040255   fd  Linux swap / Solaris
/dev/sdb3   *         280        8899    69240150   fd  Linux

Modifier le type des partitions

fdisk /dev/sdb
Command (m for help): t
Partition number (1-4): 1
Hex code (type L to list codes): fd
Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): fd
Command (m for help): t
Partition number (1-4): 3
Hex code (type L to list codes): fd
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.

On doit obtenir :

fdisk -l /dev/sdb
Disk /dev/sdb: 73.2 GB, 73200476160 bytes
255 heads, 63 sectors/track, 8899 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               2          25      192780   fd  Linux raid autodetect
/dev/sdb2              26         279     2040255   fd  Linux raid autodetect
/dev/sdb3   *         280        8899    69240150   fd  Linux raid autodetect

Création des volumes RAID1

On crée les RAID1 sans /dev/sda :

mdadm --create /dev/md0 --level=1 --raid-disks=2 missing /dev/sdb1
mdadm --create /dev/md1 --level=1 --raid-disks=2 missing /dev/sdb2
mdadm --create /dev/md2 --level=1 --raid-disks=2 missing /dev/sdb3

Si les /dev/md* n'existe pas :

mknod -m 640 /dev/md0 b 9 0
mknod -m 640 /dev/md1 b 9 1
mknod -m 640 /dev/md2 b 9 2

La commande 'cat /proc/mdstat' doit nous donner 3 RAID dégradé :

cat /proc/mdstat
Personalities : [raid1] [linear] [multipath] [raid0] [raid6] [raid5] [raid4] [raid10]
md2 : active raid1 sdb3[1]
      4594496 blocks [2/1] [_U]
md1 : active raid1 sdb2[1]
      497920 blocks [2/1] [_U]
md0 : active raid1 sdb1[1]
      144448 blocks [2/1] [_U]
unused devices: <none>


Formater les volumes RAID

mke2fs -j /dev/md0
mkswap /dev/md1
mke2fs -j /dev/md2

Modification des fichiers système

/etc/mdadm.conf

cp /usr/share/doc/mdadm-2.5.4/mdadm.conf-example /etc/mdadm.conf
mdadm --examine --scan >> /etc/mdadm.conf

Il doit maintenant y avoir à la fin du fichier les infos concernant les volumes RAID :

ARRAY /dev/md0 level=raid1 num-devices=2 UUID=72d23d35:35d103e3:01b5209e:be9ff10a
ARRAY /dev/md1 level=raid1 num-devices=2 UUID=a50c4299:9e19f9e4:01b5209e:be9ff10a
ARRAY /dev/md2 level=raid1 num-devices=2 UUID=99fee3a5:ae381162:01b5209e:be9ff10a

/etc/fstab & /etc/mtab
On replace les /dev/sda* par les /dev/md* correspondant :

/dev/md2                /                       ext3    defaults        1 1
/dev/md0                /boot                   ext3    defaults        1 2
/dev/md1                swap                    swap    defaults        0 0
none                    /dev/pts                devpts  gid=5,mode=620  0 0
none                    /proc                   proc    defaults        0 0
none                    /dev/shm                tmpfs   defaults        0 0

/dev/md2 / ext3 rw 0 0
none /proc proc rw 0 0
none /dev/pts devpts rw,gid=5,mode=620 0 0
/dev/md0 /boot ext3 rw 0 0
none /dev/shm tmpfs rw 0 0
none /proc/sys/fs/binfmt_misc binfmt_misc rw 0 0

/boot/grub/grub.conf

default=0
fallback=1
timeout=5
hiddenmenu
title CentOS (Default)
        root (hd1,0)
        kernel /vmlinuz ro root=/dev/md2
        initrd /initrd-raid1
title CentOS (Default)
        root (hd0,0)
        kernel /vmlinuz ro root=/dev/sda3

La ligne 'initrd /initrd-raid1' est nécessaire si /dev/md2 n'est pas trouvé au démarrage. Si besoin du initrd, il faut le générer :

uname -a
Linux mamachine.lan2wan.fr 2.6.18-prep #1 SMP Tue Mar 4 15:02:47 CET 2008 x86_64 x86_64 x86_64 GNU/Linux
cd /boot
mkinitrd --with=raid1 initrd-raid1 2.6.18-prep

Copie du système

mkdir /mnt/md0
mkdir /mnt/md2
mount /dev/md0 /mnt/md0
mount /dev/md2 /mnt/md2
cp -dpRx / /mnt/md2/
cd /boot
cp -dpRx . /mnt/md0/

Mise à jour du chargeur de démarrage (GRUB)

grub
  root (hd0,0)
  setup (hd0)
  root (hd1,0)
  setup (hd1)
  quit

Ensuite on reboot.

Modification des partitions de /dev/sda

fdisk /dev/sda
Command (m for help): t
Partition number (1-4): 1
Hex code (type L to list codes): fd
Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): fd
Command (m for help): t
Partition number (1-4): 3
Hex code (type L to list codes): fd
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.

fdisk -l /dev/sda
[...]
/dev/sda1               2          25      192780   fd  Linux raid autodetect
/dev/sda2              26         279     2040255   fd  Linux raid autodetect
/dev/sda3   *         280        8899    69240150   fd  Linux raid autodetect

Ajout des disques dans les RAIDs

mdadm --add /dev/md0 /dev/sda1
mdadm --add /dev/md1 /dev/sda2
mdadm --add /dev/md2 /dev/sda3

Si une erreur se produit (ex: /dev/sda3 ressource busy)
Modifier /boot/grub/grub.conf, remplacer hd1 par hd0

title CentOS (Default)
        root (hd0,0)
        kernel /vmlinuz ro root=/dev/md2
        initrd /initrd-raid1

Rebooter.
'fuser -mv /dev/sda3' ne doit plus rien renvoyer.
Ensuite relancer 'mdadm –add /dev/md2 /dev/sda3'
Les raids vont se reconstruire :

cat /proc/mdstat
Personalities : [raid1]
md2 : active raid1 sda3[2] sdb3[1]
      4594496 blocks [2/1] [_U]
      [=====>...............]  recovery = 29.7% (1367040/4594496) finish=0.6min speed=85440K/sec

md1 : active raid1 sda2[0] sdb2[1]
      497920 blocks [2/2] [UU]

md0 : active raid1 sda1[0] sdb1[1]
      144448 blocks [2/2] [UU]

unused devices: <none>

Dernière modification GRUB

Modifier le '/boot/grub/grub.conf'
Permettra de démarrer si le premier disque est cassé :

default=0
fallback=1
timeout=5
hiddenmenu
title CentOS (Default)
        root (hd0,0)
        kernel /vmlinuz ro root=/dev/md2
        initrd /initrd-raid1
title CentOS (Default)
        root (hd1,0)
        kernel /vmlinuz ro root=/dev/md2
        initrd /initrd-raid1

Normalement pas besoin, mais juste pour être sûr que grub est bien installé sur les 2 disques :

grub
  root (hd0,0)
  setup (hd0)
  root (hd1,0)
  setup (hd1)
  quit

Si lors de cette étape, une erreur du type 'Checking if “/boot/grub/stage1” exists… no' se produit, il faut réinstaller grub dans la partition '/boot' d'un des disques en RAID :

grub-install /dev/hdX

Ou 'hdX' est votre disque (à remplacer par hda voir sda)