Cari di RHE Linux 
    Red Hat Enterprise Linux Manual
Daftar Isi
(Sebelumnya) 10 : Chapter 4. LVM Administra ...10 : 4.5. Controlling LVM Devi ... (Berikutnya)

Logical Volume Manager Administration

4.4. Logical Volume Administration

This section describes the commands that perform the various aspects of logical volume administration.

4.4.1. Creating Linear Logical Volumes

To create a logical volume, use the lvcreate command. If you do not specify a name for the logical volume, the default name lvol# is used where # is the internal number of the logical volume.
When you create a logical volume, the logical volume is carved from a volume group using the free extents on the physical volumes that make up the volume group. Normally logical volumes use up any space available on the underlying physical volumes on a next-free basis. Modifying the logical volume frees and reallocates space in the physical volumes.
As of the Red Hat Enterprise Linux 6.3 release, you can use LVM to create, display, rename, use, and remove RAID logical volumes. For information on RAID logical volumes, refer to Section 4.4.15, "RAID Logical Volumes".
The following command creates a logical volume 10 gigabytes in size in the volume group vg1.
# lvcreate -L 10G vg1
The following command creates a 1500 MB linear logical volume named testlv in the volume group testvg, creating the block device /dev/testvg/testlv.
# lvcreate -L1500 -n testlv testvg
The following command creates a 50 gigabyte logical volume named gfslv from the free extents in volume group vg0.
# lvcreate -L 50G -n gfslv vg0
You can use the -l argument of the lvcreate command to specify the size of the logical volume in extents. You can also use this argument to specify the percentage of the volume group to use for the logical volume. The following command creates a logical volume called mylv that uses 60% of the total space in volume group testvg.
# lvcreate -l 60%VG -n mylv testvg
You can also use the -l argument of the lvcreate command to specify the percentage of the remaining free space in a volume group as the size of the logical volume. The following command creates a logical volume called yourlv that uses all of the unallocated space in the volume group testvg.
# lvcreate -l 100%FREE -n yourlv testvg
You can use -l argument of the lvcreate command to create a logical volume that uses the entire volume group. Another way to create a logical volume that uses the entire volume group is to use the vgdisplay command to find the "Total PE" size and to use those results as input to the lvcreate command.
The following commands create a logical volume called mylv that fills the volume group named testvg.
# vgdisplay testvg | grep "Total PE"Total PE  10230# lvcreate -l 10230 testvg -n mylv
The underlying physical volumes used to create a logical volume can be important if the physical volume needs to be removed, so you may need to consider this possibility when you create the logical volume. For information on removing a physical volume from a volume group, see Section 4.3.7, "Removing Physical Volumes from a Volume Group".
To create a logical volume to be allocated from a specific physical volume in the volume group, specify the physical volume or volumes at the end at the lvcreate command line. The following command creates a logical volume named testlv in volume group testvg allocated from the physical volume /dev/sdg1,
# lvcreate -L 1500 -ntestlv testvg /dev/sdg1
You can specify which extents of a physical volume are to be used for a logical volume. The following example creates a linear logical volume out of extents 0 through 24 of physical volume /dev/sda1 and extents 50 through 124 of physical volume /dev/sdb1 in volume group testvg.
# lvcreate -l 100 -n testlv testvg /dev/sda1:0-24 /dev/sdb1:50-124
The following example creates a linear logical volume out of extents 0 through 25 of physical volume /dev/sda1 and then continues laying out the logical volume at extent 100.
# lvcreate -l 100 -n testlv testvg /dev/sda1:0-25:100-
The default policy for how the extents of a logical volume are allocated is inherit, which applies the same policy as for the volume group. These policies can be changed using the lvchange command. For information on allocation policies, see Section 4.3.1, "Creating Volume Groups".

4.4.2. Creating Striped Volumes

For large sequential reads and writes, creating a striped logical volume can improve the efficiency of the data I/O. For general information about striped volumes, see Section 2.3.2, "Striped Logical Volumes".
When you create a striped logical volume, you specify the number of stripes with the -i argument of the lvcreate command. This determines over how many physical volumes the logical volume will be striped. The number of stripes cannot be greater than the number of physical volumes in the volume group (unless the --alloc anywhere argument is used).
If the underlying physical devices that make up a striped logical volume are different sizes, the maximum size of the striped volume is determined by the smallest underlying device. For example, in a two-legged stripe, the maximum size is twice the size of the smaller device. In a three-legged stripe, the maximum size is three times the size of the smallest device.
The following command creates a striped logical volume across 2 physical volumes with a stripe of 64kB. The logical volume is 50 gigabytes in size, is named gfslv, and is carved out of volume group vg0.
# lvcreate -L 50G -i2 -I64 -n gfslv vg0
As with linear volumes, you can specify the extents of the physical volume that you are using for the stripe. The following command creates a striped volume 100 extents in size that stripes across two physical volumes, is named stripelv and is in volume group testvg. The stripe will use sectors 0-49 of /dev/sda1 and sectors 50-99 of /dev/sdb1.
# lvcreate -l 100 -i2 -nstripelv testvg /dev/sda1:0-49 /dev/sdb1:50-99  Using default stripesize 64.00 KB  Logical volume "stripelv" created

4.4.3. Creating Mirrored Volumes

Note

As of the Red Hat Enterprise Linux 6.3 release, LVM supports RAID4/5/6 and a new implementation of mirroring. For information on this new implementation, refer to Section 4.4.15, "RAID Logical Volumes".

Mirrored LVM Logical Volumes in a Cluster

Creating a mirrored LVM logical volume in a cluster requires the same commands and procedures as creating a mirrored LVM logical volume on a single node. However, in order to create a mirrored LVM volume in a cluster the cluster and cluster mirror infrastructure must be running, the cluster must be quorate, and the locking type in the lvm.conf file must be set correctly to enable cluster locking. For an example of creating a mirrored volume in a cluster, see Section 5.5, "Creating a Mirrored LVM Logical Volume in a Cluster".
Attempting to run multiple LVM mirror creation and conversion commands in quick succession from multiple nodes in a cluster might cause a backlog of these commands. This might cause some of the requested operations to time-out and, subsequently, fail. To avoid this issue, it is recommended that cluster mirror creation commands be executed from one node of the cluster.
When you create a mirrored volume, you specify the number of copies of the data to make with the -m argument of the lvcreate command. Specifying -m1 creates one mirror, which yields two copies of the file system: a linear logical volume plus one copy. Similarly, specifying -m2 creates two mirrors, yielding three copies of the file system.
The following command creates a mirrored logical volume with a single mirror. The volume is 50 gigabytes in size, is named mirrorlv, and is carved out of volume group vg0:
# lvcreate -L 50G -m1 -n mirrorlv vg0
An LVM mirror divides the device being copied into regions that, by default, are 512KB in size. You can use the -R argument of the lvcreate command to specify the region size in megabytes. You can also change the default region size by editing the mirror_region_size setting in the lvm.conf file.

Note

Due to limitations in the cluster infrastructure, cluster mirrors greater than 1.5TB cannot be created with the default region size of 512KB. Users that require larger mirrors should increase the region size from its default to something larger. Failure to increase the region size will cause LVM creation to hang and may hang other LVM commands as well.
As a general guideline for specifying the region size for mirrors that are larger than 1.5TB, you could take your mirror size in terabytes and round up that number to the next power of 2, using that number as the -R argument to the lvcreate command. For example, if your mirror size is 1.5TB, you could specify -R 2. If your mirror size is 3TB, you could specify -R 4. For a mirror size of 5TB, you could specify -R 8.
The following command creates a mirrored logical volume with a region size of 2MB:
# lvcreate -m1 -L 2T -R 2 -n mirror vol_group
When a mirror is created, the mirror regions are synchronized. For large mirror components, the sync process may take a long time. As of the Red Hat Enterprise Linux 6.3 release, When you are creating a new mirror that does not need to be revived, you can specify the --nosync argument to indicate that an initial synchronization from the first device is not required.
LVM maintains a small log which it uses to keep track of which regions are in sync with the mirror or mirrors. By default, this log is kept on disk, which keeps it persistent across reboots and ensures that the mirror does not need to be re-synced every time a machine reboots or crashes. You can specify instead that this log be kept in memory with the --mirrorlog core argument; this eliminates the need for an extra log device, but it requires that the entire mirror be resynchronized at every reboot.
The following command creates a mirrored logical volume from the volume group bigvg. The logical volume is named ondiskmirvol and has a single mirror. The volume is 12MB in size and keeps the mirror log in memory.
# lvcreate -L 12MB -m1 --mirrorlog core -n ondiskmirvol bigvg  Logical volume "ondiskmirvol" created
The mirror log is created on a separate device from the devices on which any of the mirror legs are created. It is possible, however, to create the mirror log on the same device as one of the mirror legs by using the --alloc anywhere argument of the vgcreate command. This may degrade performance, but it allows you to create a mirror even if you have only two underlying devices.
The following command creates a mirrored logical volume with a single mirror for which the mirror log is on the same device as one of the mirror legs. In this example, the volume group vg0 consists of only two devices. This command creates a 500 MB volume named mirrorlv in the vg0 volume group.
# lvcreate -L 500M -m1 -n mirrorlv -alloc anywhere vg0

Note

