Guidelines

This site is for tech Q&A. Please keep your posts focused on the subject at hand.

Ask one question at a time. Don't conflate multiple problems into a single question.

Make sure to include all relevant information in your posts. Try to avoid linking to external sites.

Links to documentation are fine, but in addition you should also quote the relevant parts in your posts.

0 votes
550 views
550 views

I had a harddisk failure in one of my servers. The disk (/dev/sda) is part of a Linux software RAID-1 with 2 partitions. The datacenter support replaced the failed disk, and now I'm trying to add it back into my software RAID.

Adding the partition for the swap volume worked fine:

root@server:~ # mdadm /dev/md0 -a /dev/sda1
mdadm: added /dev/sda1

But when I tried adding the partition for the root volume mdadm complained about the size, even though I created the partition with the same size as the corresponding one:

root@server:~ # mdadm /dev/md1 -a /dev/sda2
mdadm: /dev/sda2 not large enough to join array

Looking at fdisk output the new partition had less sectors than the one on the other disk:

root@server:~ # fdisk -l
...
Device     Boot   Start       End   Sectors  Size Id Type
/dev/sda1          2048   4209029   4206982    2G fd Linux raid autodetect
/dev/sda2       4210688 312492031 308281344  147G fd Linux raid autodetect
...
Device     Boot   Start       End   Sectors  Size Id Type
/dev/sdb1          2048   4209029   4206982    2G fd Linux raid autodetect
/dev/sdb2       4209030 312576704 308367675  147G fd Linux raid autodetect

So I deleted the partition again and re-created it with slightly larger size:

root@server:~ # fdisk -l
...
Device     Boot   Start       End   Sectors  Size Id Type
/dev/sda1          2048   4209029   4206982    2G fd Linux raid autodetect
/dev/sda2       4210688 314589183 310378496  148G fd Linux raid autodetect
...
Device     Boot   Start       End   Sectors  Size Id Type
/dev/sdb1          2048   4209029   4206982    2G fd Linux raid autodetect
/dev/sdb2       4209030 312576704 308367675  147G fd Linux raid autodetect

But mdadm still complained that /dev/sda2 was not large enough to join the array.

in Sysadmin
by (125)
3 19 33
edit history

Please log in or register to answer this question.

1 Answer

0 votes
 

Sector count can be misleading. Better use a tool like blockdev and compare the actual sizes of the two partitions:

blockdev --report /dev/sda2 /dev/sdb2

Make sure the new partition has at least the size of the other one if you want to add it to an existing RAID-1.

You may also need to force Linux to re-read the partition table after modifying the partitioning, otherwise blockdev and other tools might operate on stale data. You can do that by running partprobe (the tool is part of the parted package).

by (125)
3 19 33
edit history
...