[RndTbl] setting up RAID 1 with mdadm

Scott Toderash scott at 100percenthelpdesk.com
Thu Oct 4 10:07:12 CDT 2018

Here are my notes from the last time I build a Linux RAID on LVM. This 
was on 16.04LTS

I think my approach was slightly different. The RAID device is created 
on the LVM devices.

1. create partitions of type Linux RAID Autodetect on both disks
fdisk -l /dev/sdb
fdisk -l /dev/sdc
2. create a RAID array called md0 using mdstat
sudo mdadm --create /dev/md0 --level=mirror --raid-devices=2 /dev/sdb1 
3. add the md0 raid device to the LVM pool
sudo pvcreate /dev/md0
4. create a volume group called datavg
sudo vgcreate datavg /dev/md0
5. create a logical volume called datalv within the volume group
sudo lvcreate --name datalv --size 1.8T datavg
6. format the newly created logical volume
sudo mkfs.ext4 /dev/datavg/datalv
7. move home files to a temporary location, create a new home and mount 
the newly formatted device there, copy the original home files to the 
new device
sudo mv home home.orig; sudo mkdir home ; sudo chmod 777 home ; sudo 
mount /dev/mapper/datavg-datalv /home ; sudo cp -a /home.orig/* home
8. edit fstab for startup config for this disk

On 18-10-04 09:42 AM, Gilbert E. Detillieux wrote:
> I think the tutorial is complete enough.  The only thing I'd do 
> differently is create appropriate partition tables on the raw disks 
> (GPT if the disks are >2TB or if you need to use GPT for other 
> reasons, but the older MS-DOS partition tables would be fine 
> otherwise), set up one partition on each drive and tag them with the 
> applicable partition type to indicate they're MD RAID partitions, and 
> use the device names for the partitions rather than the raw drives in 
> the mdadm commands.  While this isn't necessary, I think it would help 
> in post-mortem recovery, and in keeping your sanity when you're (or 
> someone else is) trying to figure out what you did a few years later.
> LVM has some nice features to offer, e.g. if you anticipate wanting to 
> add more capacity to this file system in the future, or you want to 
> split a large array into multiple file systems.  But for simple use 
> cases, I wouldn't bother.  If you do use LVM, don't use its RAID 
> features; use LVM over top of MD.
> If you go with GPT partition format, and don't want to deal with the 
> arcane syntax of parted commands, there are alternatives: gparted for 
> the full-GUI, Partition-Magic-like experience, or gdisk for a simple 
> fdisk-like, retro, text-menu-based interface.
> Gilbert
> On 04/10/2018 8:33 AM, Gilles Detillieux wrote:
>> Circumstances finally forced me to bite the bullet and learn 
>> something I had been putting off for too long: setting up a RAID 
>> array under Linux. I'm almost embarrassed, now that I've done it, 
>> that I waited so long because it was way simpler than I'd imagined. I 
>> thought I'd have to figure out all kinds of magic with LVM, parted, 
>> and mdadm, but I found this tutorial that showed a simple set of 
>> mdadm commands to set up RAID 1:
>> https://www.digitalocean.com/community/tutorials/how-to-create-raid-arrays-with-mdadm-on-ubuntu-16-04 
>> This was actually one of the simplest scenarios: the system had an 
>> SSD for the root/boot partition, and two 2 TB hard drives for data 
>> storage (/dev/sdb & sdc), so I just needed to set up RAID 1 and not 
>> worry about the intricacies of booting from RAID. So, software RAID 
>> seemed like the quick & easy way to go with a minimum of fuss.
>> Now the nagging question: is it really this simple, or does the 
>> tutorial above oversimplify and omit some important steps? Can 
>> someone with ample RAID and mdadm experience advise or provide tips 
>> on anything else I should do or lookout for?
>> Thanks,
>> Gilles

More information about the Roundtable mailing list