With clustered mirrors, the mirror log management is completely the responsibility of the cluster node with the currently lowest cluster ID. Therefore, when the device holding the cluster mirror log becomes unavailable on a subset of the cluster, the clustered mirror can continue operating without any impact, as long as the cluster node with lowest ID retains access to the mirror log. Since the mirror is undisturbed, no automatic corrective action (repair) is issued, either. When the lowest-ID cluster node loses access to the mirror log, however, automatic action will kick in (regardless of accessibility of the log from other nodes).
To create a mirror log that is itself mirrored, you can specify the --mirrorlog mirrored argument. The following command creates a mirrored logical volume from the volume group bigvg. The logical volume is named twologvol and has a single mirror. The volume is 12MB in size and the mirror log is mirrored, with each log kept on a separate device.
# lvcreate -L 12MB -m1 --mirrorlog mirrored -n twologvol bigvg  Logical volume "twologvol" created
Just as with a standard mirror log, it is possible to create the redundant mirror logs on the same device as the mirror legs by using the --alloc anywhere argument of the vgcreate command. This may degrade performance, but it allows you to create a redundant mirror log even if you do not have sufficient underlying devices for each log to be kept on a separate device than the mirror legs.
When a mirror is created, the mirror regions are synchronized. For large mirror components, the sync process may take a long time. When you are creating a new mirror that does not need to be revived, you can specify the --nosync argument to indicate that an initial synchronization from the first device is not required.
You can specify which devices to use for the mirror legs and log, and which extents of the devices to use. To force the log onto a particular disk, specify exactly one extent on the disk on which it will be placed. LVM does not necessary respect the order in which devices are listed in the command line. If any physical volumes are listed that is the only space on which allocation will take place. Any physical extents included in the list that are already allocated will get ignored.
The following command creates a mirrored logical volume with a single mirror and a single log that is not mirrored. The volume is 500 MB in size, it is named mirrorlv, and it is carved out of volume group vg0. The first leg of the mirror is on device /dev/sda1, the second leg of the mirror is on device /dev/sdb1, and the mirror log is on /dev/sdc1.
# lvcreate -L 500M -m1 -n mirrorlv vg0 /dev/sda1 /dev/sdb1 /dev/sdc1
The following command creates a mirrored logical volume with a single mirror. The volume is 500 MB in size, it is named mirrorlv, and it is carved out of volume group vg0. The first leg of the mirror is on extents 0 through 499 of device /dev/sda1, the second leg of the mirror is on extents 0 through 499 of device /dev/sdb1, and the mirror log starts on extent 0 of device /dev/sdc1. These are 1MB extents. If any of the specified extents have already been allocated, they will be ignored.
# lvcreate -L 500M -m1 -n mirrorlv vg0 /dev/sda1:0-499 /dev/sdb1:0-499 /dev/sdc1:0

Note

As of the Red Hat Enterprise Linux 6.1 release, you can combine striping and mirroring in a single logical volume. Creating a logical volume while simultaneously specifying the number of mirrors (--mirrors X) and the number of stripes (--stripes Y) results in a mirror device whose constituent devices are striped.

4.4.3.1. Mirrored Logical Volume Failure Policy

You can define how a mirrored logical volume behaves in the event of a device failure with the mirror_image_fault_policy and mirror_log_fault_policy parameters in the activation section of the lvm.conf file. When these parameters are set to remove, the system attempts to remove the faulty device and run without it. When this parameter is set to allocate, the system attempts to remove the faulty device and tries to allocate space on a new device to be a replacement for the failed device; this policy acts like the remove policy if no suitable device and space can be allocated for the replacement.
By default, the mirror_log_fault_policy parameter is set to allocate. Using this policy for the log is fast and maintains the ability to remember the sync state through crashes and reboots. If you set this policy to remove, when a log device fails the mirror converts to using an in-memory log and the mirror will not remember its sync status across crashes and reboots and the entire mirror will be re-synced.
By default, the mirror_image_fault_policy parameter is set to remove. With this policy, if a mirror image fails the mirror will convert to a non-mirrored device if there is only one remaining good copy. Setting this policy to allocate for a mirror device requires the mirror to resynchronize the devices; this is a slow process, but it preserves the mirror characteristic of the device.

Note

When an LVM mirror suffers a device failure, a two-stage recovery takes place. The first stage involves removing the failed devices. This can result in the mirror being reduced to a linear device. The second stage, if the mirror_log_fault_policy parameter is set to allocate, is to attempt to replace any of the failed devices. Note, however, that there is no guarantee that the second stage will choose devices previously in-use by the mirror that had not been part of the failure if others are available.
For information on manually recovering from an LVM mirror failure, refer to Section 6.3, "Recovering from LVM Mirror Failure".

4.4.3.2. Splitting Off a Redundant Image of a Mirrored Logical Volume

You can split off a redundant image of a mirrored logical volume to form a new logical volume. To split off an image, you use the --splitmirrors argument of the lvconvert command, specifying the number of redundant images to split off. You must use the --name argument of the command to specify a name for the newly-split-off logical volume.
The following command splits off a new logical volume named copy from the mirrored logical volume vg/lv. The new logical volume contains two mirror legs. In this example, LVM selects which devices to split off.
# lvconvert --splitmirrors 2 --name copy vg/lv
You can specify which devices to split off. The following command splits off a new logical volume named copy from the mirrored logical volume vg/lv. The new logical volume contains two mirror legs consisting of devices /dev/sdc1 and /dev/sde1.
# lvconvert --splitmirrors 2 --name copy vg/lv /dev/sd[ce]1

4.4.3.3. Repairing a Mirrored Logical Device

You can use the lvconvert --repair command to repair a mirror after a disk failure. This brings the mirror back into a consistent state. The lvconvert --repair command is an interactive command that prompts you to indicate whether you want the system to attempt to replace any failed devices.
  • To skip the prompts and replace all of the failed devices, specify the -y option on the command line.
  • To skip the prompts and replace none of the failed devices, specify the -f option on the command line.
  • To skip the prompts and still indicate different replacement policies for the mirror image and the mirror log, you can specify the --use-policies argument to use the device replacement policies specified by the mirror_log_fault_policy and mirror_device_fault_policy parameters in the lvm.conf file.

4.4.3.4. Changing Mirrored Volume Configuration

You can increase or decrease the number of mirrors that a logical volume contains by using the lvconvert command. This allows you to convert a logical volume from a mirrored volume to a linear volume or from a linear volume to a mirrored volume. You can also use this command to reconfigure other mirror parameters of an existing logical volume, such as corelog.
When you convert a linear volume to a mirrored volume, you are basically creating mirror legs for an existing volume. This means that your volume group must contain the devices and space for the mirror legs and for the mirror log.
If you lose a leg of a mirror, LVM converts the volume to a linear volume so that you still have access to the volume, without the mirror redundancy. After you replace the leg, you can use the lvconvert command to restore the mirror. This procedure is provided in Section 6.3, "Recovering from LVM Mirror Failure".
The following command converts the linear logical volume vg00/lvol1 to a mirrored logical volume.
# lvconvert -m1 vg00/lvol1
The following command converts the mirrored logical volume vg00/lvol1 to a linear logical volume, removing the mirror leg.
# lvconvert -m0 vg00/lvol1
The following example adds an additional mirror leg to the existing logical volume vg00/lvol1. This example shows the configuration of the volume before and after the lvconvert command changed the volume to a volume with two mirror legs.
# lvs -a -o name,copy_percent,devices vg00  LV  Copy%  Devices  lvol1   100.00 lvol1_mimage_0(0),lvol1_mimage_1(0)  [lvol1_mimage_0] /dev/sda1(0)  [lvol1_mimage_1] /dev/sdb1(0)  [lvol1_mlog] /dev/sdd1(0)# lvconvert -m 2 vg00/lvol1  vg00/lvol1: Converted: 13.0%  vg00/lvol1: Converted: 100.0%  Logical volume lvol1 converted.# lvs -a -o name,copy_percent,devices vg00  LV  Copy%  Devices  lvol1   100.00 lvol1_mimage_0(0),lvol1_mimage_1(0),lvol1_mimage_2(0)  [lvol1_mimage_0] /dev/sda1(0)  [lvol1_mimage_1] /dev/sdb1(0)  [lvol1_mimage_2] /dev/sdc1(0)  [lvol1_mlog] /dev/sdd1(0)

4.4.4. Creating Thinly-Provisioned Logical Volumes

As of the Red Hat Enterprise Linux 6.4 release, logical volumes can be thinly provisioned. This allows you to create logical volumes that are larger than the available extents. Using thin provisioning, you can manage a storage pool of free space, known as a thin pool, to be allocated to an arbitrary number of devices when needed by applications. You can then create devices that can be bound to the thin pool for later allocation when an application actually writes to the logical volume. The thin pool can be expanded dynamically when needed for cost-effective allocation of storage space.

Note

Thin volumes are not supported across the nodes in a cluster. The thin pool and all its thin volumes must be exclusively activated on only one cluster node.
To create a thin volume, you perform the following tasks:
  1. Create a volume group with the vgcreate command.
  2. Create a thin pool with the lvcreate command.
  3. Create a thin volume in the thin pool with the lvcreate command.
