Laptop with Linux Mint 17.3, 1x SSD for system and 2x HDD intended for RAID1 using mdadm.

Without knowing how to create RAID1 properly, I created it badly.

  • GParted showed a warning that a primary gpt partition table is not there, and that it is using the backup one, I think it showed this twice

  • GParted showed the partition on both HDDs contained ext4 filesystem, instead of linux-raid filesystem

  • GParted did not show the raid flag on neither HDDs

  • Reboot caused the array not to work, I mean not only it did not mount automatically, it could not be mounted without stopping the array and re-assembling it

  • There were probably other things I did not notice like I don't know if the array, I mean the mirroring, even worked properly


In this answer, let it be clear that all of your data will be destroyed on both of the array members (drives), so back it up first!

Open terminal and become root (su); if you have sudo enabled, you may also do for example sudo -i; see man sudo for all options):

sudo -i

Check what number (mdX) the array has:

cat /proc/mdstat

Suppose it is md0 and it is mounted on /mnt/raid1, first we have to unmount and stop the array:

umount /mnt/raid1
mdadm --stop /dev/md0

We need to erase the super-block on both drives, suppose sda and sdb:

mdadm --zero-superblock /dev/sda1
mdadm --zero-superblock /dev/sdb1

Let's get to work; we should erase the drives, if there were any data and filesystems before, that is. Suppose we have 2 members: sda, sdb:

pv < /dev/zero > /dev/sda
pv < /dev/zero > /dev/sdb

If you were to skip the previous step for your reasons, you need to wipe all filesystems on both of the drives. Then check if there is nothing left behind, you may peek with GParted on both of the drives, and if there is any filesystem other than unknown, wipe it.

First, we wipe all existing partitions, suppose sda contains 3 partitions, then:

wipefs --all /dev/sda3
wipefs --all /dev/sda2
wipefs --all /dev/sda1

Use this on both of the drives and do all partitions there are.

Then, we wipe the partition scheme with:

wipefs --all /dev/sda
wipefs --all /dev/sdb

Then, we initialize both drives with GUID partition table (GPT):

gdisk /dev/sda
gdisk /dev/sdb

In both cases use the following:

o Enter for new empty GUID partition table (GPT)
y Enter to confirm your decision
w Enter to write changes
y Enter to confirm your decision

Now, we need to partition both of the drives, but don't do this with GParted, because it would create a filesystem in the process, which we don't want, use gdisk again:

gdisk /dev/sda
gdisk /dev/sdb

In both cases use the following:
n Enter for new partition
Enter for first partition
Enter for default of the first sector
Enter for default of the last sector
fd00 Enter for Linux RAID type
w Enter to write changes
y Enter to confirm your decision

To triple-check if there is nothing left behind, you may peek with GParted on both of the newly created partitions, and if they contain any filesystem other than unknown, wipe it:

wipefs --all /dev/sda1
wipefs --all /dev/sdb1

You can examine the drives now:

mdadm --examine /dev/sda /dev/sdb

It should say:

(type ee)

If it does, we now examine the partitions:

mdadm --examine /dev/sda1 /dev/sdb1

It should say:

No md superblock detected

If it does, we can create the RAID1 array:

mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1

We shall wait until the array is fully created, this process we may watch with:

watch -n 1 cat /proc/mdstat

After creation of the array, we should look at its detail:

mdadm --detail /dev/md0

It should say:

          State : clean
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

Now we create filesystem on the array, if you use ext4, this is better to be avoided, because of ext4lazyinit would take noticeable amount of time, hence the name, "lazyinit", therefore I recommend you to avoid this one:

mkfs.ext4 /dev/md0

Instead, you should force a full instant initialization with:

mkfs.ext4 -E lazy_itable_init=0,lazy_journal_init=0 /dev/md0

By specifying these options, the inodes and the journal will be initialized immediately during creation, useful for larger arrays.

If you chose to take a shortcut and created the ext4 filesystem with the "better avoided command", note that ext4lazyinit will take noticeable amount of time to initialize all of the inodes, you may watch it until it is done, e.g. with:


Either way you choose to make the file system initialization, you should mount it after it has finished its initialization.

We now create some directory for this RAID1 array:

mkdir --parents /mnt/raid1

And simply mount it:

mount /dev/md0 /mnt/raid1

Since we are essentially done, we may use GParted again to quickly check if it shows linux-raid filesystem, together with the raid flag on both of the drives.

If it does, we properly created the RAID1 array with GPT partitions and can now copy files on it.

See what UUID the md0 filesystem has:

blkid /dev/md0

Copy the UUID to clipboard.

Now we need to edit fstab, with your favorite text editor:

nano /etc/fstab

And add add an entry to it:

UUID=<the UUID you have in the clipboard>    /mnt/raid1    ext4    defaults     0    0

You may check if it is correct, after you save the changes:

mount --all --verbose | grep raid1

It should say:

already mounted

If it does, we save the array configuration; in case you don't have any md device yet created, you can simply do:

mdadm --detail --scan >> /etc/mdadm/mdadm.conf

In case there are arrays already existent, just run the previous command without redirection to the conf file:

mdadm --detail --scan

and add the new array to the mdadm.conf file manually.

In the end, don't forget to update your initramfs:

update-initramfs -u

Check if you did everything according to plan, and if so, you may restart:

reboot --reboot

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.