# SOLVED: adding new drive to software raid array

## plink212

I have 3 software raids setup

```
Personalities : [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] 

md3 : active raid10 sdf2[1] sdb2[5] sda2[0] sde2[2] sdd2[3]

      292675584 blocks 64K chunks 2 near-copies [6/5] [UUUU_U]

      

md4 : active raid5 sdf3[2] sdb3[5] sda3[0] sde3[3] sdd3[1]

      6837411200 blocks level 5, 64k chunk, algorithm 2 [6/5] [UUUU_U]

      

md0 : active raid1 sdf1[2] sdb1[0] sda1[5] sde1[3] sdd1[4]

      97536 blocks [6/5] [U_UUUU]

      

unused devices: <none>

```

as you can see one of my drives has failed and I need to replace it.

So I have a new drive which is /dev/sdc and I need to recreate the partition layout

This is the setup /dev/sda

```
Model: ATA ST31500341AS (scsi)

Disk /dev/sda: 1500GB

Sector size (logical/physical): 512B/512B

Partition Table: gpt

Number  Start   End     Size    File system  Name     Flags

 1      17.4kB  100MB   100MB   ext2         primary  raid

 2      100MB   100GB   99.9GB  xfs          primary  raid

 3      100GB   1500GB  1400GB               primary  raid

```

I launched parted on /dev/sdc and issued

```
(parted) mkpart primary 0 100M                                           

Warning: The resulting partition is not properly aligned for best performance.

Ignore/Cancel? ignore                                                     

(parted) mkpart primary 100M 100G                                    

(parted) mkpart primary 100G -1 
```

but this ends up with

```
Number  Start   End     Size    File system  Name     Flags

 1      17.4kB  100MB   100MB   ext2         primary

 2      101MB   100GB   99.9GB               primary

 3      100GB   1500GB  1400GB               primary

```

However when I try to add /dev/sdc2 to the array I get 

```
mdadm --manage /dev/md3 --add /dev/sdc2

mdadm: /dev/sdc2 not large enough to join array

```

I am confused why 2 starts at 101MB and not 100MB like the first.

HelpLast edited by plink212 on Tue Aug 24, 2010 6:30 pm; edited 1 time in total

----------

## plink212

hmm if anyone else comes across this there is a workaround

in parted type

```
unit s
```

you can then specify the sector locations for the start and the end

----------

## Mad Merlin

sfdisk makes it a lot easier to do this, as it can dump and recreate a partition table for you. Something like so:

```
sfdisk -d /dev/sda | sfdisk /dev/sdb
```

Where /dev/sda is a drive currently working and part of the array, and /dev/sdb is a brand new, unpartitioned drive. Afterwards you can just add the newly created partitions to the arrays.

A more general problem that's easy to run into here is if you get another drive that's the same size, but has different geometry (usually happens with different brands or models), this often means you can't create partitions that are of identical size, and all of the new partitions must be at least as large as the existing ones. To get around this, try making your swap partition(s) smaller, even if you also have those in RAID arrays, it shouldn't be a problem to swapoff and recreate them.

----------

## plink212

agreed it would if they were mbr disks.

these were gpt disks and I couldn't get it to run against them

Tim

----------