You can use the -T (or --thin) option of the lvcreate command to create either a thin pool or a thin volume. You can also use -T option of the lvcreate command to create both a thin pool and a thin volume in that pool at the same time with a single command.
The following command uses the -T option of the lvcreate command to create a thin pool named mythinpool that is in the volume group vg001 and that is 100M in size. Note that since you are creating a pool of physical space, you must specify the size of the pool. The -T option of the lvcreate command does not take an argument; it deduces what type of device is to be created from the other options the command specifies.
# lvcreate -L 100M -T vg001/mythinpool  Rounding up size to full physical extent 4.00 MiB  Logical volume "mythinpool" created# lvs  LV VG Attr LSize   Pool Origin Data%  Move Log Copy% Convert  my mythinpool vg001  twi-a-tz 100.00m   0.00
The following command uses the -T option of the lvcreate command to create a thin volume named thinvolume in the thin pool vg001/mythinpool. Note that in this case you are specifying virtual size, and that you are specifying a virtual size for the volume that is greater than the pool that contains it.
# lvcreate -V1G -T vg001/mythinpool -n thinvolume  Logical volume "thinvolume" created# lvs  LV  VG   Attr LSize   Pool   Origin Data%  Move Log Copy%  Convert  mythinpool  vg001 twi-a-tz 100.00m 0.00  thinvolume  vg001 Vwi-a-tz   1.00g mythinpool  0.00
The following command uses the -T option of the lvcreate command to create a thin pool and a thin volume in that pool by specifying both a size and a virtual size argument for the lvcreate command. This command creates a thin pool named mythinpool in the volume group vg001 and it also creates a thin volume named thinvolume in that pool.
# lvcreate -L 100M -T vg001/mythinpool -V1G -n thinvolume  Rounding up size to full physical extent 4.00 MiB  Logical volume "thinvolume" created# lvs  LV   VG   Attr LSize   Pool Origin Data%  Move Log Copy%  Convert  mythinpool   vg001 twi-a-tz 100.00m   0.00  thinvolume   vg001 Vwi-a-tz   1.00g mythinpool 0.00
You can also create a thin pool by specifying the --thinpool parameter of the lvcreate command. Unlike the -T option, the --thinpool parameter requires an argument, which is the name of the thin pool logical volume that you are creating. The following example specifies the --thinpool parameter of the lvcreate command to create a thin pool named mythinpool that is in the volume group vg001 and that is 100M in size:
# lvcreate -L100M --thinpool mythinpool vg001  Rounding up size to full physical extent 4.00 MiB  Logical volume "mythinpool" created# lvs  LV  VG Attr LSize   Pool Origin Data%  Move Log Copy% Convert  mythinpool  vg001  twi-a-tz 100.00m   0.00
Striping is supported for pool creation. The following command creates a 100M thin pool named pool in volume group vg001 with two 64 kB stripes and a chunk size of 256 kB. It also creates a 1T thin volume, vg00/thin_lv.
# lvcreate -i 2 -I 64 -c 256 -L100M -T vg00/pool -V 1T --name thin_lv
You can extend the size of a thin volume with the lvextend command. You cannot, however, reduce the size of a thin pool.
The following command resizes an existing thin pool that is 100M in size by extending it another 100M.
# lvextend -L+100M vg001/mythinpool  Extending logical volume mythinpool to 200.00 MiB  Logical volume mythinpool successfully resized# lvs  LV   VG   Attr LSize   Pool Origin Data%  Move Log Copy%  Convert  mythinpool   vg001 twi-a-tz 200.00m   0.00  thinvolume   vg001 Vwi-a-tz   1.00g mythinpool  0.00
As with other types of logical volumes, you can rename the volume with the lvrename, you can remove the volume with the lvremove, and you can display information about the volume with the lvs and lvdisplay commands.
By default, the lvcreate sets the size of the thin pool's metadata logical volume according to the formula (Pool_LV_size / Pool_LV_chunk_size * 64b). You cannot currently resize the metadata volume, however, so if you expect significant growth of the size of thin pool at a later time you should increase this value with the --poolmetasize parameter of the lvcreate command. The supported value for the thin pool's metadata logical volume is in the range between 2MiB and 16GiB.
You can use the --thinpool parameter of the lvconvert command to convert an existing logical volume to a thin volume. When you convert an existing logical volume to a thin volume, you must use the --poolmetadata parameter in conjunction with the --thinpool parameter of the lvconvert to convert an existing logical volume to the thin volume's metadata volume.
The following example converts the existing logical volume lv1 in volume group vg001 to a thin volume and converts the existing logical volume lv2 in volume group vg001 to the metadata volume for that thin volume.
# lvconvert --thinpool vg001/lv1 --poolmetadata vg001/lv2  Converted vg001/lv1 to thin pool.

4.4.5. Creating Snapshot Volumes

Note

As of the Red Hat Enterprise Linux 6.4 release, LVM supports thinly-provisioned snapshots. For information on creating thinly provisioned snapshot volumes, refer to Section 4.4.6, "Creating Thinly-Provisioned Snapshot Volumes".
Use the -s argument of the lvcreate command to create a snapshot volume. A snapshot volume is writable.

Note

LVM snapshots are not supported across the nodes in a cluster. You cannot create a snapshot volume in a clustered volume group. As of the Red Hat Enterprise Linux 6.1 release, however, if you need to create a consistent backup of data on a clustered logical volume you can activate the volume exclusively and then create the snapshot. For information on activating logical volumes exclusively on one node, see Section 4.7, "Activating Logical Volumes on Individual Nodes in a Cluster".

Note

As of the Red Hat Enterprise Linux 6.1 release, LVM snapshots are supported for mirrored logical volumes.
As of the Red Hat Enterprise Linux 6.3 release, snapshots are supported for RAID logical volumes. For information on RAID logical volumes, refer to Section 4.4.15, "RAID Logical Volumes".
The following command creates a snapshot logical volume that is 100 MB in size named /dev/vg00/snap. This creates a snapshot of the origin logical volume named /dev/vg00/lvol1. If the original logical volume contains a file system, you can mount the snapshot logical volume on an arbitrary directory in order to access the contents of the file system to run a backup while the original file system continues to get updated.
# lvcreate --size 100M --snapshot --name snap /dev/vg00/lvol1
After you create a snapshot logical volume, specifying the origin volume on the lvdisplay command yields output that includes a list of all snapshot logical volumes and their status (active or inactive).
The following example shows the status of the logical volume /dev/new_vg/lvol0, for which a snapshot volume /dev/new_vg/newvgsnap has been created.
# lvdisplay /dev/new_vg/lvol0  --- Logical volume ---  LV Name /dev/new_vg/lvol0  VG Name new_vg  LV UUID LBy1Tz-sr23-OjsI-LT03-nHLC-y8XW-EhCl78  LV Write Access read/write  LV snapshot status source of /dev/new_vg/newvgsnap1 [active]  LV Status  available  # open 0  LV Size 52.00 MB  Current LE 13  Segments   1  Allocation inherit  Read ahead sectors 0  Block device   253:2
The lvs command, by default, displays the origin volume and the current percentage of the snapshot volume being used for each snapshot volume. The following example shows the default output for the lvs command for a system that includes the logical volume /dev/new_vg/lvol0, for which a snapshot volume /dev/new_vg/newvgsnap has been created.
# lvs  LV VG Attr   LSize  Origin Snap%  Move Log Copy%  lvol0  new_vg owi-a- 52.00M  newvgsnap1 new_vg swi-a-  8.00M lvol0 0.20

Warning

Because the snapshot increases in size as the origin volume changes, it is important to monitor the percentage of the snapshot volume regularly with the lvs command to be sure it does not fill. A snapshot that is 100% full is lost completely, as a write to unchanged parts of the origin would be unable to succeed without corrupting the snapshot.
As of the Red Hat Enterprise Linux 6.2 release, there are two new features related to snapshots. First, in addition to the snapshot itself being invalidated when full, any mounted file systems on that snapshot device are forcibly unmounted, avoiding the inevitable file system errors upon access to the mount point. Second, you can specify the snapshot_autoextend_threshold option in the lvm.conf file. This option allows automatic extension of a snapshot whenever the remaining snapshot space drops below the threshold you set. This feature requires that there be unallocated space in the volume group.
Information on setting snapshot_autoextend_threshold and snapshot_autoextend_percent is provided in the lvm.conf file itself. For information about the lvm.conf file, refer to Appendix B, The LVM Configuration Files.

4.4.6. Creating Thinly-Provisioned Snapshot Volumes

The Red Hat Enterprise Linux release 6.4 version of LVM provides support for thinly-provisioned snapshot volumes. For information on the benefits and limitations of thin snapshot volumes, refer to Section 2.3.6, "Thinly-Provisioned Snapshot Volumes".

Important

When creating a thin snapshot volume, you do not specify the size of the volume. If you specify a size parameter, the snapshot that will be created will not be a thin snapshot volume and will not use the thin pool for storing data. For example, the command lvcreate -s vg/thinvolume -L10M will not create a thin snapshot, even though the origin volume is a thin volume.
To create a thin snapshot volume, you must create the origin volume as a thin volume, as described in Section 4.4.4, "Creating Thinly-Provisioned Logical Volumes".
The following command creates a thin snapshot volume of the thin volume vg001/thinvolume.
# lvcreate -s vg001/thinvolume  Logical volume "lvol0" created# lvs  LV VG   Attr LSize   Pool   Origin Data%  Move Log Copy%  Convert  lvol0  vg001 Vwi-a-tz   1.00g mythinpool thinvolume   0.00  mythinpool vg001 twi-a-tz 100.00m 0.00  thinvolume vg001 Vwi-a-tz   1.00g mythinpool  0.00
You can specify a name for the snapshot volume with the --name option of the lvcreate command. The following command creates a thinly-provisioned snapshot volume of the thinly-provisioned logical volume vg001/thinvolume that is named mysnapshot1.
# lvcreate -s --name mysnapshot1 vg001/thinvolume  Logical volume "mysnapshot1" created# lvs  LV  VG   Attr LSize   Pool   Origin Data%  Move Log Copy%  Convert  mysnapshot1 vg001 Vwi-a-tz   1.00g mythinpool thinvolume   0.00  mythinpool  vg001 twi-a-tz 100.00m 0.00  thinvolume  vg001 Vwi-a-tz   1.00g mythinpool  0.00
A thin snapshot volume has the same characteristics as any other thin volume. You can independently activate the volume, extend the volume, rename the volume, remove the volume, and even snapshot the volume.

4.4.7. Merging Snapshot Volumes

As of the Red Hat Enterprise Linux 6 release, you can use the --merge option of the lvconvert command to merge a snapshot into its origin volume. If both the origin and snapshot volume are not open, the merge will start immediately. Otherwise, the merge will start the first time either the origin or snapshot are activated and both are closed. Merging a snapshot into an origin that cannot be closed, for example a root file system, is deferred until the next time the origin volume is activated. When merging starts, the resulting logical volume will have the origin�s name, minor number and UUID. While the merge is in progress, reads or writes to the origin appear as they were directed to the snapshot being merged. When the merge finishes, the merged snapshot is removed.
The following command merges snapshot volume vg00/lvol1_snap into its origin.
# lvconvert --merge vg00/lvol1_snap
You can specify multiple snapshots on the command line, or you can use LVM object tags to specify that multiple snapshots be merged to their respective origins. In the following example, logical volumes vg00/lvol1, vg00/lvol2, and vg00/lvol3 are all tagged with the tag @some_tag. The following command merges the snapshot logical volumes for all three volumes serially: vg00/lvol1, then vg00/lvol2, then vg00/lvol3. If the --background option were used, all snapshot logical volume merges would start in parallel.
# lvconvert --merge @some_tag
For information on tagging LVM objects, see Appendix C, LVM Object Tags. For further information on the lvconvert --merge command, see the lvconvert(8) man page.

4.4.8. Persistent Device Numbers

Major and minor device numbers are allocated dynamically at module load. Some applications work best if the block device always is activated with the same device (major and minor) number. You can specify these with the lvcreate and the lvchange commands by using the following arguments:
--persistent y --major major --minor minor
Use a large minor number to be sure that it has not already been allocated to another device dynamically.
If you are exporting a file system using NFS, specifying the fsid parameter in the exports file may avoid the need to set a persistent device number within LVM.

