Home > Linux > Growing a Raid 5. It has never been easier.

Growing a Raid 5. It has never been easier.

Add a new disk and prepare it with 3 partitions 6GB of size as well as the file system type as “fd”. It has to be like this: you can create whatever size you desire, it doesn’t matter. On one condition: It must have  the same size to others partitions else of your array.

[root@carlosqueiroz ~]# sfdisk -l /dev/hdd

Disk /dev/hdd: 41610 cylinders, 16 heads, 63 sectors/track
Units = cylinders of 516096 bytes, blocks of 1024 bytes, counting from 0

Device Boot Start     End   #cyls    #blocks   Id  System
/dev/hdd1          0+  11905   11906-   6000592+  fd  Linux raid autodetect
/dev/hdd2      11906   23811   11906    6000624   fd  Linux raid autodetect
/dev/hdd3      23812   35717   11906    6000624   fd  Linux raid autodetect
/dev/hdd4          0       –       0          0    0  Empty
[root@carlosqueiroz ~]#

Add the partitions bound in the array previously created.

[root@carlosqueiroz ~]# mdadm /dev/md0 -a /dev/hdd1
mdadm: added /dev/hdd1
[root@carlosqueiroz ~]# mdadm /dev/md0 -a /dev/hdd2
mdadm: added /dev/hdd2
[root@carlosqueiroz ~]# mdadm /dev/md0 -a /dev/hdd3
mdadm: added /dev/hdd3
[root@carlosqueiroz ~]#

Take a look on it. We have an array level 5 defined as 3 devices. All of those devices else are put as spare. It’s time to make our array growing up.

[root@carlosqueiroz ~]# mdadm –detail /dev/md0
/dev/md0:
Version : 0.90
Creation Time : Sun Feb  7 20:54:04 2010
Raid Level : raid5
Array Size : 12001024 (11.45 GiB 12.29 GB)
Used Dev Size : 6000512 (5.72 GiB 6.14 GB)
Raid Devices : 3
Total Devices : 6
Preferred Minor : 0
Persistence : Superblock is persistent

Update Time : Sun Feb  7 21:27:29 2010
State : clean
Active Devices : 3
Working Devices : 6
Failed Devices : 0
Spare Devices : 3

Layout : left-symmetric
Chunk Size : 64K

UUID : abe4f009:9806dda4:4df6f1df:dc8baa81
Events : 0.2

Number   Major   Minor   RaidDevice State
0       3       65        0      active sync   /dev/hdb1
1       3       66        1      active sync   /dev/hdb2
2       3       67        2      active sync   /dev/hdb3

3      22       65        –      spare   /dev/hdd1
4      22       66        –      spare   /dev/hdd2
5      22       67        –      spare   /dev/hdd3
[root@carlosqueiroz ~]#

This part where we’ll make our array to grow up. That means, all of those partitions else will join to the array, as the array has been defined with 3 disks, it just need increasing three more.

[root@carlosqueiroz ~]# mdadm –grow /dev/md0 –raid-devices=6
mdadm: Need to backup 320K of critical section..
mdadm: … critical section passed.

You can watch all the process through watch cat /proc/mdstat. Caution, it can late a while.

[root@carlosqueiroz ~]#watch cat /proc/mdstat

Every 2.0s: cat /proc/mdstat                                                                                                         Sun Feb  7 21:33:15 2010

Personalities : [raid6] [raid5] [raid4]
md0 : active raid5 hdd3[3] hdd2[4] hdd1[5] hdb3[2] hdb2[1] hdb1[0]
12001024 blocks super 0.91 level 5, 64k chunk, algorithm 2 [6/6] [UUUUUU]
[>………………..]  reshape =  2.2% (134656/6000512) finish=46.9min speed=2081K/sec

unused devices: <none>

Once this process is finished, check out how is it like.

[root@carlosqueiroz ~]# mdadm –detail /dev/md0
/dev/md0:
Version : 0.90
Creation Time : Sun Feb  7 20:54:04 2010
Raid Level : raid5
Array Size : 30002560 (28.61 GiB 30.72 GB)
Used Dev Size : 6000512 (5.72 GiB 6.14 GB)
Raid Devices : 6
Total Devices : 6
Preferred Minor : 0
Persistence : Superblock is persistent

Update Time : Sun Feb  7 21:54:38 2010
State : clean
Active Devices : 6
Working Devices : 6
Failed Devices : 0
Spare Devices : 0

Layout : left-symmetric
Chunk Size : 64K

UUID : abe4f009:9806dda4:4df6f1df:dc8baa81
Events : 0.4006

Number   Major   Minor   RaidDevice State
0       3       65        0      active sync   /dev/hdb1
1       3       66        1      active sync   /dev/hdb2
2       3       67        2      active sync   /dev/hdb3
3      22       67        3      active sync   /dev/hdd3
4      22       66        4      active sync   /dev/hdd2
5      22       65        5      active sync   /dev/hdd1

Take it easy man, it still needs to make up some points like resizing  the volume. At beginning we must have around 11 GB. We have to resize this array.

Before:

[root@carlosqueiroz ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/hda3             9.0G  969M  7.6G  12% /
/dev/hda1              99M   12M   83M  12% /boot
tmpfs                 172M     0  172M   0% /dev/shm
/dev/md0               12G  157M   11G   2% /foobar
[root@carlosqueiroz ~]#

Launch resize2fs command.

[root@carlosqueiroz /]# resize2fs /dev/md0
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/md0 is mounted on /foobar; on-line resizing required
Performing an on-line resize of /dev/md0 to 7500640 (4k) blocks.
The filesystem on /dev/md0 is now 7500640 blocks long.

After:

[root@carlosqueiroz /]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/hda3             9.0G  969M  7.6G  12% /
/dev/hda1              99M   12M   83M  12% /boot
tmpfs                 172M     0  172M   0% /dev/shm
/dev/md0               29G  204M   27G   1% /foobar
[root@carlosqueiroz /]#

Don’t forget to regenerate mdadm.conf file. I used to do it every time :$

[root@carlosqueiroz /]# mdadm –examine –scan > /etc/mdadm.conf

Great! that’s all.
Cheers!

Categories: Linux
  1. No comments yet.
  1. No trackbacks yet.

Leave a comment