lvchange Command Examples in Linux

lvchange command changes LV attributes in the VG, changes LV activation in the kernel and includes other utilities for LV maintenance. For example, you may use lvchange while removing a disk from a Volume Group. Below outlined steps, provide a procedure to remove a disk from VG.

Note: Backup the whole Volume Group either by the VM level snapshot or OS level LVM snapshot and make sure volumes can be restored from the snapshot.

1. If a Physical Volume has a Logical Volume bindings, therefore unmount the volume and destroy it is needed:

# umount [mount point]
# lvchange -a n [LV path]

2. Remove the Logical Volume:

# lvremove [LV path]

3. Remove the Physical Volume from the Volume Group:

# vgreduce [volume group] [physical volume]

lvchange command examples

1. To control the availablability of logical volumes:

# lvchange -a LV00
# lvchange --available LV00
# lvchange -ay LV00  (To activate)
# lvchange -an LV00  (To deactivate)
# lvchange -aey LV00  (In Cluster - Activate in one node)
# lvchange -aly LV00  (In Cluster - Activate in local node)
# lvchange -aln LV00  (In Cluster - deactivate in local node)

2. To set or reset the contiguous allocation policy for logical volumes:

# lvchange -C y|n LV00
# lvchange --contiguous y|n LV00

3. To force the complete resynchronization of a mirror:

# lvchange --resync LV00

4. To set the minor number:

# lvchange --minor minor LV00

5. To start or stop monitoring a mirrored or snapshot logical volume with dmeventd:

# lvchange --monitor y|n LV00

6. To poll a logical volume to restart its previous incomplete transactions:

# lvchange --poll y|n LV00

7. To invoke lvchange from early system initialisation scripts (e.g. rc.sysinit or an initrd):

# lvchange --sysinit LV00

8. To disable udev synchronization:

# lvchange --noudevsync LV00

9. To make no attempt to interact with dmeventd unless –monitor is specified:

# lvchange --ignoremonitoring LV00

10. To set to y to make the minor number specified persistent:

# lvchange -M y|n LV00
# lvchange --persistent y|n LV00 

11. To change access permission to read-only or read/write:

# lvchange -p r|rw LV00
# lvchange --permission r|rw LV00

12. To set read ahead sector count of this logical volume:

# lvchange -r ReadAheadSectors|auto|none LV00
# lvchange --readahead ReadAheadSectors|auto|none LV00

13. To reload the logical volume metadata:

# lvchange --refresh LV00
Related Post