4.4.9. Resizing Logical Volumes

To reduce the size of a logical volume, use the lvreduce command. If the logical volume contains a file system, be sure to reduce the file system first (or use the LVM GUI) so that the logical volume is always at least as large as the file system expects it to be.
The following command reduces the size of logical volume lvol1 in volume group vg00 by 3 logical extents.
# lvreduce -l -3 vg00/lvol1

4.4.10. Changing the Parameters of a Logical Volume Group

To change the parameters of a logical volume, use the lvchange command. For a listing of the parameters you can change, see the lvchange(8) man page.
You can use the lvchange command to activate and deactivate logical volumes. To activate and deactivate all the logical volumes in a volume group at the same time, use the vgchange command, as described in Section 4.3.8, "Changing the Parameters of a Volume Group".
The following command changes the permission on volume lvol1 in volume group vg00 to be read-only.
# lvchange -pr vg00/lvol1

4.4.11. Renaming Logical Volumes

To rename an existing logical volume, use the lvrename command.
Either of the following commands renames logical volume lvold in volume group vg02 to lvnew.
# lvrename /dev/vg02/lvold /dev/vg02/lvnew
# lvrename vg02 lvold lvnew
For more information on activating logical volumes on individual nodes in a cluster, see Section 4.7, "Activating Logical Volumes on Individual Nodes in a Cluster".

4.4.12. Removing Logical Volumes

To remove an inactive logical volume, use the lvremove command. If the logical volume is currently mounted, unmount the volume before removing it. In addition, in a clustered environment you must deactivate a logical volume before it can be removed.
The following command removes the logical volume /dev/testvg/testlv from the volume group testvg. Note that in this case the logical volume has not been deactivated.
# lvremove /dev/testvg/testlvDo you really want to remove active logical volume "testlv"? [y/n]: y  Logical volume "testlv" successfully removed
You could explicitly deactivate the logical volume before removing it with the lvchange -an command, in which case you would not see the prompt verifying whether you want to remove an active logical volume.

4.4.13. Displaying Logical Volumes

There are three commands you can use to display properties of LVM logical volumes: lvs, lvdisplay, and lvscan.
The lvs command provides logical volume information in a configurable form, displaying one line per logical volume. The lvs command provides a great deal of format control, and is useful for scripting. For information on using the lvs command to customize your output, see Section 4.8, "Customized Reporting for LVM".
The lvdisplay command displays logical volume properties (such as size, layout, and mapping) in a fixed format.
The following command shows the attributes of lvol2 in vg00. If snapshot logical volumes have been created for this original logical volume, this command shows a list of all snapshot logical volumes and their status (active or inactive) as well.
# lvdisplay -v /dev/vg00/lvol2
The lvscan command scans for all logical volumes in the system and lists them, as in the following example.
# lvscan ACTIVE   '/dev/vg0/gfslv' [1.46 GB] inherit

4.4.14. Growing Logical Volumes

To increase the size of a logical volume, use the lvextend command.
When you extend the logical volume, you can indicate how much you want to extend the volume, or how large you want it to be after you extend it.
The following command extends the logical volume /dev/myvg/homevol to 12 gigabytes.
# lvextend -L12G /dev/myvg/homevol lvextend -- extending logical volume "/dev/myvg/homevol" to 12 GBlvextend -- doing automatic backup of volume group "myvg"lvextend -- logical volume "/dev/myvg/homevol" successfully extended
The following command adds another gigabyte to the logical volume /dev/myvg/homevol.
# lvextend -L+1G /dev/myvg/homevollvextend -- extending logical volume "/dev/myvg/homevol" to 13 GBlvextend -- doing automatic backup of volume group "myvg"lvextend -- logical volume "/dev/myvg/homevol" successfully extended
As with the lvcreate command, you can use the -l argument of the lvextend command to specify the number of extents by which to increase the size of the logical volume. You can also use this argument to specify a percentage of the volume group, or a percentage of the remaining free space in the volume group. The following command extends the logical volume called testlv to fill all of the unallocated space in the volume group myvg.
# lvextend -l +100%FREE /dev/myvg/testlv  Extending logical volume testlv to 68.59 GB  Logical volume testlv successfully resized
After you have extended the logical volume it is necessary to increase the file system size to match.
By default, most file system resizing tools will increase the size of the file system to be the size of the underlying logical volume so you do not need to worry about specifying the same size for each of the two commands.

4.4.14.1. Extending a Striped Volume

In order to increase the size of a striped logical volume, there must be enough free space on the underlying physical volumes that make up the volume group to support the stripe. For example, if you have a two-way stripe that that uses up an entire volume group, adding a single physical volume to the volume group will not enable you to extend the stripe. Instead, you must add at least two physical volumes to the volume group.
For example, consider a volume group vg that consists of two underlying physical volumes, as displayed with the following vgs command.
# vgs  VG   #PV #LV #SN Attr   VSize   VFree  vg 2   0   0 wz--n- 271.31G 271.31G
You can create a stripe using the entire amount of space in the volume group.
# lvcreate -n stripe1 -L 271.31G -i 2 vg  Using default stripesize 64.00 KB  Rounding up size to full physical extent 271.31 GB  Logical volume "stripe1" created# lvs -a -o +devices  LV  VG   Attr   LSize   Origin Snap%  Move Log Copy%  Devices  stripe1 vg   -wi-a- 271.31G   /dev/sda1(0),/dev/sdb1(0)
Note that the volume group now has no more free space.
# vgs  VG   #PV #LV #SN Attr   VSize   VFree  vg 2   1   0 wz--n- 271.31G 0
The following command adds another physical volume to the volume group, which then has 135G of additional space.
# vgextend vg /dev/sdc1  Volume group "vg" successfully extended# vgs  VG   #PV #LV #SN Attr   VSize   VFree  vg 3   1   0 wz--n- 406.97G 135.66G
At this point you cannot extend the striped logical volume to the full size of the volume group, because two underlying devices are needed in order to stripe the data.
# lvextend vg/stripe1 -L 406G  Using stripesize of last segment 64.00 KB  Extending logical volume stripe1 to 406.00 GB  Insufficient suitable allocatable extents for logical volume stripe1: 34480 more required
To extend the striped logical volume, add another physical volume and then extend the logical volume. In this example, having added two physical volumes to the volume group we can extend the logical volume to the full size of the volume group.
# vgextend vg /dev/sdd1  Volume group "vg" successfully extended# vgs  VG   #PV #LV #SN Attr   VSize   VFree  vg 4   1   0 wz--n- 542.62G 271.31G# lvextend vg/stripe1 -L 542G  Using stripesize of last segment 64.00 KB  Extending logical volume stripe1 to 542.00 GB  Logical volume stripe1 successfully resized
If you do not have enough underlying physical devices to extend the striped logical volume, it is possible to extend the volume anyway if it does not matter that the extension is not striped, which may result in uneven performance. When adding space to the logical volume, the default operation is to use the same striping parameters of the last segment of the existing logical volume, but you can override those parameters. The following example extends the existing striped logical volume to use the remaining free space after the initial lvextend command fails.
# lvextend vg/stripe1 -L 406G  Using stripesize of last segment 64.00 KB  Extending logical volume stripe1 to 406.00 GB  Insufficient suitable allocatable extents for logical volume stripe1: 34480 more required# lvextend -i1 -l+100%FREE vg/stripe1

4.4.14.2. Extending a Mirrored Volume

As of the Red Hat Enterprise Linux 6.3 release, it is possible to grow mirrored logical volumes with the lvextend command without performing a synchronization of the new mirror regions.
If you specify the --nosync option when you create a mirrored logical volume with the lvcreate command, the mirror regions are not synchronized when the mirror is created, as described in Section 4.4.3, "Creating Mirrored Volumes". If you later extend a mirror that you have created with the --nosync option, the mirror extensions are not synchronized at that time, either.
You can determine whether an existing logical volume was created with the --nosync option by using the lvs command to display the volume's attributes. A logical volume will have an attribute bit 1 of "M" if it is a mirrored volume that was created without an initial synchronization, and it will have an attribute bit 1 of "m" if it was created with initial synchronization.
The following command displays the attributes of a mirrored logical volume named lv that was created without initial synchronization, showing attribute bit 1 as "M". Attribute bit 7 is "m", indicating a target type of mirror. For information on the meaning of the attribute bits, refer to Table 4.4, "lvs Display Fields".
# lvs vg  LV   VG   Attr LSize Pool Origin Snap%  Move Log Copy%  Convert  lv   vg   Mwi-a-m- 5.00g lv_mlog 100.00
If you grow this mirrored logical volume with the lvextend command, the mirror extension will not be resynchronized.
If you created a mirrored logical volume without specifying the --nosync option of the lvcreate command, you can grow the logical volume without resynchronizing the mirror by specifying the --nosync option of the lvextend command.
The following example extends a logical volume that was created without the --nosync option, indicated that the mirror was synchronized when it was created. This example, however, specifies that the mirror not be synchronized when the volume is extended. Note that the volume has an attribute of "m", but after executing the lvextend commmand with the --nosync option the volume has an attribute of "M".
# lvs vg  LV   VG   Attr LSize  Pool Origin Snap%  Move Log Copy%  Convert  lv   vg   mwi-a-m- 20.00m lv_mlog 100.00 # lvextend -L +5G vg/lv --nosync  Extending 2 mirror images.  Extending logical volume lv to 5.02 GiB  Logical volume lv successfully resized# lvs vg  LV   VG   Attr LSize Pool Origin Snap%  Move Log Copy%  Convert  lv   vg   Mwi-a-m- 5.02g lv_mlog 100.00
If a mirror is inactive, it will not automatically skip synchronization when you extend the mirror, even if you create the mirror with the --nosync option specified. Instead, you will be prompted whether to do a full resync of the extended portion of the logical volume.

Note

If a mirror is performing recovery, you cannot extend the mirrored logical volume if you created or extended the volume with the --nosync option specified. If you did not specify the --nosync option, however, you can extend the mirror while it is recovering.

4.4.14.3. Extending a Logical Volume with the cling Allocation Policy

