{"id":6115,"date":"2016-07-31T16:31:49","date_gmt":"2016-07-31T08:31:49","guid":{"rendered":"http:\/\/rmohan.com\/?p=6115"},"modified":"2016-07-31T16:31:49","modified_gmt":"2016-07-31T08:31:49","slug":"reduce-a-logical-volume-online-without-any-data-loss","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=6115","title":{"rendered":"REDUCE A LOGICAL VOLUME ONLINE WITHOUT ANY DATA LOSS"},"content":{"rendered":"<p>It\u2019s possible to reduce the size of a logical volume without any data loss occurring.<\/p>\n<p>The first step is to check the existing size of the logical volume:<\/p>\n<p>[root@slave ~]# lvdisplay \/dev\/myvg\/mylv<br \/>\n  &#8212; Logical volume &#8212;<br \/>\n  LV Path                \/dev\/myvg\/mylv<br \/>\n  LV Name                mylv<br \/>\n  VG Name                myvg<br \/>\n  LV UUID                K31i4c-mJmI-mNhJ-CvkB-c38D-7wCd-I2erTM<br \/>\n  LV Write Access        read\/write<br \/>\n  LV Creation host, time slave, 2014-10-13 20:01:22 -0400<br \/>\n  LV Status              available<br \/>\n  # open                 1<br \/>\n  LV Size                4.00 GiB<br \/>\n  Current LE             1024<br \/>\n  Segments               2<br \/>\n  Allocation             inherit<br \/>\n  Read ahead sectors     auto<br \/>\n  &#8211; currently set to     8192<br \/>\n  Block device           253:2<br \/>\nThe current size is 4 GB, although we would like to change the size to 2 GB.<\/p>\n<p>As a cautious measure, run fsck on the logical volume to ensure that the file system is in a consistent state.<\/p>\n<p>[root@slave ~]# fsck \/dev\/myvg\/mylv<br \/>\nWe will now resize the file system to 2 GB.<\/p>\n<p>[root@slave ~]# resize2fs \/dev\/myvg\/mylv 2G<br \/>\nThe final step is to reduce the logical volume using lvreduce.<\/p>\n<p>[root@slave ~]# lvreduce \/dev\/myvg\/mylv -L 2G<br \/>\n  WARNING: Reducing active and open logical volume to 2.00 GiB<br \/>\n  THIS MAY DESTROY YOUR DATA (filesystem etc.)<br \/>\nDo you really want to reduce mylv? [y\/n]: y<br \/>\n  Reducing logical volume mylv to 2.00 GiB<br \/>\n  Logical volume mylv successfully resized<br \/>\nVerify the new logical volume size using lvdisplay.<\/p>\n<p>[root@slave ~]# lvdisplay \/dev\/myvg\/mylv<br \/>\n  &#8212; Logical volume &#8212;<br \/>\n  LV Path                \/dev\/myvg\/mylv<br \/>\n  LV Name                mylv<br \/>\n  VG Name                myvg<br \/>\n  LV UUID                K31i4c-mJmI-mNhJ-CvkB-c38D-7wCd-I2erTM<br \/>\n  LV Write Access        read\/write<br \/>\n  LV Creation host, time slave, 2014-10-13 20:01:22 -0400<br \/>\n  LV Status              available<br \/>\n  # open                 1<br \/>\n  LV Size                2.00 GiB<br \/>\n  Current LE             512<br \/>\n  Segments               1<br \/>\n  Allocation             inherit<br \/>\n  Read ahead sectors     auto<br \/>\n  &#8211; currently set to     8192<br \/>\n  Block device           253:2<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It\u2019s possible to reduce the size of a logical volume without any data loss occurring.<\/p>\n<p>The first step is to check the existing size of the logical volume:<\/p>\n<p>[root@slave ~]# lvdisplay \/dev\/myvg\/mylv &#8212; Logical volume &#8212; LV Path \/dev\/myvg\/mylv LV Name mylv VG Name myvg LV UUID K31i4c-mJmI-mNhJ-CvkB-c38D-7wCd-I2erTM LV Write Access read\/write LV Creation host, [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[73],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6115"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6115"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6115\/revisions"}],"predecessor-version":[{"id":6116,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6115\/revisions\/6116"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6115"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6115"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6115"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}