currently raid 1 with disks sda and sdb

# lsblk
[...]
sda 8:0 0 3,6T 0 disk
└─md0 9:0 0 3,6T 0 raid1
└─md0p1 259:5 0 3,6T 0 part /mnt/raid
sdb 8:16 0 3,6T 0 disk
└─md0 9:0 0 3,6T 0 raid1
└─md0p1 259:5 0 3,6T 0 part /mnt/raid
sdc 8:32 0 3,6T 0 disk
[...]
# df -h /mnt/raid/
Filesystem      Size  Used Avail Use% Mounted on
/dev/md0p1      3,6T  3,3T  129G  97% /mnt/raid
# cat /proc/mdstat
Personalities : [raid1] [linear] [multipath] [raid0] [raid6] [raid5] [raid4] [raid10]
md0 : active raid1 sda[0] sdb[1]
3906886464 blocks super 1.2 [2/2] [UU]
bitmap: 5/30 pages [20KB], 65536KB chunk
# mdadm --detail /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Fri Sep 18 18:02:13 2020
Raid Level : raid1
Array Size : 3906886464 (3.64 TiB 4.00 TB)
Used Dev Size : 3906886464 (3.64 TiB 4.00 TB)
Raid Devices : 2
Total Devices : 2
Persistence : Superblock is persistent

Intent Bitmap : Internal

   Update Time : Fri Sep  6 18:45:05 2024
         State : clean 
Active Devices : 2

Working Devices : 2
Failed Devices : 0
Spare Devices : 0

Consistency Policy : bitmap

          Name : nirvana:0  (local to host nirvana)
          UUID : 072a3189:a0f1aea9:14edbf71:d28dc14e
        Events : 321660

Number   Major   Minor   RaidDevice State
   0       8        0        0      active sync   /dev/sda
   1       8       16        1      active sync   /dev/sdb
# mdadm --grow /dev/md0 -l 5

mdadm: level of /dev/md0 changed to raid5
# cat /proc/mdstat
Personalities : [raid1] [linear] [multipath] [raid0] [raid6] [raid5] [raid4] [raid10]
md0 : active raid5 sda[0] sdb[1]
3906886464 blocks super 1.2 level 5, 64k chunk, algorithm 2 [2/2] [UU]
bitmap: 7/30 pages [28KB], 65536KB chunk

unused devices:
# mdadm --detail /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Fri Sep 18 18:02:13 2020
Raid Level : raid5
Array Size : 3906886464 (3.64 TiB 4.00 TB)
Used Dev Size : 3906886464 (3.64 TiB 4.00 TB)
Raid Devices : 2
Total Devices : 2
Persistence : Superblock is persistent

Intent Bitmap : Internal

Update Time : Fri Sep 6 18:47:30 2024
State : clean
Active Devices : 2

Working Devices : 2
Failed Devices : 0
Spare Devices : 0

Layout : left-symmetric
Chunk Size : 64K

Consistency Policy : bitmap

Name : nirvana:0 (local to host nirvana)
UUID : 072a3189:a0f1aea9:14edbf71:d28dc14e
Events : 321661

Number Major Minor RaidDevice State
0 8 0 0 active sync /dev/sda
1 8 16 1 active sync /dev/sdb
# mdadm /dev/md0 --add-spare /dev/sdc
mdadm: added /dev/sdc
# mdadm --grow /dev/md0 -n 3
# mdadm --detail /dev/md0
/dev/md0:
           Version : 1.2
     Creation Time : Fri Sep 18 18:02:13 2020
        Raid Level : raid5
        Array Size : 3906886464 (3.64 TiB 4.00 TB)
     Used Dev Size : 3906886464 (3.64 TiB 4.00 TB)
      Raid Devices : 3
     Total Devices : 3
       Persistence : Superblock is persistent

     Intent Bitmap : Internal

       Update Time : Sat Sep  7 13:03:01 2024
             State : active, reshaping 
    Active Devices : 3
   Working Devices : 3
    Failed Devices : 0
     Spare Devices : 0

            Layout : left-symmetric
        Chunk Size : 64K