When extending an LVM volume, you can use the --alloc cling option of the lvextend command to specify the cling allocation policy. This policy will choose space on the same physical volumes as the last segment of the existing logical volume. If there is insufficient space on the physical volumes and a list of tags is defined in the lvm.conf file, LVM will check whether any of the tags are attached to the physical volumes and seek to match those physical volume tags between existing extents and new extents.
For example, if you have logical volumes that are mirrored between two sites within a single volume group, you can tag the physical volumes according to where they are situated by tagging the physical volumes with @site1 and @site2 tags and specify the following line in the lvm.conf file:
cling_tag_list = [ "@site1", "@site2" ]
For information on tagging physical volumes, see Appendix C, LVM Object Tags.
In the following example, the lvm.conf file has been modified to contain the following line:
cling_tag_list = [ "@A", "@B" ]
Also in this example, a volume group taft has been created that consists of the physical volumes /dev/sdb1, /dev/sdc1, /dev/sdd1, /dev/sde1, /dev/sdf1, /dev/sdg1, and /dev/sdh1. These physical volumes have been tagged with tags A, B, and C. The example does not use the C tag, but this will show that LVM uses the tags to select which physical volumes to use for the mirror legs.
# pvs -a -o +pv_tags /dev/sd[bcdefgh]1  PV VG   Fmt  Attr PSize   PFree   PV Tags  /dev/sdb1  taft lvm2 a-   135.66g 135.66g A  /dev/sdc1  taft lvm2 a-   135.66g 135.66g B  /dev/sdd1  taft lvm2 a-   135.66g 135.66g B  /dev/sde1  taft lvm2 a-   135.66g 135.66g C  /dev/sdf1  taft lvm2 a-   135.66g 135.66g C  /dev/sdg1  taft lvm2 a-   135.66g 135.66g A  /dev/sdh1  taft lvm2 a-   135.66g 135.66g A
The following command creates a 100GB mirrored volume from the volume group taft.
# lvcreate -m 1 -n mirror --nosync -L 100G taft
The following command shows which devices are used for the mirror legs and mirror log.
# lvs -a -o +devices  LV VG Attr   LSize   Log Copy%  Devices  mirror taft  Mwi-a- 100.00g mirror_mlog 100.00mirror_mimage_0(0),mirror_mimage_1(0)  [mirror_mimage_0] taft  iwi-ao 100.00g /dev/sdb1(0)  [mirror_mimage_1] taft  iwi-ao 100.00g /dev/sdc1(0)  [mirror_mlog] taft  lwi-ao   4.00m /dev/sdh1(0)
The following command extends the size of the mirrored volume, using the cling allocation policy to indicate that the mirror legs should be extended using physical volumes with the same tag.
# lvextend --alloc cling -L +100G taft/mirror  Extending 2 mirror images.  Extending logical volume mirror to 200.00 GiB  Logical volume mirror successfully resized
The following display command shows that the mirror legs have been extended using physical volumes with the same tag as the leg. Note that the physical volumes with a tag of C were ignored.
# lvs -a -o +devices  LV VG Attr   LSize   Log Copy%  Devices  mirror taft  Mwi-a- 200.00g mirror_mlog  50.16mirror_mimage_0(0),mirror_mimage_1(0)  [mirror_mimage_0] taft  Iwi-ao 200.00g /dev/sdb1(0)  [mirror_mimage_0] taft  Iwi-ao 200.00g /dev/sdg1(0)  [mirror_mimage_1] taft  Iwi-ao 200.00g /dev/sdc1(0)  [mirror_mimage_1] taft  Iwi-ao 200.00g /dev/sdd1(0)  [mirror_mlog] taft  lwi-ao   4.00m /dev/sdh1(0)

4.4.15. RAID Logical Volumes

As of the Red Hat Enterprise Linux 6.3 release, LVM supports RAID4/5/6 and a new implementation of mirroring. The latest implementation of mirroring differs from the previous implementation of mirroring (documented in Section 4.4.3, "Creating Mirrored Volumes") in the following ways:
  • The segment type for the new implementation of mirroring is raid1. For the earlier implementation, the segment type is mirror.
  • The new implementation of mirroring leverages MD software RAID, just as for the RAID 4/5/6 implementations.
  • The new implementation of mirroring maintains a fully redundant bitmap area for each mirror image, which increases its fault handling capabilities. This means that there is no --mirrorlog option or --corelog option for mirrors created with this segment type.
  • The new implementation of mirroring can handle transient failures.
  • Mirror images can be temporarily split from the array and merged back into the array later.
  • The new implementation of mirroring supports snapshots (as do the higher-level RAID implementations).
  • The new RAID implementations are not cluster-aware. You cannot create an LVM RAID logical volume in a clustered volume group.
For information on how failures are handled by the RAID logical volumes, refer to Section 4.4.15.8, "Setting a RAID fault policy".
The remainder of this section describes the following administrative tasks you can perform on LVM RAID devices:

4.4.15.1. Creating a RAID Logical Volume

To create a RAID logical volume, you specify a raid type as the --type argument of the lvcreate command. Usually when you create a logical volume with the lvcreate command, the --type argument is implicit. For example, when you specify the -i stripes argument, the lvcreate command assumes the --type stripe option. When you specify the -m mirrors argument, the lvcreate command assumes the --type mirror option. When you create a RAID logical volume, however, you must explicitly specify the segment type you desire. The possible RAID segment types are described in Table 4.1, "RAID Segment Types".

Table 4.1. RAID Segment Types

