{"id":2608,"date":"2021-12-23T02:37:35","date_gmt":"2021-12-23T02:37:35","guid":{"rendered":"https:\/\/dft.wiki\/?p=2608"},"modified":"2025-11-06T15:33:56","modified_gmt":"2025-11-06T20:33:56","slug":"vlm-cheat-sheet","status":"publish","type":"post","link":"https:\/\/dft.wiki\/?p=2608","title":{"rendered":"LVM Cheat Sheet"},"content":{"rendered":"<p>Logical Volume Management (LVM) is a method of space allocating on mass-storage devices.<\/p>\n<p>It can provide superior features to the traditional partitioning schema such as concatenating, striping or combining partitions, re-sizing or moving partitions, potentially without rebooting.<\/p>\n<p>Some related commands that will help with the LVM commands are:<\/p>\n<pre>lsblk\r\nblkid \/dev\/mapper\/lg_name-lv_name<\/pre>\n<hr \/>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-2609 \" src=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2021\/12\/Screenshot_2021-12-22_21-36-00.png\" alt=\"\" width=\"527\" height=\"465\" srcset=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2021\/12\/Screenshot_2021-12-22_21-36-00.png 787w, https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2021\/12\/Screenshot_2021-12-22_21-36-00-300x265.png 300w, https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2021\/12\/Screenshot_2021-12-22_21-36-00-768x677.png 768w\" sizes=\"auto, (max-width: 527px) 100vw, 527px\" \/><\/p>\n<p>Displaying information:<\/p>\n<pre>pvdisplay\r\nvgdisplay\r\nlvdisplay\r\nlvs<\/pre>\n<p>Claiming a new Physical device to extend an existent Logical Volume:<\/p>\n<pre>pvcreate \/dev\/sdb\r\nvgextend vg_name \/dev\/sdb\r\nlvextend -L +5G \/dev\/mapper\/lg_name-lv_name\r\nresize2fs \/dev\/mapper\/lg_name-lv_name<\/pre>\n<p>Extending an existing Logical Volume to the whole extension of the Logical Group:<\/p>\n<pre>lvextend --resizefs -l +100%FREE \/dev\/mapper\/lg_name-lv_name<\/pre>\n<p>Creating new Logical Volumes on the same new Volume Group:<\/p>\n<pre>vgcreate vg2_name \/dev\/sdc\r\nlvcreate vg2_name -L 10G -n lv2_name\r\nmkfs.ext4 \/dev\/mapper\/vg2_name-lv2_name\r\nlvcreate vg2_name -L 10G -n lv3_name\r\nmkfs.ext4 \/dev\/mapper\/vg2_name-lv3_name<\/pre>\n<pre>lvcreate \/dev\/mapper\/vg2_name-lv3_name -L 5G -s -n lv3_snapshot\r\nmount \/dev\/mapper\/vg2_name-lv3_snapshot \/mount_point\/\r\nlvconvert --merge \/dev\/mapper\/vg2_name-lv3_snapshot\r\nlvchange -an \/dev\/mapper\/vg2_name-lv3_name\r\nlvchange -ay \/dev\/mapper\/vg2_name-lv3_name<\/pre>\n<hr \/>\n<p><strong>BONUS<\/strong><\/p>\n<p>Here is a quick-and-dirty step-by-step that might work on default Ubuntu installations that have LVM on the root volume.<\/p>\n<pre>df -h\r\nlsblk\r\nblkid \/dev\/mapper\/ubuntu--vg-ubuntu--lv \r\n\r\npvdisplay\r\ngrowpart \/dev\/vda 3\r\npvdisplay\r\n\r\nvgdisplay ubuntu-vg\r\nlvextend -l +100%FREE \/dev\/ubuntu-vg\/ubuntu-lv\r\nlvdisplay \/dev\/ubuntu-vg\/ubuntu-lv\r\nvgdisplay ubuntu-vg\r\n\r\ndf -h\r\nresize2fs \/dev\/ubuntu-vg\/ubuntu-lv\r\ndf -h<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Logical Volume Management (LVM) is a method of space allocating on mass-storage devices. It can [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-2608","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/2608","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2608"}],"version-history":[{"count":4,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/2608\/revisions"}],"predecessor-version":[{"id":5157,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/2608\/revisions\/5157"}],"wp:attachment":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2608"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2608"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2608"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}