{"id":217,"date":"2019-11-07T15:44:03","date_gmt":"2019-11-07T20:44:03","guid":{"rendered":"https:\/\/www.bu.edu\/engit\/?page_id=217"},"modified":"2019-11-12T17:15:51","modified_gmt":"2019-11-12T22:15:51","slug":"lvm_usage","status":"publish","type":"page","link":"https:\/\/www.bu.edu\/engit\/knowledge-base\/linux\/lvm_usage\/","title":{"rendered":"LVM Usage Examples"},"content":{"rendered":"<p>For documentation purposes, here&#8217;s the procedure to resize a partition on an LVM system. For more detail, see the LVM howto at <a class=\"http\" href=\"http:\/\/tldp.org\/HOWTO\/LVM-HOWTO\">http:\/\/tldp.org\/HOWTO\/LVM-HOWTO<\/a> :<\/p>\n<h1 id=\"I.Exampleongrowingafilesystem\">I. Example on growing a filesystem<\/h1>\n<p>1. pvscan to see if you&#8217;ve got enough free extents to grow your partition. If so, skip to step 4. If not, go on to step 2.<\/p>\n<p>2. Make a partition for the new physical volume. If you&#8217;re adding a whole disk, you can skip to step 3. With parted, you can do this non- interactively, which we did to run it as a script across all machines: in this case, we did:<\/p>\n<pre class=\"darkSnippet\">parted \/dev\/sda mkpart primary ext3 73.3G 501G<\/pre>\n<p>2a. If you receive an error message saying that the new partition table won&#8217;t be readable yet, run:<\/p>\n<pre class=\"darkSnippet\">partx -v -a \/dev\/sda<\/pre>\n<p>3. Create the physical volume on the new partition (or the new whole disk). In this case, we did:<\/p>\n<pre class=\"darkSnippet\">pvcreate \/dev\/sda4<\/pre>\n<p>4. vgextend your existing volume group onto the new physical volume In this case, we did:<\/p>\n<pre class=\"darkSnippet\">vgextend \/dev\/vglab \/dev\/sda4<\/pre>\n<p>5. resize the logical volume that you care about. (NOTE: if shrinking, you must unmount the partition first! See Example II. Depending on the partition, this will probably require you to boot from a rescue disk.) In this case, we did:<\/p>\n<pre class=\"darkSnippet\">lvresize \/dev\/vglab\/lvtmp -L100G<\/pre>\n<p>6. resize the filesystem residing on the logical volume. In this case, we did:<\/p>\n<pre class=\"darkSnippet\">resize2fs \/dev\/vglab\/lvtmp<\/pre>\n<h1 id=\"II.Exampleonshrinkingafilesystem\">II. Example on shrinking a filesystem<\/h1>\n<p>To shrink an ext3 filesystem, you *do* have to unmount.<\/p>\n<pre class=\"darkSnippet\">1. umount \/home\r\n2. resize2fs \/dev\/VolGroup00\/Home00 1500M\r\n3. e2fsck -f \/dev\/VolGroup00\/Home00\r\n4. resize2fs \/dev\/VolGroup00\/Home00 1500M\r\n5. lvreduce -L 1500M \/dev\/VolGroup00\/Home00\r\n6. e2fsck -f \/dev\/VolGroup00\/Home00\r\n7. mount \/home<\/pre>\n<h1 id=\"III.Exampleonremovingafilesystemandgrowingonanotherfilesystem\">III. Example on removing a filesystem and growing on another filesystem<\/h1>\n<pre class=\"darkSnippet\">1. umount \/home\r\n2. lvremove \/dev\/VolGroup00\/Home00\r\n3. lvresize -l +24 \/dev\/VolGroup00\/LogVol00\r\n4. resize2fs \/dev\/VolGroup00\/LogVol00<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>For documentation purposes, here&#8217;s the procedure to resize a partition on an LVM system. For more detail, see the LVM howto at http:\/\/tldp.org\/HOWTO\/LVM-HOWTO : I. Example on growing a filesystem 1. pvscan to see if you&#8217;ve got enough free extents to grow your partition. If so, skip to step 4. If not, go on to [&hellip;]<\/p>\n","protected":false},"author":16541,"featured_media":0,"parent":868,"menu_order":3,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/www.bu.edu\/engit\/wp-json\/wp\/v2\/pages\/217"}],"collection":[{"href":"https:\/\/www.bu.edu\/engit\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.bu.edu\/engit\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.bu.edu\/engit\/wp-json\/wp\/v2\/users\/16541"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bu.edu\/engit\/wp-json\/wp\/v2\/comments?post=217"}],"version-history":[{"count":3,"href":"https:\/\/www.bu.edu\/engit\/wp-json\/wp\/v2\/pages\/217\/revisions"}],"predecessor-version":[{"id":794,"href":"https:\/\/www.bu.edu\/engit\/wp-json\/wp\/v2\/pages\/217\/revisions\/794"}],"up":[{"embeddable":true,"href":"https:\/\/www.bu.edu\/engit\/wp-json\/wp\/v2\/pages\/868"}],"wp:attachment":[{"href":"https:\/\/www.bu.edu\/engit\/wp-json\/wp\/v2\/media?parent=217"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}