Segment typeDescription
raid1RAID1 mirroring
raid4RAID4 dedicated parity disk
raid5Same as raid5_ls
raid5_la
RAID5 left asymmetric.
Rotating parity 0 with data continuation
raid5_ra
RAID5 right asymmetric.
Rotating parity N with data continuation
raid5_ls
RAID5 left symmetric.
Rotating parity 0 with data restart
raid5_rs
RAID5 right symmetric.
Rotating parity N with data restart
raid6Same as raid6_zr
raid6_zr
RAID6 zero restart
Rotating parity zero (left-to-right) with data restart
raid6_nr
RAID6 N restart
Rotating parity N (left-to-right) with data restart
raid6_nc
RAID6 N continue
Rotating parity N (left-to-right) with data continuation
raid10 (Red Hat Enterprise Linux 6.4 and later
Striped mirrors
Striping of mirror sets

For most users, specifying one of the five available primary types (raid1, raid4, raid5, raid6, raid10) should be sufficient. For more information on the different algorithms used by RAID 5/6, refer to chapter four of the Common RAID Disk Data Format Specification at http://www.snia.org/sites/default/files/SNIA_DDF_Technical_Position_v2.0.pdf.
When you create a RAID logical volume, LVM creates a metadata subvolume that is one extent in size for every data or parity subvolume in the array. For example, creating a 2-way RAID1 array results in two metadata subvolumes (lv_rmeta_0 and lv_rmeta_1) and two data subvolumes (lv_rimage_0 and lv_rimage_1). Similarly, creating a 3-way stripe (plus 1 implicit parity device) RAID4 results in 4 metadata subvolumes (lv_rmeta_0, lv_rmeta_1, lv_rmeta_2, and lv_rmeta_3) and 4 data subvolumes (lv_rimage_0, lv_rimage_1, lv_rimage_2, and lv_rimage_3).
The following command creates a 2-way RAID1 array named my_lv in the volume group my_vg that is 1G in size.
# lvcreate --type raid1 -m 1 -L 1G -n my_lv my_vg
You can create RAID1 arrays with different numbers of copies according to the value you specify for the -m argument. Although the -m argument is the same argument used to specify the number of copies for the previous mirror implementation, in this case you override the default segment type mirror by explicitly setting the segment type as raid1. Similarly, you specify the number of stripes for a RAID 4/5/6 logical volume with the familiar -i argument, overriding the default segment type with the desired RAID type. You can also specify the stripe size with the -I argument.

Note

You can set the default mirror segment type to raid1 by changing mirror_segtype_default in the lvm.conf file.
The following command creates a RAID5 array (3 stripes + 1 implicit parity drive) named my_lv in the volume group my_vg that is 1G in size. Note that you specify the number of stripes just as you do for an LVM striped volume; the correct number of parity drives is added automatically.
# lvcreate --type raid5 -i 3 -L 1G -n my_lv my_vg
The following command creates a RAID6 array (3 stripes + 2 implicit parity drives) named my_lv in the volume group my_vg that is 1G in size.
# lvcreate --type raid6 -i 3 -L 1G -n my_lv my_vg
After you have created a RAID logical volume with LVM, you can activate, change, remove, display, and use the volume just as you would any other LVM logical volume.

4.4.15.2. Converting a Linear Device to a RAID Device

You can convert an existing linear logical volume to a RAID device by using the --type argument of the lvconvert command.
The following command converts the linear logical volume my_lv in volume group my_vg to a 2-way RAID1 array.
# lvconvert --type raid1 -m 1 my_vg/my_lv
Since RAID logical volumes are composed of metadata and data subvolume pairs, when you convert a linear device to a RAID1 array, a new metadata subvolume is created and associated with the original logical volume on (one of) the same physical volumes that the linear volume is on. The additional images are added in metadata/data subvolume pairs. For example, if the original device is as follows:
# lvs -a -o name,copy_percent,devices my_vg  LV Copy%  Devices   my_lv /dev/sde1(0)
After conversion to a 2-way RAID1 array the device contains the following data and metadata subvolume pairs:
# lvconvert --type raid1 -m 1 my_vg/my_lv# lvs -a -o name,copy_percent,devices my_vg  LV   Copy%  Devices my_lv 6.25   my_lv_rimage_0(0),my_lv_rimage_1(0)  [my_lv_rimage_0] /dev/sde1(0)   [my_lv_rimage_1] /dev/sdf1(1)   [my_lv_rmeta_0] /dev/sde1(256) [my_lv_rmeta_1] /dev/sdf1(0)
If the metadata image that pairs with the original logical volume cannot be placed on the same physical volume, the lvconvert will fail.

4.4.15.3. Converting an LVM RAID1 Logical Volume to an LVM Linear Logical Volume

You can convert an existing RAID1 LVM logical volume to an LVM linear logical volume with the lvconvert command by specifying the -m0 argument. This removes all the RAID data subvolumes and all the RAID metadata subvolumes that make up the RAID array, leaving the top-level RAID1 image as the linear logical volume.
The following example displays an existing LVM RAID1 logical volume.
# lvs -a -o name,copy_percent,devices my_vg  LV   Copy%  Devices my_lv 100.00 my_lv_rimage_0(0),my_lv_rimage_1(0)  [my_lv_rimage_0] /dev/sde1(1)   [my_lv_rimage_1] /dev/sdf1(1)   [my_lv_rmeta_0] /dev/sde1(0)   [my_lv_rmeta_1] /dev/sdf1(0)
The following command converts the LVM RAID1 logical volume my_vg/my_lv to an LVM linear device.
# lvconvert -m0 my_vg/my_lv# lvs -a -o name,copy_percent,devices my_vg  LV  Copy%  Devices   my_lv  /dev/sde1(1)
When you convert an LVM RAID1 logical volume to an LVM linear volume, you can specify which physical volumes to remove. The following example shows the layout of an LVM RAID1 logical volume made up of two images: /dev/sda1 and /dev/sda2. In this example, the lvconvert command specifies that you want to remove /dev/sda1, leaving /dev/sdb1 as the physical volume that makes up the linear device.
# lvs -a -o name,copy_percent,devices my_vg  LV   Copy%  Devices  my_lv 100.00 my_lv_rimage_0(0),my_lv_rimage_1(0)  [my_lv_rimage_0] /dev/sda1(1)  [my_lv_rimage_1] /dev/sdb1(1)  [my_lv_rmeta_0] /dev/sda1(0)  [my_lv_rmeta_1] /dev/sdb1(0)# lvconvert -m0 my_vg/my_lv /dev/sda1# lvs -a -o name,copy_percent,devices my_vg  LV Copy%  Devices  my_lv /dev/sdb1(1)

4.4.15.4. Converting a Mirrored LVM Device to a RAID1 Device

You can convert an existing mirrored LVM device to a RAID1 LVM device with the lvconvert command by specifying the --type raid1 argument. This renames the mirror subvolumes (*_mimage_*) to RAID subvolumes (*_rimage_*). In addition, the mirror log is removed and metadata subvolumes (*_rmeta_*) are created for the data subvolumes on the same physical volumes as the corresponding data subvolumes.
The following example shows the layout of a mirrored logical volume my_vg/my_lv.
# lvs -a -o name,copy_percent,devices my_vg  LV   Copy%  Devices my_lv 15.20 my_lv_mimage_0(0),my_lv_mimage_1(0)  [my_lv_mimage_0] /dev/sde1(0)   [my_lv_mimage_1] /dev/sdf1(0)   [my_lv_mlog] /dev/sdd1(0)
The following command converts the mirrored logical volume my_vg/my_lv to a RAID1 logical volume.
# lvconvert --type raid1 my_vg/my_lv# lvs -a -o name,copy_percent,devices my_vg  LV   Copy%  Devices my_lv 100.00 my_lv_rimage_0(0),my_lv_rimage_1(0)  [my_lv_rimage_0] /dev/sde1(0)   [my_lv_rimage_1] /dev/sdf1(0)   [my_lv_rmeta_0] /dev/sde1(125) [my_lv_rmeta_1] /dev/sdf1(125)

4.4.15.5. Changing the Number of Images in an Existing RAID1 Device

You can change the number of images in an existing RAID1 array just as you can change the number of images in the earlier implementation of LVM mirroring, by using the lvconvert command to specify the number of additional metadata/data subvolume pairs to add or remove. For information on changing the volume configuration in the earlier implementation of LVM mirroring, refer to Section 4.4.3.4, "Changing Mirrored Volume Configuration".
When you add images to a RAID1 device with the lvconvert command, you can specify the total number of images for the resulting device, or you can specify how many images to add to the device. You can also optionally specify on which physical volumes the new metadata/data image pairs will reside.
Metadata subvolumes (named *_rmeta_*) always exist on the same physical devices as their data subvolume counterparts *_rimage_*). The metadata/data subvolume pairs will not be created on the same physical volumes as those from another metadata/data subvolume pair in the RAID array (unless you specify --alloc anywhere).
The format for the command to add images to a RAID1 volume is as follows:
lvconvert -m new_absolute_count vg/lv [removable_PVs]lvconvert -m +num_additional_images vg/lv [removable_PVs]
For example, the following display shows the LVM device my_vg/my_lv which is a 2-way RAID1 array:
# lvs -a -o name,copy_percent,devices my_vg  LV Copy%  Devices my_lv 6.25 my_lv_rimage_0(0),my_lv_rimage_1(0)  [my_lv_rimage_0] /dev/sde1(0)   [my_lv_rimage_1] /dev/sdf1(1)   [my_lv_rmeta_0] /dev/sde1(256) [my_lv_rmeta_1] /dev/sdf1(0)
The following command converts the 2-way RAID1 device my_vg/my_lv to a 3-way RAID1 device:
# lvconvert -m 2 my_vg/my_lv# lvs -a -o name,copy_percent,devices my_vg  LV   Copy%  Devices   my_lv  6.25 my_lv_rimage_0(0),my_lv_rimage_1(0),my_lv_rimage_2(0)  [my_lv_rimage_0] /dev/sde1(0)  [my_lv_rimage_1] /dev/sdf1(1)  [my_lv_rimage_2] /dev/sdg1(1)  [my_lv_rmeta_0] /dev/sde1(256) [my_lv_rmeta_1] /dev/sdf1(0)  [my_lv_rmeta_2] /dev/sdg1(0)
When you add an image to a RAID1 array, you can specify which physical volumes to use for the image. The following command converts the 2-way RAID1 device my_vg/my_lv to a 3-way RAID1 device, specifying that the physical volume /dev/sdd1 be used for the array:
# lvs -a -o name,copy_percent,devices my_vg  LV   Copy%  Devices  my_lv 56.00 my_lv_rimage_0(0),my_lv_rimage_1(0)  [my_lv_rimage_0] /dev/sda1(1)  [my_lv_rimage_1] /dev/sdb1(1)  [my_lv_rmeta_0] /dev/sda1(0)  [my_lv_rmeta_1] /dev/sdb1(0)# lvconvert -m 2 my_vg/my_lv /dev/sdd1# lvs -a -o name,copy_percent,devices my_vg  LV   Copy%  Devices  my_lv 28.00 my_lv_rimage_0(0),my_lv_rimage_1(0),my_lv_rimage_2(0)  [my_lv_rimage_0] /dev/sda1(1)  [my_lv_rimage_1] /dev/sdb1(1)  [my_lv_rimage_2] /dev/sdd1(1)  [my_lv_rmeta_0] /dev/sda1(0)  [my_lv_rmeta_1] /dev/sdb1(0)  [my_lv_rmeta_2] /dev/sdd1(0)
To remove images from a RAID1 array, use the following command. When you remove images from a RAID1 device with the lvconvert command, you can specify the total number of images for the resulting device, or you can specify how many images to remove from the device. You can also optionally specify the physical volumes from which to remove the device.
lvconvert -m new_absolute_count vg/lv [removable_PVs]lvconvert -m -num_fewer_images vg/lv [removable_PVs]
Additionally, when an image and its associated metadata subvolume volume are removed, any higher-numbered images will be shifted down to fill the slot. If you remove lv_rimage_1 from a 3-way RAID1 array that consists of lv_rimage_0, lv_rimage_1, and lv_rimage_2, this results in a RAID1 array that consists of lv_rimage_0 and lv_rimage_1. The subvolume lv_rimage_2 will be renamed and take over the empty slot, becoming lv_rimage_1.
The following example shows the layout of a 3-way RAID1 logical volume my_vg/my_lv.
# lvs -a -o name,copy_percent,devices my_vg  LV   Copy%  Devices   my_lv 100.00 my_lv_rimage_0(0),my_lv_rimage_1(0),my_lv_rimage_2(0)  [my_lv_rimage_0] /dev/sde1(1)  [my_lv_rimage_1] /dev/sdf1(1)  [my_lv_rimage_2] /dev/sdg1(1)  [my_lv_rmeta_0] /dev/sde1(0)  [my_lv_rmeta_1] /dev/sdf1(0)  [my_lv_rmeta_2] /dev/sdg1(0)
The following command converts the 3-way RAID1 logical volume into a 2-way RAID1 logical volume.
# lvconvert -m1 my_vg/my_lv# lvs -a -o name,copy_percent,devices my_vg  LV   Copy%  Devices my_lv 100.00 my_lv_rimage_0(0),my_lv_rimage_1(0)  [my_lv_rimage_0] /dev/sde1(1)   [my_lv_rimage_1] /dev/sdf1(1)   [my_lv_rmeta_0] /dev/sde1(0)   [my_lv_rmeta_1] /dev/sdf1(0)
The following command converts the 3-way RAID1 logical volume into a 2-way RAID1 logical volume, specifying the physical volume that contains the image to remove as /dev/sde1.
# lvconvert -m1 my_vg/my_lv /dev/sde1# lvs -a -o name,copy_percent,devices my_vg  LV   Copy%  Devices my_lv 100.00 my_lv_rimage_0(0),my_lv_rimage_1(0)  [my_lv_rimage_0] /dev/sdf1(1)   [my_lv_rimage_1] /dev/sdg1(1)   [my_lv_rmeta_0] /dev/sdf1(0)   [my_lv_rmeta_1] /dev/sdg1(0)

4.4.15.6. Splitting off a RAID Image as a Separate Logical Volume

You can split off an image of a RAID logical volume to form a new logical volume. The procedure for splitting off a RAID image is the same as the procedure for splitting off a redundant image of a mirrored logical volume, as described in Section 4.4.3.2, "Splitting Off a Redundant Image of a Mirrored Logical Volume".
The format of the command to split off a RAID image is as follows:
lvconvert --splitmirrors count -n splitname vg/lv [removable_PVs]
Just as when you are removing a RAID images from an existing RAID1 logical volume (as described in Section 4.4.15.5, "Changing the Number of Images in an Existing RAID1 Device"), when you remove a RAID data subvolume (and its associated metadata subvolume) from the middle of the device, any higher numbered images will be shifted down to fill the slot. The index numbers on the logical volumes that make up a RAID array will thus be an unbroken sequence of integers.

Note

