{"id":5679,"date":"2015-03-24T13:00:26","date_gmt":"2015-03-24T10:00:26","guid":{"rendered":"http:\/\/www.hbyconsultancy.com\/?p=5055"},"modified":"2015-03-24T13:00:26","modified_gmt":"2015-03-24T10:00:26","slug":"resize-lvm-partition-on-the-fly","status":"publish","type":"post","link":"https:\/\/hbyconsultancy.com\/2015\/03\/resize-lvm-partition-on-the-fly.html","title":{"rendered":"Resize LVM partition on the fly"},"content":{"rendered":"

I used to limit my Ubuntu partition size for many reasons, for example if my HD is 1TB, my Ubuntu partition is about 100G only. But this partition might get full quickly as you can see below I have used 94% of my storage :<\/p>\n

$ df -h\nFilesystem                   Size  Used Avail Use% Mounted on\n\/dev\/mapper\/ubuntu--vg-root   84G   75G  5.5G  94% \/<\/pre>\n

To resize this on the fly, let’s add 50G :<\/p>\n

$ sudo lvextend -L+50G \/dev\/ubuntu-vg\/root\n Extending logical volume root to 135.00 GiB\n  Logical volume root successfully resized<\/pre>\n

That’s it, we just need to tell our filesystem that the volume size changed :<\/p>\n

$ sudo resize2fs \/dev\/ubuntu-vg\/root\nresize2fs 1.42.9 (4-Feb-2014)\nFilesystem at \/dev\/ubuntu-vg\/root is mounted on \/; on-line resizing required\nold_desc_blocks = 6, new_desc_blocks = 9\nThe filesystem on \/dev\/ubuntu-vg\/root is now 35389440 blocks long.<\/pre>\n

Now if we run df again we can see that I have now 53G available but not 55.5G, since before I had 5.5G available. The reason is that I was working in the same time on that partition and used 2.5G in the meantime.<\/p>\n

$ df -h\nFilesystem                   Size  Used Avail Use% Mounted on\n\/dev\/mapper\/ubuntu--vg-root  133G   75G   53G  59% \/<\/pre>\n

The end.<\/p>\n","protected":false},"excerpt":{"rendered":"

I used to limit my Ubuntu partition size for many reasons, for example if my HD is 1TB, my Ubuntu partition is about 100G only. But this partition might get full quickly as you can see below I have used 94% of my storage : $ df -h Filesystem Size Used Avail Use% Mounted on […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[152],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/hbyconsultancy.com\/wp-json\/wp\/v2\/posts\/5679"}],"collection":[{"href":"https:\/\/hbyconsultancy.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hbyconsultancy.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hbyconsultancy.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hbyconsultancy.com\/wp-json\/wp\/v2\/comments?post=5679"}],"version-history":[{"count":0,"href":"https:\/\/hbyconsultancy.com\/wp-json\/wp\/v2\/posts\/5679\/revisions"}],"wp:attachment":[{"href":"https:\/\/hbyconsultancy.com\/wp-json\/wp\/v2\/media?parent=5679"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hbyconsultancy.com\/wp-json\/wp\/v2\/categories?post=5679"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hbyconsultancy.com\/wp-json\/wp\/v2\/tags?post=5679"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}