RAID 1 after install and two controllers

I have question regarding RAID 1. Can I setup software RAID 1 after having installed the first drive and setup ubuntu 12? I know that during server install and partitioning I can select RAID and setup then, but what I am not clear on is how in the world to setup RAID 1 after the fact? Can someone provide directions for this?

Also, can I RAID 1 two drives one being 500GB and the mirror drive being 1TB? Of course the mirror drive would have a 500GB partition but that’s my point.

Lastly, can one drive be on IDE and the other on a SATA controller? I know speed will be an issue, that doesn’t matter, I just need to know if it will work without corrupting data and if it’s the same process?

Thanks.

Answer

You can’t quickly convert a single disk into a mirror as you need to add the mdadm signatures to the disk/partition first.

The process instead involves creating a new RAID device on a new disk with the existing partitions marked as “missing” and then copying the data across to the new MD device. You can achieve all of this without a reboot or using boot CD/USB.

See the detailed guide here: https://wiki.archlinux.org/index.php/Convert_a_single_drive_system_to_RAID

Further to these instructions, if you’re using LVM (you should be) I use pvmove instead of file copying (using rsync). Assuming your new md device is called md0 and your old disk was called sd0, do the following after creating your new md device ( mdadm --create /dev/md0 --level=1 --raid-devices=2 missing /dev/sdb2)

  1. pvcreate /dev/md0
  2. vgextend base /dev/md0
  3. pvmove /dev/sda /dev/md0
  4. vgreduce base /dev/sda

This block moves each LV/filesystem from the old disk to the new md device.

Update:

The whole process is, assuming old disk = /dev/sd0, new disk = /dev/sdb, single LVM PV in /dev/sda1, vg = ubuntu:

  1. Change to root: sudo -i
  2. Bring system to single user mode: telinit 1
  3. Create new part map for sdb: cfdisk /dev/sdb (New, Primary, Type: fd, Bootable)
  4. Create new md array with device missing mdadm --create /dev/md0 --level=1 --raid-devices=2 missing /dev/sdb
  5. Create LVM PV: pvcreate /dev/md0
  6. Extend VG to new disk: vgextend ubuntu /dev/md0
  7. Move all LVs to new disk: pvmove /dev/sda /dev/md0
  8. Remove old disk from VG: vgreduce ubuntu /dev/sda
  9. Copy partition map from new disk: sfdisk -d /dev/sdb | sfdisk /dev/sda
  10. Add missing disks to md0: mdadm -a /dev/md0 /dev/sda1
  11. Rebuild initramfs: update-initramfs
  12. Reinstall grub: grub-install /dev/sda ; grub-install /dev/sdb
  13. Bring back to normal user mode: telinit 3

Attribution
Source : Link , Question Author : jfreak53 , Answer Author : Alastair McCormack

Leave a Comment