You cannot split off a RAID image if the RAID1 array is not yet in sync.
The following example splits a 2-way RAID1 logical volume, my_lv, into two linear logical volumes, my_lv and new.
# lvs -a -o name,copy_percent,devices my_vg  LV   Copy%  Devices my_lv 12.00 my_lv_rimage_0(0),my_lv_rimage_1(0)  [my_lv_rimage_0] /dev/sde1(1)   [my_lv_rimage_1] /dev/sdf1(1)   [my_lv_rmeta_0] /dev/sde1(0)   [my_lv_rmeta_1] /dev/sdf1(0) # lvconvert --splitmirror 1 -n new my_vg/my_lv# lvs -a -o name,copy_percent,devices my_vg  LV  Copy%  Devices   my_lv  /dev/sde1(1)  new /dev/sdf1(1)
The following example splits a 3-way RAID1 logical volume, my_lv, into a 2-way RAID1 logical volume, my_lv, and a linear logical volume, new
# lvs -a -o name,copy_percent,devices my_vg  LV   Copy%  Devices   my_lv 100.00 my_lv_rimage_0(0),my_lv_rimage_1(0),my_lv_rimage_2(0)  [my_lv_rimage_0] /dev/sde1(1)  [my_lv_rimage_1] /dev/sdf1(1)  [my_lv_rimage_2] /dev/sdg1(1)  [my_lv_rmeta_0] /dev/sde1(0)  [my_lv_rmeta_1] /dev/sdf1(0)  [my_lv_rmeta_2] /dev/sdg1(0) # lvconvert --splitmirror 1 -n new my_vg/my_lv# lvs -a -o name,copy_percent,devices my_vg  LV Copy%  Devices my_lv 100.00 my_lv_rimage_0(0),my_lv_rimage_1(0)  [my_lv_rimage_0] /dev/sde1(1)   [my_lv_rimage_1] /dev/sdf1(1)   [my_lv_rmeta_0] /dev/sde1(0)   [my_lv_rmeta_1] /dev/sdf1(0)   new /dev/sdg1(1)

4.4.15.7. Splitting and Merging a RAID Image

You can temporarily split off an image of a RAID1 array for read-only use while keeping track of any changes by using the --trackchanges argument in conjunction with the --splitmirrors argument of the lvconvert command. This allows you to merge the image back into the array at a later time while resyncing only those portions of the array that have changed since the image was split.
The format for the lvconvert command to split off a RAID image is as follows.
lvconvert --splitmirrors count --trackchanges vg/lv [removable_PVs]
When you split off a RAID image with the --trackchanges argument, you can specify which image to split but you cannot change the name of the volume being split. In addition, the resulting volumes have the following constraints.
  • The new volume you create is read-only.
  • You cannot resize the new volume.
  • You cannot rename the remaining array.
  • You cannot resize the remaining array.
  • You can activate the new volume and the remaining array independently.
You can merge an image that was split off with the --trackchanges argument specified by executing a subsequent lvconvert command with the --merge argument. When you merge the image, only the portions of the array that have changed since the image was split are resynced.
The format for the lvconvert command to merge a RAID image is as follows.
lvconvert --merge raid_image
The following example creates a RAID1 logical volume and then splits off an image from that volume while tracking changes to the remaining array.
# lvcreate --type raid1 -m2 -L1G -n my_lv .vg  Logical volume "my_lv" created# lvs -a -o name,copy_percent,devices my_vg  LV   Copy%  Devices   my_lv 100.00 my_lv_rimage_0(0),my_lv_rimage_1(0),my_lv_rimage_2(0)  [my_lv_rimage_0] /dev/sdb1(1)  [my_lv_rimage_1] /dev/sdc1(1)  [my_lv_rimage_2] /dev/sdd1(1)  [my_lv_rmeta_0] /dev/sdb1(0)  [my_lv_rmeta_1] /dev/sdc1(0)  [my_lv_rmeta_2] /dev/sdd1(0) # lvconvert --splitmirrors 1 --trackchanges my_vg/my_lv  my_lv_rimage_2 split from my_lv for read-only purposes.  Use 'lvconvert --merge my_vg/my_lv_rimage_2' to merge back into my_lv# lvs -a -o name,copy_percent,devices my_vg  LV   Copy%  Devices   my_lv 100.00 my_lv_rimage_0(0),my_lv_rimage_1(0),my_lv_rimage_2(0)  [my_lv_rimage_0] /dev/sdb1(1)  [my_lv_rimage_1] /dev/sdc1(1)  my_lv_rimage_2 /dev/sdd1(1)  [my_lv_rmeta_0] /dev/sdb1(0)  [my_lv_rmeta_1] /dev/sdc1(0)  [my_lv_rmeta_2] /dev/sdd1(0)
The following example splits off an image from a RAID1 volume while tracking changes to the remaining array, then merges the volume back into the array.
# lvconvert --splitmirrors 1 --trackchanges my_vg/my_lv  lv_rimage_1 split from my_lv for read-only purposes.  Use 'lvconvert --merge my_vg/my_lv_rimage_1' to merge back into my_lv# lvs -a -o name,copy_percent,devices my_vg  LV   Copy%  Devices my_lv 100.00 my_lv_rimage_0(0),my_lv_rimage_1(0)  [my_lv_rimage_0] /dev/sdc1(1)   my_lv_rimage_1  /dev/sdd1(1)   [my_lv_rmeta_0] /dev/sdc1(0)   [my_lv_rmeta_1] /dev/sdd1(0) # lvconvert --merge my_vg/my_lv_rimage_1  my_vg/my_lv_rimage_1 successfully merged back into my_vg/my_lv# lvs -a -o name,copy_percent,devices my_vg  LV   Copy%  Devices my_lv 100.00 my_lv_rimage_0(0),my_lv_rimage_1(0)  [my_lv_rimage_0] /dev/sdc1(1)   [my_lv_rimage_1] /dev/sdd1(1)   [my_lv_rmeta_0] /dev/sdc1(0)   [my_lv_rmeta_1] /dev/sdd1(0)
Once you have split off an image from a RAID1 volume, you can make the split permanent by issuing a second lvconvert --splitmirrors command, repeating the initial lvconvert command that split the image without specifying the --trackchanges argument. This breaks the link that the --trackchanges argument created.
After you have split an image with the --trackchanges argument, you cannot issue a subsequent lvconvert --splitmirrors command on that array unless your intent is to permanently split the image being tracked.
The following sequence of commands splits an image and tracks the image and then permanently splits off the image being tracked.
# lvconvert --splitmirrors 1 --trackchanges my_vg/my_lv  my_lv_rimage_1 split from my_lv for read-only purposes.  Use 'lvconvert --merge my_vg/my_lv_rimage_1' to merge back into my_lv# lvconvert --splitmirrors 1 -n new my_vg/my_lv# lvs -a -o name,copy_percent,devices my_vg  LV   Copy%  Devices   my_lv  /dev/sdc1(1)  new /dev/sdd1(1)
Note, however, that the following sequence of commands will fail.
# lvconvert --splitmirrors 1 --trackchanges my_vg/my_lv  my_lv_rimage_1 split from my_lv for read-only purposes.  Use 'lvconvert --merge my_vg/my_lv_rimage_1' to merge back into my_lv# lvconvert --splitmirrors 1 --trackchanges my_vg/my_lv  Cannot track more than one split image at a time
Similarly, the following sequence of commands will fail as well, since the split image is not the image being tracked.
# lvconvert --splitmirrors 1 --trackchanges my_vg/my_lv  my_lv_rimage_1 split from my_lv for read-only purposes.  Use 'lvconvert --merge my_vg/my_lv_rimage_1' to merge back into my_lv# lvs -a -o name,copy_percent,devices my_vg  LV   Copy%  Devices my_lv 100.00 my_lv_rimage_0(0),my_lv_rimage_1(0)  [my_lv_rimage_0] /dev/sdc1(1)   my_lv_rimage_1  /dev/sdd1(1)   [my_lv_rmeta_0] /dev/sdc1(0)   [my_lv_rmeta_1] /dev/sdd1(0) # lvconvert --splitmirrors 1 -n new my_vg/my_lv /dev/sdc1  Unable to split additional image from my_lv while tracking changes for my_lv_rimage_1

4.4.15.8. Setting a RAID fault policy

LVM RAID handles device failures in an automatic fashion based on the preferences defined by the raid_fault_policy field in the lvm.conf file.
  • If the raid_fault_policy field is set to allocate, the system will attempt to replace the failed device with a spare device from the volume group. If there is no available spare device, this will be reported to the system log.
  • If the raid_fault_policy field is set to warn, the system will produce a warning and the log will indicate that a device has failed. This allows the user to determine the course of action to take.
