Skip to Content

The logical volume manager. Inconspicuous, unassuming but could quite honestly be one of the most integral parts of the linux OS. For those who have not really cared or taken much notice about the finer points of LVM, then this blog post may change your mind.

LVM can be used in a multitude of ways some of them being -

  • Provide data protection by way or mirroring volumes
  • Provide increased I/O performance by way of striping across volumes
  • Ability to resize and reshape volumes on the fly
  • Provide backup utilities using snapshots

These are a just a few of the benefits of understanding more about LVM. My experience in particular was to create GPT partitions on 22 SAN attached LUNS without losing my data. My LVM metadata was written directly on the LUN rather than a partition on the LUN so I had the problem of now trying to create the partition which required the first 34 sectors which would overwrite the LVM metadata which was situated at the first 4 sectors. Dilemma.

Each LUN was in it's own volume group and the logical volume that the file system sits on, was within that volume group. So the solution here was to add another physical volume to the volume group with the vgextend command and remove the existing one so I could then do what I want with it. It can immediately be seen how this may be benificial to other problems. For example if the problem was to replace the existing disks with bigger or faster disks, then the same methodology would also be relevant.

I now have 2 physical volumes in my volume group and using the pvmove command I could move the extents off the volume I so wish. One piece of advice here though is that this can be extremely time consuming, so it is a good idea to reduce the file system to not much bigger than what is absolutely necessary and in turn reduce the size of the logical volume.

Once the pvmove command is complete, the vgreduce -a command can be executed to remove the physical volume from the volume group. If the physical volume is still in use, vgreduce will inform you that ir is so and therefore will not trash your VG. It is always a good idea anyway to use the -t option (test).

Now that all the extents have been moved to the replacement disk, the old disk can be removed with the pvremove command and then what ever is required to be done with the disk/s can be done. To put back all that needs to be done is the reverse of the process - pvcreate, vgextend to add the disk again and then pvmove the subsitute disk.

Don't forget to lvresize and resize2fs back to the way it was after your done!

Another handy little tip is to keep copies of your /etc/lvm/archive and /etc/lvm/backup directories. Should for any reason you lose the lvm metadata on your physical volumes, then your going to need the above to piece everything back together.

Quorum Problems with a Non-Root Volume Group

If you attempt to activate a non-root volume group when not enough disks and backup are present to establish a quorum, you will see error messages similar to those in this example: vgchange -a y /dev/vg01 vgchange: Warning: Couldn't attach to the volume group physical volume "/dev/dsk/c1t0d2":The path of the physical volume refers to a device that does notexist, or is not configured into the kernel. vgchange: Couldn't activate volume group "/dev/vg01":Either no physical volumes are attached or no valid VGDAs were foundon the physical volumes. If a non-root volume group does not get activated because of a failure to meet quorum, try the following: Check the power and data connections of all the disks that are part of the volume group that you cannot activate. Return all disks (or, at least enough to make a quorum) to service. Then, use the vgchange command to try to activate the volume group again. If there is no other way to make a quorum available, the -q option to the vgchange command will override the quorum check. EXAMPLE: vgchange -a y -q n /dev/vg01 CAUTION: This will activate the volume group but a quorum will not be present. You might get messages about not being able to access logical volumes. This is because some or all of a logical volume might be located on one of the disks that is not present. Whenever you override a quorum requirement, you run the risk of using data that is not current. Be sure to check the data on the logical volumes in the activated volume group as well as the size and locations of the logical volumes to ensure that they are up-to-date. You should attempt to return the disabled disks to the volume group as soon as possible. When you return a disk to service that was not online when you originally activated the volume group, use the activation command again to attach the now accessible disks to the volume group. EXAMPLE: vgchange -a y /dev/vg01

Reply

LVM keeps a metadata header at the start of every physical volume, each of which is uniquely identified by a UUID. Each PV's header is a complete copy of the entire volume group's layout, including the UUIDs of all other PV, the UUIDs of all logical volumes and an allocation map wedding bandsof PEs to LEs. This simplifies data recovery in the event of PV loss. In the 2.6-series of the Linux Operating System, the LVM is implemented in terms of the device mapper, a simple block-level scheme for creating virtual block devices and mapping their contents onto other block devices. This minimizes the amount of relatively hard-to-debug kernel code needed to implement the LVM. It also allows its I/O redirection services to be shared with other volume managers (such as EVMS). Any LVM-specific code is pushed out into its user-space tools, whichmagnetic bracelet merely manipulate these mappings and reconstruct their state from on-disk metadata upon each invocation.

This war will not end today,

This war will not end today, or tomorrow, or acceptable for decades to come, if ever E20-520. But so continued as we advance aback adjoin those who seek to yield abroad our freedoms HP0-D03, and action the acceptable fight, we will win victories that will accord us the freedoms we deserve and desire HP0-D04. We have to never become complacent. Software and media abandon is for everyone, and it is a appropriate and a abandon we should never, anytime yield for granted.