Consistency Policy : bitmap

    Reshape Status : 1% complete
     Delta Devices : 1, (2->3)

              Name : nirvana:0  (local to host nirvana)
              UUID : 072a3189:a0f1aea9:14edbf71:d28dc14e
            Events : 334371

    Number   Major   Minor   RaidDevice State
       0       8        0        0      active sync   /dev/sda
       1       8       16        1      active sync   /dev/sdb
       2       8       32        2      active sync   /dev/sdc
# watch -n0.5 cat /proc/mdstat
Every 0,5s: cat /proc/mdstat nirvana: Sat Sep 7 12:42:38 2024

Personalities : [raid1] [linear] [multipath] [raid0] [raid6] [raid5] [raid4] [raid10]
md0 : active raid5 sdc[2] sda[0] sdb[1]
3906886464 blocks super 1.2 level 5, 64k chunk, algorithm 2 [3/3] [UUU]
[===============>…..] reshape = 77.1% (3013160320/3906886464) finish=159.1min speed=93615K/sec
bitmap: 5/30 pages [20KB], 65536KB chunk

unused devices:

after ~18h, the reshape finished

# mdadm --detail /dev/md0
/dev/md0:
           Version : 1.2
     Creation Time : Fri Sep 18 18:02:13 2020
        Raid Level : raid5
        Array Size : 7813772928 (7.28 TiB 8.00 TB)
     Used Dev Size : 3906886464 (3.64 TiB 4.00 TB)
      Raid Devices : 3
     Total Devices : 3
       Persistence : Superblock is persistent

     Intent Bitmap : Internal

       Update Time : Sat Sep  7 15:47:03 2024
             State : clean 
    Active Devices : 3
   Working Devices : 3
    Failed Devices : 0
     Spare Devices : 0

            Layout : left-symmetric
        Chunk Size : 64K

Consistency Policy : bitmap

              Name : nirvana:0  (local to host nirvana)
              UUID : 072a3189:a0f1aea9:14edbf71:d28dc14e
            Events : 336103

    Number   Major   Minor   RaidDevice State
       0       8        0        0      active sync   /dev/sda
       1       8       16        1      active sync   /dev/sdb
       2       8       32        2      active sync   /dev/sdc

this is step may be optional, but this way we ensure to maximize the space:

# mdadm --grow /dev/md0 --size max
mdadm: component size of /dev/md0 has been set to 3906886592K

now raid is starts to resync

# mdadm --detail /dev/md0
/dev/md0:
           Version : 1.2
     Creation Time : Fri Sep 18 18:02:13 2020
        Raid Level : raid5
        Array Size : 7813773184 (7.28 TiB 8.00 TB)
     Used Dev Size : 3906886592 (3.64 TiB 4.00 TB)
      Raid Devices : 3
     Total Devices : 3
       Persistence : Superblock is persistent

     Intent Bitmap : Internal

       Update Time : Sat Sep  7 15:50:03 2024
             State : clean, resyncing 
    Active Devices : 3
   Working Devices : 3
    Failed Devices : 0
     Spare Devices : 0

            Layout : left-symmetric
        Chunk Size : 64K

Consistency Policy : bitmap

     Resync Status : 0% complete

              Name : nirvana:0  (local to host nirvana)
              UUID : 072a3189:a0f1aea9:14edbf71:d28dc14e
            Events : 336106

    Number   Major   Minor   RaidDevice State
       0       8        0        0      active sync   /dev/sda
       1       8       16        1      active sync   /dev/sdb
       2       8       32        2      active sync   /dev/sdc

monitor with watch and wait to finish

# apt install cloud-guest-utils
# growpart /dev/md0 1
CHANGED: partition=1 start=2048 old: size=7813769216 end=7813771264 new: size=15627544287 end=15627546335
resize2fs /dev/md0p1
# resize2fs 1.46.5 (30-Dec-2021)
Filesystem at /dev/md0p1 is mounted on /mnt/raid; on-line resizing required
old_desc_blocks = 466, new_desc_blocks = 932
The filesystem on /dev/md0p1 is now 1953443035 (4k) blocks long.
# df -h /mnt/raid/
Filesystem      Size  Used Avail Use% Mounted on
/dev/md0p1      7,2T  3,3T  3,6T  48% /mnt/raid
Converting my raid1 to raid5

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *