Linux – mdadm RAID1 with harddisks of different blocksize

linuxraid

After a crash I had to replace one of my HDDs (namely sdd).
The old one (and the one left – sdc – and the md0 itself) use a blocksize of 512 Bytes.
The new drive has a physical blocksize of 4K.

The question now is, can I add the new drive to the RAID and will it work out?

Here some info from fdisk:
(where md0 is the raid, sdc is active, and sdd is the new one that will be used for replacement):

# fdisk -l /dev/md0 /dev/sdc /dev/sdd

Platte /dev/md0: 1000.2 GByte, 1000202174464 Byte
2 Köpfe, 4 Sektoren/Spur, 244189984 Zylinder
Einheiten = Zylinder von 8 × 512 = 4096 Bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Festplatte /dev/md0 enthält keine gültige Partitionstabelle

Platte /dev/sdc: 1000.2 GByte, 1000204886016 Byte
255 Köpfe, 63 Sektoren/Spur, 121601 Zylinder
Einheiten = Zylinder von 16065 × 512 = 8225280 Bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x31eb0cf1

   Gerät  boot.     Anfang        Ende     Blöcke   Id  System
/dev/sdc1               1      121601   976760001   fd  Linux raid autodetect

Platte /dev/sdd: 1000.2 GByte, 1000204886016 Byte
255 Köpfe, 63 Sektoren/Spur, 121601 Zylinder
Einheiten = Zylinder von 16065 × 512 = 8225280 Bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000

Festplatte /dev/sdd enthält keine gültige Partitionstabelle

The only other way i can imagine would be creating another md1, adding the new drive to that, copy (rsync -avl) all files to the new md, repartition the old drive to fit the 4K blocksize, disassemble md0, and add the old drive to the new md1.

But this would take a lot of time, so i'd like to avoid that.

Best Answer

It seems to work, without any problems.

What I did:

  1. add the new drive to the RAID and let mdadm sync the drives
  2. remove the new drive from the RAID again after sync is done
  3. run fsck. on the drive
  4. mount the drive and test some directories and files manually
  5. unmount and re-add the drive to the RAID

All these steps worked without any problems. The filesystem worked as expected.

So the answer finally is (without guaranteeing its generality): You can add a device with differing block- and I/O size to a RAID1.

Related Topic