As long as there are enough devices remaining to support usability, the RAID logical volume will continue to operate.
4.4.15.8.1. The allocate RAID Fault Policy
In the following example, the raid_fault_policy field has been set to allocate in the lvm.conf file. The RAID logical volume is laid out as follows.
# lvs -a -o name,copy_percent,devices my_vg  LV   Copy%  Devices   my_lv 100.00 my_lv_rimage_0(0),my_lv_rimage_1(0),my_lv_rimage_2(0)  [my_lv_rimage_0] /dev/sde1(1)  [my_lv_rimage_1] /dev/sdf1(1)  [my_lv_rimage_2] /dev/sdg1(1)  [my_lv_rmeta_0] /dev/sde1(0)  [my_lv_rmeta_1] /dev/sdf1(0)  [my_lv_rmeta_2] /dev/sdg1(0)
If the /dev/sde device fails, the system log will display error messages.
# grep lvm /var/log/messages Jan 17 15:57:18 bp-01 lvm[8599]: Device #0 of raid1 array, my_vg-my_lv, has failed.Jan 17 15:57:18 bp-01 lvm[8599]: /dev/sde1: read failed after 0 of 2048 at250994294784: Input/output errorJan 17 15:57:18 bp-01 lvm[8599]: /dev/sde1: read failed after 0 of 2048 at250994376704: Input/output errorJan 17 15:57:18 bp-01 lvm[8599]: /dev/sde1: read failed after 0 of 2048 at 0:Input/output errorJan 17 15:57:18 bp-01 lvm[8599]: /dev/sde1: read failed after 0 of 2048 at4096: Input/output errorJan 17 15:57:19 bp-01 lvm[8599]: Couldn't find device with uuid3lugiV-3eSP-AFAR-sdrP-H20O-wM2M-qdMANy.Jan 17 15:57:27 bp-01 lvm[8599]: raid1 array, my_vg-my_lv, is not in-sync.Jan 17 15:57:36 bp-01 lvm[8599]: raid1 array, my_vg-my_lv, is now in-sync.
Since the raid_fault_policy field has been set to allocate, the failed device is replaced with a new device from the volume group.
# lvs -a -o name,copy_percent,devices vg  Couldn't find device with uuid 3lugiV-3eSP-AFAR-sdrP-H20O-wM2M-qdMANy.  LV Copy%  Devices   lv 100.00 lv_rimage_0(0),lv_rimage_1(0),lv_rimage_2(0)  [lv_rimage_0] /dev/sdh1(1)  [lv_rimage_1] /dev/sdf1(1)  [lv_rimage_2] /dev/sdg1(1)  [lv_rmeta_0] /dev/sdh1(0)  [lv_rmeta_1] /dev/sdf1(0)  [lv_rmeta_2] /dev/sdg1(0)
Note that even though the failed device has been replaced, the display still indicates that LVM could not find the failed device. This is because, although the failed device has been removed from the RAID logical volume, the failed device has not yet been removed from the volume group. To remove the failed device from the volume group, you can execute vgreduce --removemissing VG.
If the raid_fault_policy has been set to allocate but there are no spare devices, the allocation will fail, leaving the logical volume as it is. If the allocation fails, you have the option of fixing the drive, then deactivating and activating the logical volume, as described in Section 4.4.15.8.2, "The warn RAID Fault Policy". Alternately, you can replace the failed device, as described in Section 4.4.15.9, "Replacing a RAID device".
4.4.15.8.2. The warn RAID Fault Policy
In the following example, the raid_fault_policy field has been set to warn in the lvm.conf file. The RAID logical volume is laid out as follows.
# lvs -a -o name,copy_percent,devices my_vg  LV   Copy%  Devices   my_lv 100.00 my_lv_rimage_0(0),my_lv_rimage_1(0),my_lv_rimage_2(0)  [my_lv_rimage_0] /dev/sdh1(1)  [my_lv_rimage_1] /dev/sdf1(1)  [my_lv_rimage_2] /dev/sdg1(1)  [my_lv_rmeta_0] /dev/sdh1(0)  [my_lv_rmeta_1] /dev/sdf1(0)  [my_lv_rmeta_2] /dev/sdg1(0)
If the /dev/sdh device fails, the system log will display error messages. In this case, however, LVM will not automatically attempt to repair the RAID device by replacing one of the images. Instead, if the device has failed you can replace the device with the --repair argument of the lvconvert command, as shown below.
# lvconvert --repair my_vg/my_lv  /dev/sdh1: read failed after 0 of 2048 at 250994294784: Input/output error  /dev/sdh1: read failed after 0 of 2048 at 250994376704: Input/output error  /dev/sdh1: read failed after 0 of 2048 at 0: Input/output error  /dev/sdh1: read failed after 0 of 2048 at 4096: Input/output error  Couldn't find device with uuid fbI0YO-GX7x-firU-Vy5o-vzwx-vAKZ-feRxfF.Attempt to replace failed RAID images (requires full device resync)? [y/n]: y# lvs -a -o name,copy_percent,devices my_vg  Couldn't find device with uuid fbI0YO-GX7x-firU-Vy5o-vzwx-vAKZ-feRxfF.  LV   Copy%  Devices   my_lv 64.00 my_lv_rimage_0(0),my_lv_rimage_1(0),my_lv_rimage_2(0)  [my_lv_rimage_0] /dev/sde1(1)  [my_lv_rimage_1] /dev/sdf1(1)  [my_lv_rimage_2] /dev/sdg1(1)  [my_lv_rmeta_0] /dev/sde1(0)  [my_lv_rmeta_1] /dev/sdf1(0)  [my_lv_rmeta_2] /dev/sdg1(0)
Note that even though the failed device has been replaced, the display still indicates that LVM could not find the failed device. This is because, although the failed device has been removed from the RAID logical volume, the failed device has not yet been removed from the volume group. To remove the failed device from the volume group, you can execute vgreduce --removemissing VG.
If the device failure is a transient failure or you are able to repair the device that failed, you can deactivate and then activate the logical volume so that it will not longer be considered failed, as shown in the following commands.
# lvchange -an my_vg/my_lv# lvchange -ay my_vg/my_lv
Once the drive is in sync again, it is considered active.

4.4.15.9. Replacing a RAID device

RAID is not like traditional LVM mirroring. LVM mirroring required failed devices to be removed or the mirrored logical volume would hang. RAID arrays can keep on running with failed devices. In fact, for RAID types other than RAID1, removing a device would mean converting to a lower level RAID (for example, from RAID6 to RAID5, or from RAID4 or RAID5 to RAID0). Therefore, rather than removing a failed device unconditionally and potentially allocating a replacement, LVM allows you to replace a device in a RAID volume in a one-step solution by using the --replace argument of the lvconvert command.
The format for the lvconvert --replace is as follows.
lvconvert --replace dev_to_remove vg/lv [possible_replacements]
The following example creates a RAID1 logical volume and then replaces a device in that volume.
# lvcreate --type raid1 -m2 -L 1G -n my_lv my_vg  Logical volume "my_lv" created# lvs -a -o name,copy_percent,devices my_vg  LV   Copy%  Devices   my_lv 100.00 my_lv_rimage_0(0),my_lv_rimage_1(0),my_lv_rimage_2(0)  [my_lv_rimage_0] /dev/sdb1(1)  [my_lv_rimage_1] /dev/sdb2(1)  [my_lv_rimage_2] /dev/sdc1(1)  [my_lv_rmeta_0] /dev/sdb1(0)  [my_lv_rmeta_1] /dev/sdb2(0)  [my_lv_rmeta_2] /dev/sdc1(0) # lvconvert --replace /dev/sdb2 my_vg/my_lv# lvs -a -o name,copy_percent,devices my_vg  LV   Copy%  Devices   my_lv 37.50 my_lv_rimage_0(0),my_lv_rimage_1(0),my_lv_rimage_2(0)  [my_lv_rimage_0] /dev/sdb1(1)  [my_lv_rimage_1] /dev/sdc2(1)  [my_lv_rimage_2] /dev/sdc1(1)  [my_lv_rmeta_0] /dev/sdb1(0)  [my_lv_rmeta_1] /dev/sdc2(0)  [my_lv_rmeta_2] /dev/sdc1(0)
The following example creates a RAID1 logical volume and then replaces a device in that volume, specifying which physical volume to use for the replacement.
# lvcreate --type raid1 -m1 -L 100 -n my_lv my_vg  Logical volume "my_lv" created# lvs -a -o name,copy_percent,devices my_vg  LV   Copy%  Devices  my_lv 100.00 my_lv_rimage_0(0),my_lv_rimage_1(0)  [my_lv_rimage_0] /dev/sda1(1)  [my_lv_rimage_1] /dev/sdb1(1)  [my_lv_rmeta_0] /dev/sda1(0)  [my_lv_rmeta_1] /dev/sdb1(0)# pvs  PV  VG   Fmt  Attr PSize PFree  /dev/sda1   my_vg lvm2 a--  1020.00m  916.00m  /dev/sdb1   my_vg lvm2 a--  1020.00m  916.00m  /dev/sdc1   my_vg lvm2 a--  1020.00m 1020.00m  /dev/sdd1   my_vg lvm2 a--  1020.00m 1020.00m# lvconvert --replace /dev/sdb1 my_vg/my_lv /dev/sdd1# lvs -a -o name,copy_percent,devices my_vg  LV   Copy%  Devices  my_lv 28.00 my_lv_rimage_0(0),my_lv_rimage_1(0)  [my_lv_rimage_0] /dev/sda1(1)  [my_lv_rimage_1] /dev/sdd1(1)  [my_lv_rmeta_0] /dev/sda1(0)  [my_lv_rmeta_1] /dev/sdd1(0)
You can replace more than one RAID device at a time by specifying multiple replace arguments, as in the following example.
# lvcreate --type raid1 -m 2 -L 100 -n my_lv my_vg  Logical volume "my_lv" created# lvs -a -o name,copy_percent,devices my_vg  LV   Copy%  Devices  my_lv 100.00 my_lv_rimage_0(0),my_lv_rimage_1(0),my_lv_rimage_2(0)  [my_lv_rimage_0] /dev/sda1(1)  [my_lv_rimage_1] /dev/sdb1(1)  [my_lv_rimage_2] /dev/sdc1(1)  [my_lv_rmeta_0] /dev/sda1(0)  [my_lv_rmeta_1] /dev/sdb1(0)  [my_lv_rmeta_2] /dev/sdc1(0)# lvconvert --replace /dev/sdb1 --replace /dev/sdc1 my_vg/my_lv# lvs -a -o name,copy_percent,devices my_vg  LV   Copy%  Devices  my_lv 60.00 my_lv_rimage_0(0),my_lv_rimage_1(0),my_lv_rimage_2(0)  [my_lv_rimage_0] /dev/sda1(1)  [my_lv_rimage_1] /dev/sdd1(1)  [my_lv_rimage_2] /dev/sde1(1)  [my_lv_rmeta_0] /dev/sda1(0)  [my_lv_rmeta_1] /dev/sdd1(0)  [my_lv_rmeta_2] /dev/sde1(0)

Note

When you specify a replacement drive using the lvconvert --replace command, the replacement drives should never be allocated from extra space on drives already used in the array. For example, lv_rimage_0 and lv_rimage_1 should not be located on the same physical volume.

4.4.16. Shrinking Logical Volumes

To reduce the size of a logical volume, first unmount the file system. You can then use the lvreduce command to shrink the volume. After shrinking the volume, remount the file system.

Warning

It is important to reduce the size of the file system or whatever is residing in the volume before shrinking the volume itself, otherwise you risk losing data.
Shrinking a logical volume frees some of the volume group to be allocated to other logical volumes in the volume group.
The following example reduces the size of logical volume lvol1 in volume group vg00 by 3 logical extents.
# lvreduce -l -3 vg00/lvol1
(Sebelumnya) 10 : Chapter 4. LVM Administra ...10 : 4.5. Controlling LVM Devi ... (Berikutnya)