• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

lvconvert Command Examples in Linux

by admin

Although lvconvert command is used for many purposes, it is mostly used for mirroring LVM volumes or convert a mirrored volume to a linear one. To convert a linear volume to a mirrored one use lvconvert with the “-m” option. The “-m” option takes a number as an argument that represents the number of copies of the data that you want to have. The other options are the name of the LV that you want to convert followed by a list of all the physical volumes (PV) that will be used for the mirror and its log disk. The log disk contains information on which section of the mirror needs to be synced, it speeds up operations at boot time and improves reliability. When we want to specify that a PV is the one that should be used as a log disk we specify the extent that we want to use for it by appending “:0” to the device name.

For example if we have a VG called mirrorvg, with a LV called lv0 that is linear and is using a PV called mpath0 and we want to create a two way mirror (a mirror that has two replica disks) we use the following command line:

# lvconvert -m 2 /dev/mirrorvg/lv0 /dev/mpath/mpath0 /dev/mpath/mpath1 /dev/mpath/mpath2 /dev/mpath/mpath3:0

With this command, we specify that we want to have two copies of the data, that the volume that we want to convert is lv0 and belongs to mirrorvg VG. We also specify the PV that contains the original data mpath0 and two PV that will contain two copies of the data mpath1 and mpath2. The last PV, mpath3, is the PV that we want to use as a log disk so we append to it.

Similarly, if you want to remove a leg of the mirror, use the below command. We are decreasing the mirror copied with the “-m” switch.

# lvconvert -m 1 /dev/mirrorvg/lv0 /dev/mpath/mpath0

Similarly, we can go on and remove one more leg of the mirror to make the volume linear as shown below:

# lvconvert -m 0 /dev/mirrorvg/lv0 /dev/mpath/mpath1

examples of lvconvert command

1. To specify the degree of mirror to create:

# lvconvert -m 1
# lvconvert --mirrors 1

3. To specify the type of log to use:

# lvconvert --mirrorlog disk
# lvconvert --mirrorlog core
# lvconvert --mirrorlog mirrored
# lvconvert --corelog

4. To divide the mirror into regions:

# lvconvert -R MirrorLogRegionSize
# lvconvert --regionsize MirrorLogRegionSize

5. To run the daemon in background:

# lvconvert -b
# lvconvert --background

6. To report progress as a percentage at regular intervals:

# lvconvert -i Seconds
# lvconvert --interval Seconds

7. To disable udev synchronization:

# lvconvert --noudevsync

8. To split off mirror images to form a new logical volume:

# lvconvert --splitmirrors Images

9. To apply name to a logical volume which has been split off from a mirror logical volume:

# lvconvert -n name

10. To Create a snapshot from existing logical volume using another existing logical volume as its origin:

# lvconvert -s
# lvconvert --snapshot

11. To Power of 2 chunk size for the snapshot logical volume between 4k and 512k:

# lvconvert -c ChunkSize
# lvconvert --chunksize ChunkSize

12. To Controls zeroing of the first KB of data in the snapshot:

# lvconvert -Z y|n
# lvconvert --zero y|n

13. To Merges a snapshot into its origin volume:

# lvconvert --merge

14. To Repair a mirror after suffering a disk failure:

# lvconvert --repair

Filed Under: Linux

Some more articles you might also be interested in …

  1. How to transfer files securely using sftp (examples included)
  2. How to Disable “Predictable Network Interface Device Names” in CentOS/RHEL 7
  3. Linux OS Service ‘NetworkManagerDispatcher’
  4. ‘error opening class fc_host’ – systool Command Error on CentOS/RHEL 7 and 8
  5. Firewalld Command line Reference (Cheat Sheet)
  6. How To Force User/Group Ownership Of Files On A Samba Share
  7. How To Store iptables Rules To Survive Across Reboots in CentOS/RHEL
  8. How to Replace a Failed Btrfs Device
  9. elinks Command Examples in Linux
  10. How to monitor NVME drives on Centos 6

You May Also Like

Primary Sidebar

Recent Posts

  • JavaFX ComboBox: Set a value to the combo box
  • Nginx load balancing
  • nginx 504 gateway time-out
  • Images preview with ngx_http_image_filter_module

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright