{"id":1783,"date":"2015-10-15T12:00:14","date_gmt":"2015-10-15T10:00:14","guid":{"rendered":"http:\/\/guimi.net\/blogs\/hiparco\/?p=1783"},"modified":"2015-10-15T12:04:51","modified_gmt":"2015-10-15T10:04:51","slug":"resizing-lvms","status":"publish","type":"post","link":"http:\/\/guimi.net\/blogs\/hiparco\/resizing-lvms\/","title":{"rendered":"Resizing LVMs"},"content":{"rendered":"<p>I was deploying a VM and I needed more space for \/.<br \/>\nSo first I turned off the machine and modified the machine.ovf file to increase de size of the hard disk:<br \/>\nFrom <\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">&lt;Disk ovf:capacity=&quot;8589934592&quot; ovf:diskId=&quot;vmdisk2&quot; ovf:fileRef=&quot;file1&quot;\u2026<\/pre>\n<p>To<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">&lt;Disk ovf:capacity=&quot;28589934592&quot; ovf:diskId=&quot;vmdisk2&quot; ovf:fileRef=&quot;file1&quot;\u2026<\/pre>\n<p>Then I started the VM to expand the fs<br \/>\nInitial situation (take a look at \/)<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nroot@machine:~# df -h\r\nFilesystem      Size  Used Avail Use% Mounted on\r\n\/dev\/dm-0       7.2G  5.7G  1.2G  84% \/\r\nudev             10M     0   10M   0% \/dev\r\ntmpfs           403M  5.5M  397M   2% \/run\r\ntmpfs          1006M     0 1006M   0% \/dev\/shm\r\ntmpfs           5.0M     0  5.0M   0% \/run\/lock\r\ntmpfs          1006M     0 1006M   0% \/sys\/fs\/cgroup\r\n\/dev\/sda1       236M   33M  191M  15% \/boot\r\n<\/pre>\n<p>Physical Volumes<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nroot@machine:~# pvs\r\n  PV         VG               Fmt  Attr PSize  PFree\r\n  \/dev\/sda5  debian-jessie-vg lvm2 a--  26.38g 18.62g\r\n<\/pre>\n<p>Virtual Groups<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nroot@machine:~# vgs\r\n  VG               #PV #LV #SN Attr   VSize  VFree\r\n  debian-jessie-vg   1   2   0 wz--n- 26.38g 18.62g\r\n<\/pre>\n<p>Logical Volumes<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nroot@machine:~# lvs\r\n  LV     VG               Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert\r\n  root   debian-jessie-vg -wi-ao----   7.39g\r\n  swap_1 debian-jessie-vg -wi-ao---- 376.00m\r\n<\/pre>\n<p>So I have one PV with 18 free GB (that&#8217;s thanks to the machine.ovf modification), one VG and two LVS. The one I want to increase is &#8220;root&#8221;.<br \/>\nJust a last check:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nroot@machine:~# pvscan\r\n  PV \/dev\/sda5   VG debian-jessie-vg   lvm2 &#x5B;26.38 GiB \/ 18.62 GiB free]\r\n  Total: 1 &#x5B;26.38 GiB] \/ in use: 1 &#x5B;26.38 GiB] \/ in no VG: 0 &#x5B;0   ]\r\nroot@machine:~# lvdisplay\r\n  --- Logical volume ---\r\n  LV Path                \/dev\/debian-jessie-vg\/root\r\n  LV Name                root\r\n  VG Name                debian-jessie-vg\r\n  LV UUID                OdIAov-a7qm-ThOR-58YP-D7FG-zq5n-r73dUq\r\n  LV Write Access        read\/write\r\n  LV Creation host, time debian-jessie, 2015-04-27 10:42:28 +0200\r\n  LV Status              available\r\n  # open                 1\r\n  LV Size                7.39 GiB\r\n  Current LE             1892\r\n  Segments               1\r\n  Allocation             inherit\r\n  Read ahead sectors     auto\r\n  - currently set to     256\r\n  Block device           254:0\r\n\r\n  --- Logical volume ---\r\n  LV Path                \/dev\/debian-jessie-vg\/swap_1\r\n  LV Name                swap_1\r\n  VG Name                debian-jessie-vg\r\n  LV UUID                dS5vEu-w8LQ-uoZd-IGk8-cmaK-8tBQ-ZtSyvO\r\n  LV Write Access        read\/write\r\n  LV Creation host, time debian-jessie, 2015-04-27 10:42:28 +0200\r\n  LV Status              available\r\n  # open                 2\r\n  LV Size                376.00 MiB\r\n  Current LE             94\r\n  Segments               1\r\n  Allocation             inherit\r\n  Read ahead sectors     auto\r\n  - currently set to     256\r\n  Block device           254:1\r\n\r\n<\/pre>\n<p>So the path for my LV is \/dev\/debian-jessie-vg\/root<\/p>\n<p>And&#8230;<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nroot@machine:~# vgdisplay\r\n  --- Volume group ---\r\n  VG Name               debian-jessie-vg\r\n  System ID\r\n  Format                lvm2\r\n  Metadata Areas        1\r\n  Metadata Sequence No  4\r\n  VG Access             read\/write\r\n  VG Status             resizable\r\n  MAX LV                0\r\n  Cur LV                2\r\n  Open LV               2\r\n  Max PV                0\r\n  Cur PV                1\r\n  Act PV                1\r\n  VG Size               26.38 GiB\r\n  PE Size               4.00 MiB\r\n  Total PE              6754\r\n  Alloc PE \/ Size       1986 \/ 7.76 GiB\r\n  Free  PE \/ Size       4768 \/ 18.62 GiB\r\n  VG UUID               V2oYD9-uoYy-sFLY-QSLG-FPyx-Ejce-QANYo4\r\n\r\n<\/pre>\n<p>&#8230;I have 4768 Free PE for it! :-)<\/p>\n<p>So, let&#8217;s use them. I extend first the LV:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nroot@machine:~# lvextend -l +4768 \/dev\/debian-jessie-vg\/root\r\n  Size of logical volume debian-jessie-vg\/root changed from 7.39 GiB (1892 extents) to 26.02 GiB (6660 extents).\r\n  Logical volume root successfully resized\r\n\r\n<\/pre>\n<p>Then I resize the fs<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nroot@machine:~# resize2fs \/dev\/debian-jessie-vg\/root\r\nresize2fs ... (it does it all automatically)\r\n\r\n<\/pre>\n<p>And that&#8217;s all!<br \/>\nLet&#8217;s check:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nroot@machine:~# df -h\r\nFilesystem      Size  Used Avail Use% Mounted on\r\n\/dev\/dm-0        26G  5.7G   19G  24% \/\r\nudev             10M     0   10M   0% \/dev\r\ntmpfs           403M  5.5M  397M   2% \/run\r\ntmpfs          1006M     0 1006M   0% \/dev\/shm\r\ntmpfs           5.0M     0  5.0M   0% \/run\/lock\r\ntmpfs          1006M     0 1006M   0% \/sys\/fs\/cgroup\r\n\/dev\/sda1       236M   33M  191M  15% \/boot\r\nroot@machine:~# lvdisplay\r\n  --- Logical volume ---\r\n  LV Path                \/dev\/debian-jessie-vg\/root\r\n  LV Name                root\r\n  VG Name                debian-jessie-vg\r\n  LV UUID                OdIAov-a7qm-ThOR-58YP-D7FG-zq5n-r73dUq\r\n  LV Write Access        read\/write\r\n  LV Creation host, time debian-jessie, 2015-04-27 10:42:28 +0200\r\n  LV Status              available\r\n  # open                 1\r\n  LV Size                26.02 GiB\r\n  Current LE             6660\r\n  Segments               2\r\n  Allocation             inherit\r\n  Read ahead sectors     auto\r\n  - currently set to     256\r\n  Block device           254:0\r\n\r\n  --- Logical volume ---\r\n  LV Path                \/dev\/debian-jessie-vg\/swap_1\r\n  LV Name                swap_1\r\n  VG Name                debian-jessie-vg\r\n  LV UUID                dS5vEu-w8LQ-uoZd-IGk8-cmaK-8tBQ-ZtSyvO\r\n  LV Write Access        read\/write\r\n  LV Creation host, time debian-jessie, 2015-04-27 10:42:28 +0200\r\n  LV Status              available\r\n  # open                 2\r\n  LV Size                376.00 MiB\r\n  Current LE             94\r\n  Segments               1\r\n  Allocation             inherit\r\n  Read ahead sectors     auto\r\n  - currently set to     256\r\n  Block device           254:1\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I was deploying a VM and I needed more space for \/. So first I turned off the machine and modified the machine.ovf file to increase de size of the hard disk: From &lt;Disk ovf:capacity=&quot;8589934592&quot; ovf:diskId=&quot;vmdisk2&quot; ovf:fileRef=&quot;file1&quot;\u2026 To &lt;Disk ovf:capacity=&quot;28589934592&quot; ovf:diskId=&quot;vmdisk2&quot; ovf:fileRef=&quot;file1&quot;\u2026 Then I started the VM to expand the fs Initial situation (take a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,22],"tags":[],"class_list":["post-1783","post","type-post","status-publish","format-standard","hentry","category-gnulinux","category-prompt"],"_links":{"self":[{"href":"http:\/\/guimi.net\/blogs\/hiparco\/wp-json\/wp\/v2\/posts\/1783","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/guimi.net\/blogs\/hiparco\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/guimi.net\/blogs\/hiparco\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/guimi.net\/blogs\/hiparco\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/guimi.net\/blogs\/hiparco\/wp-json\/wp\/v2\/comments?post=1783"}],"version-history":[{"count":4,"href":"http:\/\/guimi.net\/blogs\/hiparco\/wp-json\/wp\/v2\/posts\/1783\/revisions"}],"predecessor-version":[{"id":1787,"href":"http:\/\/guimi.net\/blogs\/hiparco\/wp-json\/wp\/v2\/posts\/1783\/revisions\/1787"}],"wp:attachment":[{"href":"http:\/\/guimi.net\/blogs\/hiparco\/wp-json\/wp\/v2\/media?parent=1783"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/guimi.net\/blogs\/hiparco\/wp-json\/wp\/v2\/categories?post=1783"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/guimi.net\/blogs\/hiparco\/wp-json\/wp\/v2\/tags?post=1783"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}