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?


The question is not very clear, but I will try to answer anyway.

First thing is that VG itself cannot store data (OK, it can, but there are little chances that you are using it this way). Second thing - 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

Now it depends on how have you configured your LVs - as linear, stripped 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 containig a PV will fail, 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 stripped 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: http://www.redhat.com/magazine/009jul05/features/lvm2/

|improve this answer|||||
  • 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 Sep 6 '12 at 21:55
  • Would be nice to have access to that Red Hat URL. Could anyone provide an updated link? – Felipe Alvarez Feb 2 '17 at 6:02

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).

|improve this answer|||||

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).

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.