{"id":111,"date":"2011-07-18T14:21:47","date_gmt":"2011-07-18T14:21:47","guid":{"rendered":"http:\/\/www.salsaunited.net\/blog\/?p=111"},"modified":"2011-07-18T14:21:47","modified_gmt":"2011-07-18T14:21:47","slug":"howto-extend-lvm-for-a-kvm-guest","status":"publish","type":"post","link":"https:\/\/blog.domb.net\/?p=111","title":{"rendered":"Howto extend lvm for a KVM guest"},"content":{"rendered":"<p><strong>Howto Resize\u00a0 KVM lvm guest image<\/strong><\/p>\n<p>Here is how you add 5 GB of disk space to your guest:<\/p>\n<p>1a. \u00a0<em># qemu-img create -f raw temp.img 5G<\/em><\/p>\n<p>2.a <em># cat oldimage.img temp.img &gt; newdiskimage.img<\/em><\/p>\n<p><em>Sometimes you don&#8217;t have enough space to create a complete new image. If thats the case you can use this<\/em><\/p>\n<p>1.b #qemu-img create -f raw temp.raw 5G<\/p>\n<p>2.b #cat temp.raw &gt;&gt;\u00a0 oldimage.img<em><\/em><\/p>\n<p>3. After createing the new disk image you can start your VM and login<\/p>\n<p>4. Delete the old lvm partition with fdisk (the one in the VM!).<\/p>\n<p><em># \u00a0fdisk -l to see partition<\/em><\/p>\n<p><em># fdisk \/dev\/vda <\/em><\/p>\n<p><em>#\u00a0Delete lvm <\/em>(this is the partition with the type 8e)<\/p>\n<p># Create new one which starts at the same cylinder as the one you deleted (type 8e)<\/p>\n<p>5. reboot the guest<\/p>\n<p><em># init 6<\/em><\/p>\n<p>6. \u00a0Now after rebooting and logging in to the VM you can do a<\/p>\n<p><em># fdisk -l<\/em><\/p>\n<p>and you&#8217;ll see the new space you&#8217;ve just added to the disk. So lets extend the physical volume, volume group and logical volume (named bla):<\/p>\n<p><em># pvresize \/dev\/vda2<\/em><\/p>\n<p><em> #lvresize \/dev\/Volgroup\/bla -L +5G<\/em><\/p>\n<p><em> #resize2fs \/dev\/Volgroup\/bla<\/em><\/p>\n<p>7. If everything went well you should see the new diskspace with the command<\/p>\n<p># df -h<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Howto Resize\u00a0 KVM lvm guest image Here is how you add 5 GB of disk space to your guest: 1a. \u00a0# qemu-img create -f raw temp.img 5G 2.a # cat oldimage.img temp.img &gt; newdiskimage.img Sometimes you don&#8217;t have enough space to create a complete new image. If thats the case you can use this 1.b&#8230;<\/p>\n","protected":false},"author":2,"featured_media":159,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_themeisle_gutenberg_block_has_review":false,"footnotes":""},"categories":[3,4],"tags":[],"class_list":["post-111","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","category-virtualization"],"_links":{"self":[{"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/posts\/111","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=111"}],"version-history":[{"count":1,"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/posts\/111\/revisions"}],"predecessor-version":[{"id":160,"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/posts\/111\/revisions\/160"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/media\/159"}],"wp:attachment":[{"href":"https:\/\/blog.domb.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=111"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=111"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=111"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}