{"id":504,"date":"2018-06-05T09:31:08","date_gmt":"2018-06-05T09:31:08","guid":{"rendered":"http:\/\/wp.spoton.cz\/?p=504"},"modified":"2018-06-05T09:31:08","modified_gmt":"2018-06-05T09:31:08","slug":"resize-lvm-and-ext4-online","status":"publish","type":"post","link":"https:\/\/spoton.cz\/index.php\/2018\/06\/05\/resize-lvm-and-ext4-online\/","title":{"rendered":"Resize LVM and ext4 online"},"content":{"rendered":"<p>If you ever need to resize a device on a Unix like system and are using LVM as the underlying mediator and ext2\/3\/4 as the file system, it can be done <strong>without a reboot<\/strong>. This is quite handy for ESX and other virtual machines.\u00a0<\/p>\n<p><!--more--><\/p>\n<h3>Before doing all that comes, please resize the &#8220;physical&#8221; device &#8211; in our case the virtual disk in ESX<\/h3>\n<p>Mind you, this only works if and when the &#8220;physical&#8221; disk is used by LVM as RAW device. You have to resize the partition (e.g. \/dev\/sda2), if the LVM resides on a partition. You can check this by issuing<\/p>\n<pre># fdisk -l\n\n\nDisk \/dev\/sda: 53.7 GB, 53687091200 bytes, 104857600 sectors\nUnits = sectors of 1 * 512 = 512 bytes\nSector size (logical\/physical): 512 bytes \/ 512 bytes\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes\nDisk label type: dos\nDisk identifier: 0x000f06be\n\nDevice Boot Start End Blocks Id System\n\/dev\/sda1 * 2048 2099199 1048576 83 Linux\n\/dev\/sda2 2099200 104857599 51379200 8e Linux LVM\n<\/pre>\n<ol>\n<li>\n<p>First, we need to identify the resized disk. In our case, this is \/dev\/sdb<\/p>\n<pre>echo 1 &gt; \/sys\/class\/block\/sdb\/device\/rescan<\/pre>\n<\/li>\n<li>\n<p>If you omit any flags, the LVM partition will fill the whole device<\/p>\n<pre>pvresize \/dev\/sdb<\/pre>\n<\/li>\n<li>\n<p>Here, the boundaries for the LV need to be set explicitly<\/p>\n<pre>lvresize -L 35000 \/dev\/vg_appl\/lv_storage<\/pre>\n<\/li>\n<li>\n<p>File system resize can be once again done without any flags and it will fill the whole LV.<\/p>\n<pre>resize2fs \/dev\/vg_appl\/lv_storage<\/pre>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you ever need to resize a device on a Unix like system and are using LVM as the underlying [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":512,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4,5,7,9],"tags":[43,45,61,74,86],"_links":{"self":[{"href":"https:\/\/spoton.cz\/index.php\/wp-json\/wp\/v2\/posts\/504"}],"collection":[{"href":"https:\/\/spoton.cz\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/spoton.cz\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/spoton.cz\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/spoton.cz\/index.php\/wp-json\/wp\/v2\/comments?post=504"}],"version-history":[{"count":0,"href":"https:\/\/spoton.cz\/index.php\/wp-json\/wp\/v2\/posts\/504\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/spoton.cz\/index.php\/wp-json\/wp\/v2\/media\/512"}],"wp:attachment":[{"href":"https:\/\/spoton.cz\/index.php\/wp-json\/wp\/v2\/media?parent=504"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/spoton.cz\/index.php\/wp-json\/wp\/v2\/categories?post=504"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/spoton.cz\/index.php\/wp-json\/wp\/v2\/tags?post=504"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}