I'd like to mirror my existing root (and only) partition on an SSD to another disk. It should be a sort of RAID-1, just asymmetric*. I know there's the option mdadm --write-behind, which should do it.

But I have no idea if it is possible with preserving the context of the existing partition. I imagine it like

  • create the "slave" partition
  • setup the RAID telling it that the slave partition is not initialized
  • let it initialize it by cloning the master partition

but I'm probably too optimistic, aren't I?

* All reads should access the first disk and writes should be considered finished when the first disk is written.

  • 1
    A friend of my friend recently nuked all his data by running mdadm --create while trying to achieve the same thing. I don't know how to do it correctly but that's not the way.
    – stribika
    Commented Mar 10, 2011 at 14:25
  • @stribika: You can run mdadm --create on an existing disk as long as you choose a superblock version that goes to the end of the disk, and shrink the filesystem accordingly. Commented Mar 10, 2011 at 19:33
  • @Gilles: I think he didn't do the degraded trick just added both disks to the array and hoped it would sync the right way.
    – stribika
    Commented Mar 10, 2011 at 21:54

2 Answers 2


You can create an mdraid RAID-1 array starting with an existing partition. First, you need to make room for the mdadm superblock, which means you need to shrink your filesystem a little.

At the moment, the normal superblock format is 0.9. Its location is between 128kB and 60kB from the end of the partition, it is 4kB long, and it starts on an address that is a multible of 64kB. So shrink your filesystem by 128kB, or more precisely to ((device_size mod 64kB) - 1) * 64kB.

If you want more than 2TB per stripe, you need the 1.0 superblock format, which isn't supported out-of-the-box by all distributions yet. The 1.0 superblock is at the end of the device, which I understand to mean that you only need to shrink your filesystem by 8kB.

Now that you've shrunk the filesystem, you can create the array. First create a degraded array with just the existing data. Make sure the filesystem isn't mounted at this point. For your use case the write-intent bitmap must be on a separate partition. Use -e 1.0 to use the newer version-1 superblock format.

mdadm --create /dev/md0 -e 0.9 -l 1 -n 2 \
      --write-behind=256 --bitmap=/path/to/bitmap /dev/sda1 missing

Now you can mount the filesystem in /dev/md0. Add the second disk at your leasure. The data will be copied to the new drive in the background.

mdadm --add /dev/md0 --write-mostly /dev/sdb1

I've created a mirrored array like this, but without write-behind mode. I don't think write-behind mode would invalidate the procedure.

  • Great. This would take half the time my method takes.
    – stribika
    Commented Mar 10, 2011 at 21:51
  • Can I remove the write-intent later?
    – Lionel
    Commented Jan 18, 2012 at 6:56
  • @Lionel: I've never tried this myself, but the mdadm manpage documents the following: * under "For Manage mode", that one can reset --write-mostly with mdadm --readwrite --re-add /dev/sdb1 * under --bitmap, that one can use --grow /dev/md0 --bitmap=none. BTW, the 1.0 format seems more 'defaultish' by now. Commented Dec 10, 2013 at 14:56

I have an idea. I tested this with small filesystems on loop devices I recommend you do the same before trying it yourself. In this answer /dev/sda is your disk with the important data and /dev/sdb is the new emtpy disk.

export DATA_DISK='/dev/sda'
export EMPTY_DISK='/dev/sdb'
  1. Create a degraded RAID1 array from the empty disk. This is important!

    mdadm --create /dev/md0 --level=1 --raid-devices=2 "${EMPTY_DISK}" missing
  2. Then shrink the filesystem on the disk you want to mirror. (Hopefully it's supported.) This is needed because the RAID arrays have a header and the full filesystem won't fit on the array.

  3. Copy the data to the new degraded array.

    dd if="${DATA_DISK}" of=/dev/md0 bs=4k
  4. Add the original disk to the array.

    mdadm --manage /dev/md0 --add "${DATA_DISK}"
  5. You can watch the synchronization progress.

    watch 'cat /proc/mdstat'
  • This procedure can be tuned in a few ways (rsync instead of raw copy, settings to choose the syncing bandwidth, and so on). One page describing such techniques which looks good is wiki.archlinux.org/index.php/…, though I didn't try that myself. Commented Dec 14, 2013 at 7:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .