Last time. instruction We installed the operating system in SoftRAID on one hard drive, and then we'll add another hard drive to the raid array.
Let’s start adding a new hard drive to SoftRAID:
Add the same hard drive to the server, load the server, log in and check if the hard drive system sees after executing the command:
fdisk -l
The answer of the system where we see a new Winchester /dev/sdb without sections:
Disk /dev/sdb: 80 GiB, 85899345920 bytes, 167772160 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/sda: 80 GiB, 85899345920 bytes, 167772160 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x8eb9611b Device Boot Start End Sectors Size Id Type /dev/sda1 * 2048 999423 997376 487M fd Linux raid autodetect /dev/sda2 1001470 167770111 166768642 79,5G 5 Extended /dev/sda5 1001472 4904959 3903488 1,9G 82 Linux swap / Solaris /dev/sda6 4907008 83030015 78123008 37,3G fd Linux raid autodetect /dev/sda7 83032064 89669631 6637568 3,2G fd Linux raid autodetect /dev/sda8 89671680 167770111 78098432 37,2G fd Linux raid autodetect
Checking the status of the raid array is performed by the team:
cat /proc/mdstat
The system response is when only one hard drive is connected in the system, that is, only sdaX is connected in each of the Raid arrays, where the X partition number:
Personalities : [raid1] [linear] [multipath] [raid0] [raid6] [raid5] [raid4] [raid10]
md0 : active raid1 sda1[0]
498368 blocks super 1.2 [2/1] [U_]
md1 : active raid1 sda6[0]
39028736 blocks super 1.2 [2/1] [U_]
md2 : active raid1 sda7[0]
3316736 blocks super 1.2 [2/1] [U_]
md3 : active raid1 sda8[0]
39016448 blocks super 1.2 [2/1] [U_]Preparation of a new hard disk for Raid array
Both disks in the array should have the same partition. Depending on the type of partition table used (MBR or GPT), you need to use appropriate utilities to copy the partition table. Generally, GPT is used in disks larger than 2TB.
Hard drive with MBR
Partition table can be simply copied to a new disk using the program. sfdisk And then I did the command.
sfdisk -d /dev/sda | sfdisk /dev/sdb
wherein /dev/sda It's the source, and /dev/sdb - the destination hard drive.
System response:
Checking that no-one is using this disk right now ... OK Disk /dev/sdb: 80 GiB, 85899345920 bytes, 167772160 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes >>> Script header accepted. >>> Script header accepted. >>> Script header accepted. >>> Script header accepted. >>> Created a new DOS disklabel with disk identifier 0x8eb9611b. /dev/sdb1: Created a new partition 1 of type 'Linux raid autodetect' and of size 487 MiB. /dev/sdb2: Created a new partition 2 of type 'Extended' and of size 79,5 GiB. /dev/sdb3: Created a new partition 5 of type 'Linux swap / Solaris' and of size 1,9 GiB. /dev/sdb6: Created a new partition 6 of type 'Linux raid autodetect' and of size 37,3 GiB. /dev/sdb7: Created a new partition 7 of type 'Linux raid autodetect' and of size 3,2 GiB. /dev/sdb8: Created a new partition 8 of type 'Linux raid autodetect' and of size 37,2 GiB. /dev/sdb9: Done. New situation: Device Boot Start End Sectors Size Id Type /dev/sdb1 * 2048 999423 997376 487M fd Linux raid autodetect /dev/sdb2 1001470 167770111 166768642 79,5G 5 Extended /dev/sdb5 1001472 4904959 3903488 1,9G 82 Linux swap / Solaris /dev/sdb6 4907008 83030015 78123008 37,3G fd Linux raid autodetect /dev/sdb7 83032064 89669631 6637568 3,2G fd Linux raid autodetect /dev/sdb8 89671680 167770111 78098432 37,2G fd Linux raid autodetect The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks.
Check how the system sees a new screw with a copied partition table by executing the command:
fdisk -l
System response:
Disk /dev/sdb: 80 GiB, 85899345920 bytes, 167772160 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x8eb9611b Device Boot Start End Sectors Size Id Type /dev/sdb1 * 2048 999423 997376 487M fd Linux raid autodetect /dev/sdb2 1001470 167770111 166768642 79,5G 5 Extended /dev/sdb5 1001472 4904959 3903488 1,9G 82 Linux swap / Solaris /dev/sdb6 4907008 83030015 78123008 37,3G fd Linux raid autodetect /dev/sdb7 83032064 89669631 6637568 3,2G fd Linux raid autodetect /dev/sdb8 89671680 167770111 78098432 37,2G fd Linux raid autodetect Disk /dev/sda: 80 GiB, 85899345920 bytes, 167772160 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x8eb9611b Device Boot Start End Sectors Size Id Type /dev/sda1 * 2048 999423 997376 487M fd Linux raid autodetect /dev/sda2 1001470 167770111 166768642 79,5G 5 Extended /dev/sda5 1001472 4904959 3903488 1,9G 82 Linux swap / Solaris /dev/sda6 4907008 83030015 78123008 37,3G fd Linux raid autodetect /dev/sda7 83032064 89669631 6637568 3,2G fd Linux raid autodetect /dev/sda8 89671680 167770111 78098432 37,2G fd Linux raid autodetect
If the partitions are not visible in the system, then the partition table should be reread by the kernel of the system after executing the command:
sfdisk -R /dev/sdb
Of course, sections can be created manually using programs. After that, the disk can be added to the array and install a loader on it.
Hard drive with GPT
There are several copies stored on the hard disk. GUID partition tables (GPT)Therefore, to edit it, you should use utilities that support GPT, for example. parted or GPT fdisk. Utility. sgdisk from GPT fdisk It allows you to copy the partition table to a new hard disk in a simple way. Example of copying a partition table from sda to sdb:
sgdisk -R /dev/sdb /dev/sda
Next, the hard drive needs to set a new random UUID:
sgdisk -G /dev/sdb
After that, the disk can be added to the array and install a loader on it.
Adding a new hard drive
In our case, there is only one system disk in the RAID array, so we add a new hard drive to the Raid array. This should be done for each section by following the commands:
mdadm /dev/md0 -a /dev/sdb1 mdadm /dev/md1 -a /dev/sdb6 mdadm /dev/md2 -a /dev/sdb7 mdadm /dev/md3 -a /dev/sdb8
System response:
mdadm /dev/md0 -a /dev/sdb1 mdadm: added /dev/sdb1 mdadm /dev/md1 -a /dev/sdb6 mdadm: added /dev/sdb6 mdadm /dev/md2 -a /dev/sdb7 mdadm: added /dev/sdb7 mdadm /dev/md3 -a /dev/sdb8 mdadm: added /dev/sdb8
Check the status of checking synchronization of added partitions in the Raid array by executing the command:
cat /proc/mdstat
System response:
Personalities : [raid1] [linear] [multipath] [raid0] [raid6] [raid5] [raid4] [raid10]
md0 : active raid1 sdb1[2] sda1[0]
498368 blocks super 1.2 [2/2] [UU]
md1 : active raid1 sdb6[2] sda6[0]
39028736 blocks super 1.2 [2/1] [U_]
[===============>.....] recovery = 75.3% (29421184/39028736) finish=0.7min speed=199752K/sec
md2 : active raid1 sdb7[2] sda7[0]
3316736 blocks super 1.2 [2/1] [U_]
resync=DELAYED
md3 : active raid1 sdb8[2] sda8[0]
39016448 blocks super 1.2 [2/1] [U_]
resync=DELAYED
unused devices: <none>Our new hard drive is added to the Raid array and after synchronization, the status of the arrays is seen as [UU]:
Personalities : [raid1] [linear] [multipath] [raid0] [raid6] [raid5] [raid4] [raid10]
md0 : active raid1 sdb1[2] sda1[0]
498368 blocks super 1.2 [2/2] [UU]
md1 : active raid1 sdb6[2] sda6[0]
39028736 blocks super 1.2 [2/2] [UU]
md2 : active raid1 sdb7[2] sda7[0]
3316736 blocks super 1.2 [2/2] [UU]
md3 : active raid1 sdb8[2] sda8[0]
39016448 blocks super 1.2 [2/2] [UU]
unused devices: <none>
Installation of loader
After installing a new hard drive of the same size, or larger and as at the beginning of this article, you need to prepare the hard drive and add it to the SoftRAID array.
Install the Grub2 bootloader on a new hard drive by executing a command for each hard drive:
grub-install /dev/sda grub-install /dev/sdb
System response:
grub-install /dev/sda Выполняется установка для платформы i386-pc. Установка завершена. Ошибок нет. grub-install /dev/sdb Выполняется установка для платформы i386-pc. Установка завершена. Ошибок нет.
In the case of Grub1 (an outdated version of grub), more steps will be required depending on which disk is dropped.
- Launch the console grub: grub
- Indicate the section on which it is located /boot: root (hd0,1) (/dev/sda2 = (hd0,1))
- Write the bootloader in MBR: setup (hd0)
- In order to record the bootloader on the second hard disk:
- Indicate grub to switch to sdb: device (hd0) /dev/sdb
- Repeat steps 2 and 3 exactly.
- Finish the console grub: quit
Remove the hard drive from the raid array
If you have a hard drive broke, or began to crumble, you need to remove all sections from the array, check the status of the array by following the command:
cat /proc/mdstat
The answer to the system where the hard drive failed:
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
md1 : active raid1 sda6[0]
39028736 blocks super 1.2 [2/1] [U_]
md2 : active raid1 sda7[0]
3316736 blocks super 1.2 [2/1] [U_]
md3 : active raid1 sda8[0]
39016448 blocks super 1.2 [2/1] [U_]
md0 : active raid1 sda1[0]
498368 blocks super 1.2 [2/1] [U_]
unused devices: <none>If you need to disable the hard drive due to the fact that it broke, or began to fail You will see that in one of the sections, or all at the same time will have a dash, we need each section from the raid array to remove by executing the command on the example that we have failed the hard drive. /dev/sdb
Executing commands:
mdadm /dev/md0 -r /dev/sdb1 mdadm /dev/md1 -r /dev/sdb6 mdadm /dev/md2 -r /dev/sdb7 mdadm /dev/md3 -r /dev/sdb8
To see the sections of the hard drive included in the array can be seen by executing a command for each Raid array:
mdadm --detail /dev/md0
In some cases, the hard drive may be partially damaged, such as status. [U_] solid-array /dev/md0, and all other massifs have status [UU]. In that case the team
mdadm /dev/md1 -r /dev/sdb6
It will not pass because the device /dev/md1 I'm fine.
To fix this, you first need to mark the partition as damaged by executing commands:
mdadm --manage /dev/md1 --fail /dev/sdb6 mdadm --manage /dev/md2 --fail /dev/sdb7 mdadm --manage /dev/md3 --fail /dev/sdb8
Then delete the partitions from the array by executing commands with the -r key:
mdadm /dev/md0 -r /dev/sdb1 mdadm /dev/md1 -r /dev/sdb6 mdadm /dev/md2 -r /dev/sdb7 mdadm /dev/md3 -r /dev/sdb8
After removing partitions from the array raid, you can turn off the computer, remove the broken screw and replace it.
Verification of the work of SofttRAID
After setting up the server, it is necessary to test the system boot on each of the hard drives installed in the Raid array, for this you need to turn off the second hard drive physically, turn on the server, make sure that the server is loaded.
Then we turn off the first hard drive and connect the second hard drive, and also make sure that the system boots.
After testing each hard drive separately, you need to connect both hard drives and check that both hard drives are connected to the Raid array without errors by executing the command:
cat /proc/mdstat
P.S.
If you need to find out the serial number of the hard drive, you must execute commands:
/sbin/udevadm info --query=property --name=sdb | grep ID_SERIAL
Team response:
ID_SERIAL=TOSHIBA_DT01ACA300_23CEKJJWS ID_SERIAL_SHORT=23CEKJJWS
I was with you. Sergey Lazarenko.



comment