Migrating from RAID0 -> RAID1 with mdadm

Because of a stupid mistake made during a hectic installation of RHEL /var partition was configured as RAID0 instead of RAID1. Thankfully, it could be easily fixed though with a short downtime. Here is how I did it:

  1. Stopped all processes that were using /var. In my case they were sendmail and named.
  2. Backed up the data.
  3. # cd /var
    # find . | cpio -o -Hnewc > /root/var.cpio
  4. I had to comment out /var in /etc/fstab because even in a single user mode I failed to unmount it.
  5. Rebooted into a single user mode.
  6. Created, mounted /dev/md3 and restored the data.
  7. # mdadm --stop /dev/md3
    # mdadm --create --verbose /dev/md3 --level=1 --raid-devices=2 /dev/sdb2 /dev/sd2
    # mkfs.ext3 /dev/md3
    # mount /var
    # cd /var; cpio -i < /root/var.cpio
  8. And finally, updated /etc/mdadm.conf to reflect applied changes.
  9. # mdadm --detail --scan > /etc/mdadm.conf
  10. Rebooted.
  11. Posted on September 2, 2009 at 5:39 pm by sergeyt · Permalink
    In: Linux

    Leave a Reply