[SATLUG] lvm2 and raid 0

John Pappas j at jvpappas.net
Mon Jan 7 14:30:49 CST 2008

On Jan 7, 2008 10:22 AM, Todd W. Bucy <toddwbucy at grandecom.net> wrote:

> I am getting ready to build a new box in the next couple of days.
> However I can only afford two 500 gig drives.  I would eventually like
> to expand to four or six 500 gig drives.  If I set my first two up as
> Raid 1 can I latter and another drive and change to Raid 5 without
> having to back up, format, and re-setup my system.

This is a non-trival operation (if you use a hardware RAID controller, some
of them support RAID level conversions, some don't).  There is an older tool
(http://unthought.net/raidreconf/index.shtml) that can reconfigure software
RAID levels, but the problem is that the conversion requires a "restripe" as
RAID 5 lays out checksum data across all disks in the array.  It usually is
possible to extend an R5 array by adding constituent disks, however.

>  Or would I be better off setting up an LVM.  I want the speed benefits as
> well as the
> redundancy benefits of Raid but I also want the ease of adding
> additional drives latter when I can afford them.

LVM and RAID are 2 distinctly separate items.  This thread has somewhat
confused the topics, so I will try to clarify a bit.  RAID through the
kernel provides a virtual block device that has redundancy constructed from
multiple physical block devices.  Functionally, it looks like this
RAID1(/dev/[sh]da1 + /dev/[sh]db1) = /dev/md0 and so RAID5(/dev/[sh]da1 +
/dev/[sh]db1 + /dev/[sh]dc1) = /dev/md0.  You would then use /dev/md0 as
your disk for File System or LVM operations.  ie mkfs /dev/md0 or pvcreate

LVM on the other hand uses pooled blocks from one or multiple block devices,
and then subdivides these blocks into one or many logical block sets called
volumes represented by a device ie /dev/VolumeGroupName/VolumeName.  Since
these volumes are logical, it is possible to then move, add, delete blocks
in order to address changing storage needs, without changing the underlying
physical disk structure.

Advanced example: 5 disks, one R1 Array (2 disks) and one R5 Array (3
disks).  By adding both arrays (say /dev/md0 and /dev/md1) to a volume group
(say VG00) and you had a logical volume (say lv00) you could execute the
following `pvmove -n lv00 /dev/md1 VG00` which would then move the volume
from the R1 disks to the R5 disks without downtime.

The application in your case would be to add 2 disks, break the mirror, use
the 2 new and 1 old disks to create an R5 set, execute the PVmove to move
the contents of the data disk to the new array, then extend the R5 array
with the newly vacated disk.

Hope that helps!

More information about the SATLUG mailing list