0

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.

MadHatter
  • 78,442
  • 20
  • 178
  • 229
jfreak53
  • 188
  • 1
  • 3
  • 25

2 Answers2

2

Can I setup software RAID 1 after having installed the first drive and setup Ubuntu 12?

Yes, you can.

Consider this:

Current situation: 
Drive 1: Already in use.
Drive 2: Empty.

Now create a mirror, using drive 2 (I know, a mirror with 1 drive makes little sense)

Drive 1: Already in use.
Drive 2: Part of a mirror. (degraded).

Copy all data from drive 1 to the mirror.
Test the mirror.
Boot from the mirror.

Current situation: 
Drive 1: Filled with stuff, but currently unused.
Drive 2: New installation on degraded RAID 1 (mirror)

Now add drive 1 to the mirror.

While this might not be trivial, it certainly is possible.

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.

Yes you can. This question has been asked several times before. Use the search box in the right upper corner of the page to locate the answers. The short version is:

  1. You can do this using hardware RAID. You will end up with a 500GB mirror
  2. You can do this with mdadm and end up with a 500GB mirror. Optionally you can also use the remaining part of the larger drive (but not as part of the mirror).

Lastly, can one drive be on IDE and the other on a SATA controller?

Technically this is not problem.

However mirror write speed is likely to be the lowest common speed of both drives.

Hennes
  • 4,772
  • 1
  • 18
  • 29
  • So basically the directions for mdadm on https://help.ubuntu.com/community/Installation/SoftwareRAID#Using_mdadm will work just fine for my case? Thanks :) – jfreak53 Nov 25 '12 at 17:41
  • If you refer to the *Boot from degraded disk*. With `BOOT_DEGRADED=true`, then yes. Do not skip the part where they test if the system boots. And if you have important information, **always** back that up before doing anything new which includes formatting filesystems. – Hennes Nov 25 '12 at 17:52
2

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
Alastair McCormack
  • 2,184
  • 13
  • 22
  • I can't do this as my new disk is a 1.5TB and my old disk is a 1TB. So I can't make a new everything on my new drive and copy over, I couldn't do a mirror from bigger to smaller then. – jfreak53 Jan 10 '13 at 22:21
  • 1
    In step 3, only create the partition table on the new disk to be 1TB – Alastair McCormack Jan 10 '13 at 22:55