I had trouble finding tutorials on setting up a simple filesystem raid 1 setup. Most were geared towards setting up Ubuntu on a Raid 1 array.
List your disks:
$ sudo fdisk -l
This will give an output like:
Disk /dev/sdd: 240.1 GB, 240057409536 bytes 81 heads, 63 sectors/track, 91879 cylinders, total 468862128 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x211bbf32 Device Boot Start End Blocks Id System /dev/sdd1 2048 468862127 234430040 fd Linux raid autodetect Disk /dev/sde: 240.1 GB, 240057409536 bytes 81 heads, 63 sectors/track, 91879 cylinders, total 468862128 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x22e6d1f2 Device Boot Start End Blocks Id System /dev/sde1 2048 468862127 234430040 fd Linux raid autodetect
The two disks that I listed above have already been added to an array, but the output should be roughly similar (yours won’t she partitions). The two devices I’ll be working with are /dev/sdd and /dev/sde.
Now, we are ready to begin creating our array:
$ sudo fdisk /dev/sdd
Press the following keys:
- n for new partition, then
- p for primary, then
- 1 for partition 1, then
- enter & enter again.
You’ll want to change the system id, so press “t” and then type “FD.” FD is the hex code to designate it as Linux Raid Autodetect.
- Press “w” to write changes.
Repeat the above steps for your second drive (/dev/sde in my case).
Now, we are ready to run mdadm (if you haven’t already, type in sudo apt-get install mdadm)
$ sudo mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdd1 /dev/sde1
While it’s creating the array, you can watch the process with:
$ watch cat /proc/mdstat
Once it’s done creating the array, we’ll need to create a filesystem on the drive:
$ sudo mkfs -t ext4 /dev/md0
After that, we’ll want to mount the array somewhere, I chose /raid
$ sudo mkdir /raid $ sudo mount /dev/md0 /raid
To permanently mount it, you’ll want to mount it by UUID, so type in:
$ sudo blkid
Fine the output that looks like:
/dev/md0: LABEL="KVM" UUID="758f8408-caed-49dc-98f9-xxxxxxxxx" TYPE="ext4"
$ sudo nano /etc/fstab
UUID=758f8408-caed-49dc-98f9-xxxxxxxx /raid auto defaults 0 0
That’s pretty much it!