{"id":65,"date":"2022-04-02T11:31:00","date_gmt":"2022-04-02T09:31:00","guid":{"rendered":"https:\/\/blubb.fish\/?p=65"},"modified":"2022-03-25T11:31:55","modified_gmt":"2022-03-25T10:31:55","slug":"remove-lvm-volume","status":"publish","type":"post","link":"https:\/\/blubb.fish\/index.php\/2022\/04\/02\/remove-lvm-volume\/","title":{"rendered":"Remove LVM Volume"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">How to remove a volume from lvm<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">check if lv is still mounted<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ df -hTP | grep test                                                                                          \n\/dev\/mapper\/datavg-testlv ext4      9.9G    4.5M  9.4G    1% \/mnt\/test<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">check with lsof if there are open files pointing on the volume. if yes close them<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">get id with lsblk<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ lsblk | grep test                                                                                                \n\u2514\u2500datavg-testlv                               254:4    0    10G  0 lvm   \/mnt\/test<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">check with lsof (in this case we fount the id 254:4 with lsblk which will be 254,4 for lsof)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#if we get empty response, there are no open files\n$ lsof | grep \"254,4\"                                                                                   \n\n$ lsof \/mnt\/test                                                                                        <\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Remove all mount entries from \/etc\/fstab<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># check for entries\n$ grep test \/etc\/fstab                                                                                           \n\/dev\/mapper\/datavg-testlv \/mnt\/test ext4 defaults 0 0\n#we get an entry so we open \/etc\/fstab and remove it\n$ vim \/etc\/fstab<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">umount the volume<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>umount -f \/mnt\/test<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">now we can start the removal. if lvremove still sees open files, reboot the machine and everything will be closed<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ lvremove \/dev\/mapper\/datavg-testlv                                                                               \nDo you really want to remove active logical volume datavg\/testlv? &#91;y\/n]: y\n  Logical volume \"testlv\" successfully removed.<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p class=\"wp-block-paragraph\">if needed we can now remove the volume group too. can only be done if there are no other logical volumes<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ vgremove datavg<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">and remove the physical volume<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pvremove \/dev\/sdx<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>How to remove a volume from lvm check if lv is still mounted check with lsof if there are open files pointing on the volume. if yes close them get id with lsblk check with lsof (in this case we fount the id 254:4 with lsblk which will be 254,4 for lsof) Remove all mount [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-65","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/blubb.fish\/index.php\/wp-json\/wp\/v2\/posts\/65","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blubb.fish\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blubb.fish\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blubb.fish\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blubb.fish\/index.php\/wp-json\/wp\/v2\/comments?post=65"}],"version-history":[{"count":3,"href":"https:\/\/blubb.fish\/index.php\/wp-json\/wp\/v2\/posts\/65\/revisions"}],"predecessor-version":[{"id":76,"href":"https:\/\/blubb.fish\/index.php\/wp-json\/wp\/v2\/posts\/65\/revisions\/76"}],"wp:attachment":[{"href":"https:\/\/blubb.fish\/index.php\/wp-json\/wp\/v2\/media?parent=65"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blubb.fish\/index.php\/wp-json\/wp\/v2\/categories?post=65"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blubb.fish\/index.php\/wp-json\/wp\/v2\/tags?post=65"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}