• I'm creating a new RAID1 array using mdadm.
  • I won't be using additional layers, such as LVM or dm-crypt.

  • I've noticed that metadata version 1.2 is now the default. I understand it's the recommended version, if all other parts of the system (for example grub2) support it. This is the case for me.

  • From the manpage and several other sources I understand that metadata 1.2 means the superblock is stored at the beginning of the disk. At 4KiB from the start.
  • On previous RAID1 arrays I created, I used metadata version 0.90 which stores the superblock at the end of the disk instead. To prevent it from being overwritten, I left the last part of the disk unpartitioned.

It's my intention to partition the new RAID1 array with a GPT partition table, first partition starting at sector 2048. If a sector is 512 bytes, this means the actual partition will start at 1024KiB from the start of the disk.


  • Should I take any precautions to prevent the version 1.2 superblock from being overwritten, or is starting the first partition at sector 2048 enough to be relatively safe?
  • I imagine grub will write at the start of the disk, but it will probably only need the first 512 bytes. Do any other programs write right after those bytes on the disk?
  • Is the part right after the end of the first sector, up to sector 2048, a 'regulated' part of the disk? Do other programs check if any other data is present before they start writing there? I couldn't find anything specific about this.

I understand that using dd can destroy a superblock ;-) and so does mdadm --zero-superblock. I'm more concerned about any other utilities or filesystem layers such as LVM of which I may not immediately realise they could overwrite that specific part of the disk where the superblock is stored.


It's all about layers.

You have a disk (the lowest layer). On that disk you put a partition table. On that, you put a RAID. On the RAID you put LUKS. On the LUKS you add LVM. On the LVM, finally the filesystem (the highest layer).

Disk -> Partition -> RAID -> LUKS -> LVM -> Filesystem

You may skip or reorder some of those layers. It usually starts with a disk and ends in a filesystem, what's in between is optional.

No problems so far. All should be well.

As long as each of those layers are respected, there are no conflicts. Each of those layers has metadata, but each layer only provides what can be used without damaging that metadata. You can't create a partition that starts at sector 0 because that would clash with the partition table itself. You can't damage md metadata by writing to the md device. You can fill up the filesystem to the brim, it won't damage the filesystem metadata, nor any of the layers below it, because each layer looks after itself.

As such, you don't have to worry about anything.

Unless you stop respecting those layers.

You mention RAID and GPT. You can put RAID on a GPT partition, or GPT on a RAID. As long as it's one layer on the other layer, not a problem at all. But suppose you were trying to use both layers at the same time side-by-side? You partition your disk using GPT, and at the same time make the entire disk a member of your RAID.

Doesn't really work.

GPT has metadata at the start and end; RAID has metadata at the start or end (for md it depends on the metadata version). The RAID metadata may overwrite the GPT outright (or vice versa). Or it may actually seem to work since the offsets are slightly different, but it's still a horrible situation.

Suppose you wanted to use another layer along with that, where do you put it? If you put it on the RAID, it may cross boundaries of the partitions to created. If instead you put it on the partitions, it bypasses the RAID layer and as such won't be mirrored. The RAID believes itself in sync while the data is corrupted.

Suddenly you have layers fighting each other, when they should be cooperating and complementing.

  • The fun exception to this is GRUB (i.e. the bootloader). 1) PC boot loaders grab the first 446 bytes of the partitioned disk. That part is allowed for by MBR, and automatically by GPT since GPT includes a "protective MBR".
    – sourcejedi
    Sep 10 '17 at 19:22
  • 2) PC boot loaders may also be installed to the first sector of a partition, or an unpartitioned device such as a floppy disk. Obviously this requires some co-operation from the filesystem :(, and different versions of MS filesystems work a bit differently. My vague understanding was that Linux filesystems would just not use the first sector, e.g. ext2/3/4 does not touch the first 1024 bytes.
    – sourcejedi
    Sep 10 '17 at 19:23
  • 3) GRUB assumes that on MBR, something like sectors 1-30 are not used, because partitions will be aligned to some greater granularity. Originally "cylinders". AIUI that lets GRUB store more code to reliably find and read filesystems. This does not clash with GPT, because GRUB detects that case and puts this code in a "BIOS Boot Partition" instead, if booting in BIOS mode. (GRUB doesn't create this partition for you, it only fills it).
    – sourcejedi
    Sep 10 '17 at 19:26
  • I think the messy parts of 2 and 3) can be avoided by never installing GRUB to a partition (or unpartitioned device, because floppies are obsolete). Also not installing grub-pc to anything other that isn't really MBR or GPT... given what it has to do, it should be checking for them anyway, so you'd only have to worry if you had some weird format that looks strangely similar.
    – sourcejedi
    Sep 10 '17 at 19:33

You don't have to worry about all this. The data in a volume won't overlap with the metadata. Otherwise it would be very difficult to manage! For example, this is what each of your disks will look like (not to scale):

[--------------------- sda ------------------------]
[---][------------------ sda1 ---------------------]
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one copy of the data in /dev/md0
     ^^^^ superblock
^^^^ partition table

The partition table is not contained in a partition, and the RAID metadata is not contained inside the RAID volume. When you put content on the RAID volume, that content will occupy the part that isn't occupied by the metadata. You don't need to make any special arrangements.

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.