6

My questions are similar to this thread Does LVM increase the risk of data loss?, however, I couldn't find a satisfying answer.

So the question is, where does LVM store data/files, when I have a Volume Group (VG) of 3 physical disks? What happens when one disk fails? Can I just unplug that disk, tell LVM to remove that physical disk from the VG and just continue working with the other disks? So the real question is: Does LVM save a file on one disk or does LVM fragment the file and split it throughout the three disks? The first option can't possible be right, because what happens when I have a 3GB file, my VG says that 3GB are free, but in fact each disk only have 1GB of space left. So the latter is true? But then this means that I will definitely lose some other data other than from the failing disk?

3 Answers 3

7

The first thing is that the VG itself cannot store data (OK, it can, but there are little chances that you are using it this way). The second thing is: LVM does not see disks, but physical volumes.

Usually, data is stored on partitions defined under logical volumes. One VG can contain many LVs on many PVs. An image from Wikimedia may help:

![LVM scheme] (https://upload.wikimedia.org/wikipedia/commons/b/ba/LVM1.svg)

Now it depends on how have you configured your LVs: as linear, striped or mirrored volumes. Also, normally LVs are placed on PVs in order, but you may force LVM to place them on specific PVs.

If a disk containing a PV fails, there are two main things that can happen:

  • if a PV contained no LV, LVM will shout that it cannot find that PV, but data stored on other LVs will be safe
  • if there was at least a part of a logical volume on the missing PV, the filesystem defined on that LV will certainly be corrupted. Now it depends on the filesystem used how many data you will lose and how hard it will be to recover the remaining part.

Of course, if you have configured LVM in striped mode, most probably every single disk that fails will make all filesystems on all LVs corrupted.

If you want to read more about LVM internals, there is a good article in RedHat magazine: https://web.archive.org/web/20150213040147/http://www.redhat.com/magazine/009jul05/features/lvm2/

2
  • 1
    I did some testing with removing a PV from a used LV. In my case, the removed PV seemed to store all the metadata for the ext4 filesystem. While the files that sat on the other drives seemed intact, it all ended up in lost+found after a fsck.
    – jordanm
    Commented Sep 6, 2012 at 21:55
  • Would be nice to have access to that Red Hat URL. Could anyone provide an updated link? Commented Feb 2, 2017 at 6:02
4

It is not really LVMs responsibility to decide where the data goes. However, it may be given some control over the data distribution by using a specific configuration.

There are three types of LVM logical volumes. First, linear volumes, second striped and third mirrored volumes. If you have set up the linear mapping, it assigns a range of physical extents to an area of a logical volume in order. To the filesystem this looks like one continuous "disk".

It is then filesystems responsibility to store the data where ever it thinks the data should go. Many filesystems try to store data in continuous manner, so with linear volume the files may or may not fit into one physical volume.

For a striped volume, things are a bit different. There LVM actually splits the data to stripes and writes them parallel to different PVs.

A mirror maintains identical copies of data on different devices.

So depending on your setup, if PV3 fails, you might lose only the files that physically were in PV3 (linear), corrupt all the files that extends more than two stripes (striped), or none (mirror).

0

The behaviour of LVM is configured in lvm.conf (located in CentOS 5 on /etc/lvm/).

Normally LVM stores its meta-data on every PVs (see section metatdata in the configuration file).

And there are backups for LVM-information as defined in the backup-section of /etc/lvm/lvm.conf.

Now in this default-setup it completely depends on your VG/LV-setup, whether there will be data-loss, or not, if you loose a PV (if you mirror, you will not loose data).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .