Skip to contentSkip to conversation

growing md2, do I need three reboots?

DISCUSSION Janek Kozicki 2 participants 3 messages Dec 2, 2010 – Dec 3, 2010 MD RAID

lore
Share & tools
lore
#0 lore raw

Hello,

my /dev/md2 uses superblock 1.0, which is stored at the end of device. Therefore I suppose that this approach of growing it isn't going to work:

#Alter the partition tables, to make /dev/sd[abc]2 have new size:
fdisk /dev/sda
fdisk /dev/sdb
fdisk /dev/sdc

#reboot (make kernel read new partition table)

  #then, grow the raid1 /dev/md1
  mdadm --grow /dev/md2 --size=max

#and finaly, grow the ext2 (or ext3) fs on /dev/md1 resize2fs /dev/md1

Because in this way, after rebooting, /dev/md2 won't be found - the superblock won't be in the correct place.

So, I would need to remove each of them from the array, resize partition, then add it back. Thus needing three reboots, since I can remove only one device at a time (the same HDDs have also partitions belonging to root raid1 array), which must be always up & running.

I can afford reboots, no problem here, but isn't there some simpler way?

below is my raid layout, I need to grow md2 by few spare gigabytes left at the end of /dev/sd[abc].

kernel 2.6.29 (impossible to upgrade at the moment).

Personalities : [raid0] [raid1] [raid10]
md2 : active raid10 sda2[0] sdc2[2] sdb2[1]

      185381376 blocks super 1.0 512K chunks 2 far-copies [3/3] [UUU]
      bitmap: 1/6 pages [4KB], 16384KB chunk

md1 : active raid1 sdc1[2](W) sdb1[3](W)

      9767416 blocks super 1.0 [2/2] [UU]
      bitmap: 1/150 pages [4KB], 32KB chunk

md0 : active raid1 sde1[0] sdd1[2] sda1[1]

      9767424 blocks [3/3] [UUU]
      bitmap: 1/150 pages [4KB], 32KB chunk

unused devices: <none>

atak:/home/janek# mdadm -D /dev/md2
/dev/md2:
        Version : 1.0
  Creation Time : Thu Sep  2 11:47:39 2010
     Raid Level : raid10
     Array Size : 185381376 (176.79 GiB 189.83 GB)
  Used Dev Size : 123587584 (117.86 GiB 126.55 GB)
   Raid Devices : 3
  Total Devices : 3
    Persistence : Superblock is persistent

Intent Bitmap : Internal

Update Time : Thu Dec 2 16:41:02 2010
State : active
Active Devices : 3
Working Devices : 3
Failed Devices : 0
Spare Devices : 0

Layout : far=2
Chunk Size : 512K

Name : atak:2 (local to host atak) UUID : f2a75dbe:5ac91a1f:c09da3c0:f6f69c9c
Events : 28

Number Major Minor RaidDevice State
0 8 2 0 active sync /dev/sda2
1 8 18 1 active sync /dev/sdb2
2 8 34 2 active sync /dev/sdc2

best regards

Signature · 1 line
Janek Kozicki                               http://janek.kozicki.pl/  |
#1 lore raw
Quoted 22 lines · On Thu, 2 Dec 2010 16:52:03 +0100 Janek Kozicki <[email protected]> wrote:

Hello,

my /dev/md2 uses superblock 1.0, which is stored at the end of device. Therefore I suppose that this approach of growing it isn't going to work:

#Alter the partition tables, to make /dev/sd[abc]2 have new size:
fdisk /dev/sda
fdisk /dev/sdb
fdisk /dev/sdc

#reboot (make kernel read new partition table)

  #then, grow the raid1 /dev/md1
  mdadm --grow /dev/md2 --size=max

#and finaly, grow the ext2 (or ext3) fs on /dev/md1 resize2fs /dev/md1

Because in this way, after rebooting, /dev/md2 won't be found - the superblock won't be in the correct place.

Quoted 6 lines

So, I would need to remove each of them from the array, resize partition, then add it back. Thus needing three reboots, since I can remove only one device at a time (the same HDDs have also partitions belonging to root raid1 array), which must be always up & running.

I can afford reboots, no problem here, but isn't there some simpler way?

Yes, there is a simpler way, but no: it isn't going to work anyway.

You cannot 'grow' a RAID10 array at all - sorry. It is sufficiently complex that it needs quite a bit of time to design, code, and test. And I haven't had that time yet.

But if you could resize a RAID10 array, this is what I would do:

1/ For each devices (sda, sdb, sdc)
- fail and remove each partition from the respective array.
- run 'kpartx -a /dev/sdX'. This will create partitions in /dev/mapper/ with the same names.
- --re-add these partitions to the arrays. The presence of a write-intent-bitmap will mean that resync is almost instant.

2/ Use fdisk to change the partition tables.

3/ run 'kpartx -a /dev/sdX' again on each device. This will change the
partitions even while they are active.

4/ For the partitions which have changed size, find the matching

     /dev/md2/md/dev-dm0X/size
  and
     echo 0 > /dev/md2/md/dev-dm-X/size

This will cause md to relocate the metadata to the new end of the device. Not that these partitions (created by kpartx) are device-mapper partitions so have names like 'dm-0' and 'dm-1'.

5/ mdadm -G /dev/md2 --size max
This bit unfortunately won't work.

NeilBrown

Quoted 54 lines

below is my raid layout, I need to grow md2 by few spare gigabytes left at the end of /dev/sd[abc].

kernel 2.6.29 (impossible to upgrade at the moment).

Personalities : [raid0] [raid1] [raid10]
md2 : active raid10 sda2[0] sdc2[2] sdb2[1]

      185381376 blocks super 1.0 512K chunks 2 far-copies [3/3] [UUU]
      bitmap: 1/6 pages [4KB], 16384KB chunk

md1 : active raid1 sdc1[2](W) sdb1[3](W)

      9767416 blocks super 1.0 [2/2] [UU]
      bitmap: 1/150 pages [4KB], 32KB chunk

md0 : active raid1 sde1[0] sdd1[2] sda1[1]

      9767424 blocks [3/3] [UUU]
      bitmap: 1/150 pages [4KB], 32KB chunk

unused devices: <none>

atak:/home/janek# mdadm -D /dev/md2
/dev/md2:
        Version : 1.0
  Creation Time : Thu Sep  2 11:47:39 2010
     Raid Level : raid10
     Array Size : 185381376 (176.79 GiB 189.83 GB)
  Used Dev Size : 123587584 (117.86 GiB 126.55 GB)
   Raid Devices : 3
  Total Devices : 3
    Persistence : Superblock is persistent

Intent Bitmap : Internal

Update Time : Thu Dec 2 16:41:02 2010
State : active
Active Devices : 3
Working Devices : 3
Failed Devices : 0
Spare Devices : 0

Layout : far=2
Chunk Size : 512K

Name : atak:2 (local to host atak) UUID : f2a75dbe:5ac91a1f:c09da3c0:f6f69c9c
Events : 28

Number Major Minor RaidDevice State
0 8 2 0 active sync /dev/sda2
1 8 18 1 active sync /dev/sdb2
2 8 34 2 active sync /dev/sdc2

best regards

#2 lore raw

Neil Brown said: (by the date of Fri, 3 Dec 2010 12:25:47 +1100)

Quoted 3 lines
Quoted 1 line

I can afford reboots, no problem here, but isn't there some simpler way?

Yes, there is a simpler way, but no: it isn't going to work anyway.

Great! Thank you for your reply, I must remember this in case when I'll want to grow a non-raid10 array :)

And now: LVM to the rescue!

best regards
Janek Kozicki

Quoted 91 lines

You cannot 'grow' a RAID10 array at all - sorry. It is sufficiently complex that it needs quite a bit of time to design, code, and test. And I haven't had that time yet.

But if you could resize a RAID10 array, this is what I would do:

1/ For each devices (sda, sdb, sdc)
- fail and remove each partition from the respective array.
- run 'kpartx -a /dev/sdX'. This will create partitions in /dev/mapper/ with the same names.
- --re-add these partitions to the arrays. The presence of a write-intent-bitmap will mean that resync is almost instant.

2/ Use fdisk to change the partition tables.

3/ run 'kpartx -a /dev/sdX' again on each device. This will change the
partitions even while they are active.

4/ For the partitions which have changed size, find the matching

     /dev/md2/md/dev-dm0X/size
  and
     echo 0 > /dev/md2/md/dev-dm-X/size

This will cause md to relocate the metadata to the new end of the device. Not that these partitions (created by kpartx) are device-mapper partitions so have names like 'dm-0' and 'dm-1'.

5/ mdadm -G /dev/md2 --size max
This bit unfortunately won't work.

NeilBrown

Quoted 54 lines

below is my raid layout, I need to grow md2 by few spare gigabytes left at the end of /dev/sd[abc].

kernel 2.6.29 (impossible to upgrade at the moment).

Personalities : [raid0] [raid1] [raid10]
md2 : active raid10 sda2[0] sdc2[2] sdb2[1]

      185381376 blocks super 1.0 512K chunks 2 far-copies [3/3] [UUU]
      bitmap: 1/6 pages [4KB], 16384KB chunk

md1 : active raid1 sdc1[2](W) sdb1[3](W)

      9767416 blocks super 1.0 [2/2] [UU]
      bitmap: 1/150 pages [4KB], 32KB chunk

md0 : active raid1 sde1[0] sdd1[2] sda1[1]

      9767424 blocks [3/3] [UUU]
      bitmap: 1/150 pages [4KB], 32KB chunk

unused devices: <none>

atak:/home/janek# mdadm -D /dev/md2
/dev/md2:
        Version : 1.0
  Creation Time : Thu Sep  2 11:47:39 2010
     Raid Level : raid10
     Array Size : 185381376 (176.79 GiB 189.83 GB)
  Used Dev Size : 123587584 (117.86 GiB 126.55 GB)
   Raid Devices : 3
  Total Devices : 3
    Persistence : Superblock is persistent

Intent Bitmap : Internal

Update Time : Thu Dec 2 16:41:02 2010
State : active
Active Devices : 3
Working Devices : 3
Failed Devices : 0
Spare Devices : 0

Layout : far=2
Chunk Size : 512K

Name : atak:2 (local to host atak) UUID : f2a75dbe:5ac91a1f:c09da3c0:f6f69c9c
Events : 28

Number Major Minor RaidDevice State
0 8 2 0 active sync /dev/sda2
1 8 18 1 active sync /dev/sdb2
2 8 34 2 active sync /dev/sdc2

best regards

Signature · 1 line
Janek Kozicki                               http://janek.kozicki.pl/  |