I want to create a second partition on a software RAID 5 created on debian stretch.

To create it I used mdadm --create /dev/md0 --auto md --level=5 --raid-devices=4 /dev/sda1 /dev/sdc1 /dev/sdd1 /dev/sdb1. The partitions have a GPT label and are tagged to be used for RAID.

The mdadm(8) manpage says

In Linux kernels prior to version 2.6.28 there were two distinctly different types of md devices that could be created: one that could be partitioned using standard partitioning tools and one that could not. Since 2.6.28 that distinction is no longer relevant as both type of devices can be partitioned. mdadm will normally create the type that originally could not be partitioned as it has a well defined major number (9).

I guess I need to create a udev rule or something like that to get a second partition, but can't find detailed documentation about HOW to do it, just that it is possible.

I finally want to create a LVM layer between the RAID and fs layers, but the filesystem is already filled by about 40% and I don't have enough extra storage to save the data elsewhere. Therefore I wanted to create a second partition after shrinking the filesystem, copy the data from my existing partition to the new one, delete the old partition, create the LVM layer, move data back and grow the LVM layer over the full RAID.

  • 2
    You can convert to LVM in-place (offline while not mounted) with lvmify. There is a description how to do it manually here wiki.ubuntuusers.de/Archiv/Howto/… (in German). It's instant as it only moves a single block of data. But you should have a backup either way, as any such operation will have its dangers. If the filesystem was ext4, you might be able to convert to btrfs and then use btrfs volumes. That is assuming - you like btrfs at all. – frostschutz Apr 6 '18 at 19:54
  • @frostschutz How would btrfs volumes be useful? – Hauke Laging Apr 6 '18 at 21:51
  • @frostschutz thank you! The Howto helped, I successfully created the LVM layer. – Christian Rudolph Apr 9 '18 at 19:04

You might want to investigate the udev rules associated with the device-mapper multipathing, and the kpartx tool. On multipathed devices, kpartx is used to create further device mappings on top of the multipath mapping if the multipathed disk contains a partition table.

But kpartx is not intrinsically tied to multipathing: it should be able to work on any disk-like device, probably including a /dev/md* RAID device.

So, for /dev/md0 for example, the corresponding partition mappings would be named /dev/mapper/md0pN where N is the partition number.

  • There is no partition table and none is supposed to be there. If there was one then md would create the necessary devices on its own. – Hauke Laging Apr 8 '18 at 14:02
  • I can confirm that kpartx doesn't help. At least I was not able to create a new partition. – Christian Rudolph Apr 9 '18 at 19:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.