[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [OT?] LVM questions



Craig Hagerman <craighagerman@gmail.com> writes:

> Hi,
>
> I recently bought a new hard drive. I alread have another big hard
> drive for files so altogether they have 450 GB.  I decided to set up
> LVM on my system to make it easy to access both together and be able
> to add more space in the future, but I am a bit wary because I know
> little about LVM. This is strictly for data, not the root partition.
> (note- I HAVE read the howto and other things online but don't find
> any of them all that user-friendly for the newbie. Things like "um...
> how to I actually access this LVM disc I have just created" or "how do
> I get the LVM discs to automatically show up on reboot" are NOT
> obvious from the howto.)

LVM is dead simple:

1. Write the lvm label onto the disk/partition:
   pvcreate /dev/disk
2. Create a volume group with one or more physical volumes
   vgcreate vg-name /dev/disk
3. Create a logical volume (like a partition)
   lvcreate -L 1G -n lv-name vg-name
4. Format the LV
   mke2fs -j /dev/vg-name/lv-name
5. mount the filesystem
   mount /dev/vg-name/lv-name /mnt/whatever

That is realy all there is to it normaly. Debian has lvm all setup to
autodetect on boot and all.

> I am wondering if there is any downside about using LVM I should be
> aware of. Is my data any less safe? I ask because I didn't realizze
> (at first) how to get the LVM disc to show up on boot, so it appeared
> that everything just wasn't there. So I was thinking - what if I have
> some problem with my root partition in the future, is the data on an
> LVM share just as accessable as otherwise? (Stupid question perhaps,
> but I don't know much yet.)

If your lvm spans accross 2 disks the volume group won't be activated
when one of the disks fails. But you can manualy activate a partial
volume group (-P option) to recover as much of the data as is till
there. Any missing parts will be mapped to produce an I/O error when
read. Obviously any logical volume on the missing disk (even partialy)
will have data loss or is unreadable alltogether.

So yes, there is a downside to LVM. You loose a disk in the group and
you have problems. But if you would have a raid0 (striping) over the
disks you also have problems if one disks fails. That is just a result
of having multiple disks joined together.

> Also I am still uncertain about how to best make use of two discs with
> LVM. Do I HAVE to set up a RAID, or is it an option. Is there any
> benifit or danger to using a RAID or not with LVM. (I have never set
> up a RAID but my motherboard - ASUS Kv8 I think - can do that I
> think.) If I don't use a RAID how are the discs used? Does it just
> fill up one, and then start on the other or use space on both at the
> same time?

By default lvm will do linear raid, put one disk behind the other,
when creating logical volumes. You get the space benefit but no speed
gain.

But lvm can also do raid 0 (striping) of a logical volume over
multiple physical volumes. This gives you the extra speed from
accessing multiple drives in parallel just like raid0 would but
preserves the lvm abilities to grow/shrink or move a logical volume at
any time.

So if you think about doing linear raid or raid0 then LVM is always
superior.


The best use of 2 disks in my opinion is to use raid1 (mirroring) and
lvm. I would create 4 partitions:

sda1 + sdb1: 300Mb raid1 for /
sda2 + sdb2: 1GB raid1 for swap
sda3 + sdb3: 10GB raid1 with lvm (vg1) for /usr, /var, /home
sda4 + sdb4: rest with lvm (vg2) with less important data

This means that all the system files and your precious home directory
will be save from a single disk failure. You don't loose your system
configuration or your gpg key if a disk fails. Just plug in a new one,
partition it the same way and let the raid resync. 

But you also have less important data that utilizes the space of both
disks without any protection against disk failure. Put things on there
you can recover again, like a debian mirror. :)


Think carefully about the right sizes for the 3rd and 4th
partitions. Changing them later isn't the easiest.

> Apologies for my ignorance in advance.
>
> Craig

MfG
        Goswin



Reply to: