{"id":109,"date":"2023-03-19T08:34:44","date_gmt":"2023-03-19T07:34:44","guid":{"rendered":"http:\/\/10.4.44.99:10084\/?p=109"},"modified":"2023-03-19T08:34:44","modified_gmt":"2023-03-19T07:34:44","slug":"centos-resize-an-lvm-physical-volume-without-a-reboot","status":"publish","type":"post","link":"https:\/\/www.winni.at\/wordpress\/?p=109","title":{"rendered":"Centos | Resize an LVM physical volume without a reboot"},"content":{"rendered":"\n<p>First unmound everything that uses the given volume group<\/p>\n\n\n\n<p>List all the logical volumes that are in vol1<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>lvdisplay \/dev\/vol01<\/code><\/pre>\n\n\n\n<p>&nbsp; &#8212; Logical volume &#8212;<br>&nbsp; LV Name&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/dev\/vol01\/lv01<br>&nbsp; VG Name&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vol01<br>&nbsp; LV UUID&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; q3eQP3-4V9E-7yvo-LUZR-zbXz-F2Mh-Pn5fDt<br>&nbsp; LV Write Access&nbsp; &nbsp; &nbsp; &nbsp; read\/write<br>&nbsp; LV Status&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; available<br>&nbsp; # open&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1<br>&nbsp; LV Size&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 139.70 GB<br>&nbsp; Current LE&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;35762<br>&nbsp; Segments&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;2<br>&nbsp; Allocation&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;inherit<br>&nbsp; Read ahead sectors&nbsp; &nbsp; &nbsp;auto<br>&nbsp; &#8211; currently set to&nbsp; &nbsp; &nbsp;256<br>&nbsp; Block device&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;254:0<br>&nbsp; &nbsp;<br>&nbsp; &#8212; Logical volume &#8212;<br>&nbsp; LV Name&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/dev\/vol01\/lv02<br>&nbsp; VG Name&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vol01<br>&nbsp; LV UUID&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; b53h7W-VO2U-3Ok5-WvW3-GbDp-Tbvb-6bbdkw<br>&nbsp; LV Write Access&nbsp; &nbsp; &nbsp; &nbsp; read\/write<br>&nbsp; LV Status&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; available<br>&nbsp; # open&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1<br>&nbsp; LV Size&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 29.31 GB<br>&nbsp; Current LE&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;7504<br>&nbsp; Segments&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1<br>&nbsp; Allocation&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;inherit<br>&nbsp; Read ahead sectors&nbsp; &nbsp; &nbsp;auto<br>&nbsp; &#8211; currently set to&nbsp; &nbsp; &nbsp;256<br>&nbsp; Block device&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;254:1<br><\/p>\n\n\n\n<p>Now unmount all these volumes (if they are mounted)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>umount \/dev\/vol01\/lv01\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>umount \/dev\/vol01\/lv02\n<\/code><\/pre>\n\n\n\n<p>In case you get a &#8220;device is busy&#8221; error, check out what processes use them (lsof \/dev\/vol01\/lv01) and stop\/kill them.<br>Now deactive the volume group.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vgchange -a n vol01\n<\/code><\/pre>\n\n\n\n<p>Increase the size of the sda2 partition to the desired value.<br>You do this by deleting the partition and recreating it with a higher end cylinder.<br>I assume that pvresize can handle partition expansions only if the partition start remains the same and the partition end cylinder is moved to a higher value.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>fdisk \/dev\/sda<\/code><\/pre>\n\n\n\n<p>The number of cylinders for this disk is set to 60801.<br>There is nothing wrong with that, but this is larger than 1024,<br>and could in certain setups cause problems with:<br>1) software that runs at boot time (e.g., old versions of LILO)<br>2) booting and partitioning software from other OSs<br>&nbsp; &nbsp;(e.g., DOS FDISK, OS\/2 FDISK)<br><br>Command (m for help):&nbsp;<strong>p<\/strong><br><br>Disk \/dev\/sda: 500.1 GB, 500107862016 bytes<br>255 heads, 63 sectors\/track, 60801 cylinders<br>Units = cylinders of 16065 * 512 = 8225280 bytes<br>Disk identifier: 0x000e4bad<br><br>&nbsp; &nbsp;Device Boot&nbsp; &nbsp; &nbsp; Start&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;End&nbsp; &nbsp; &nbsp; Blocks&nbsp; &nbsp;Id&nbsp; System<br>\/dev\/sda1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;486&nbsp; &nbsp; &nbsp;3903763+&nbsp; 83&nbsp; Linux<br>\/dev\/sda2&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;487&nbsp; &nbsp; &nbsp; &nbsp;18722&nbsp; &nbsp;146480670&nbsp; &nbsp;8e&nbsp; Linux LVM<br><br>Command (m for help):&nbsp;<strong>d<\/strong><br>Partition number (1-4):&nbsp;<strong>2<\/strong><br><br>Command (m for help):&nbsp;<strong>n<\/strong><br>Command action<br>&nbsp; &nbsp;e&nbsp; &nbsp;extended<br>&nbsp; &nbsp;p&nbsp; &nbsp;primary partition (1-4)<br><strong>p<\/strong><br>Partition number (1-4):&nbsp;<strong>2<\/strong><br>First cylinder (487-60801, default 487):&nbsp;<br>Using default value 487<br>Last cylinder or +size or +sizeM or +sizeK (487-60801, default 60801):&nbsp;<br>Using default value 60801<br><br>Command (m for help):<strong>&nbsp;t<\/strong><br>Partition number (1-4):&nbsp;<strong>2<\/strong><br>Hex code (type L to list codes):&nbsp;<strong>8e<\/strong><br>Changed system type of partition 2 to 8e (Linux LVM)<br><br>Command (m for help):&nbsp;<strong>p<\/strong><br><br>Disk \/dev\/sda: 500.1 GB, 500107862016 bytes<br>255 heads, 63 sectors\/track, 60801 cylinders<br>Units = cylinders of 16065 * 512 = 8225280 bytes<br>Disk identifier: 0x000e4bad<br><br>&nbsp; &nbsp;Device Boot&nbsp; &nbsp; &nbsp; Start&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;End&nbsp; &nbsp; &nbsp; Blocks&nbsp; &nbsp;Id&nbsp; System<br>\/dev\/sda1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;486&nbsp; &nbsp; &nbsp;3903763+&nbsp; 83&nbsp; Linux<br>\/dev\/sda2&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;487&nbsp; &nbsp; &nbsp; &nbsp;60801&nbsp; &nbsp;484480237+&nbsp; 8e&nbsp; Linux LVM<br><br>Command (m for help):&nbsp;<strong>w<\/strong><br>The partition table has been altered!<br><br>Calling ioctl() to re-read partition table.<br><br>WARNING: Re-reading the partition table failed with error 16: Device or resource busy.<br>The kernel still uses the old table.<br>The new table will be used at the next reboot.<br>Syncing disks.<br><br>Now comes the interesting part: we force the system with partprobe to re-read the partition table.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pvdisplay \/dev\/sda2\n<\/code><\/pre>\n\n\n\n<p><br>&nbsp; &#8212; Physical volume &#8212;<br>&nbsp; PV Name&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\/dev\/sda2<br>&nbsp; VG Name&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;vol01<br>&nbsp; PV Size&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;139.69 GB \/ not usable 3.53 MB<br>&nbsp; Allocatable&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;yes (but full)<br>&nbsp; PE Size (KByte)&nbsp; &nbsp; &nbsp; &nbsp;4096<br>&nbsp; Total PE&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 35761<br>&nbsp; Free PE&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0<br>&nbsp; Allocated PE&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 35761<br>&nbsp; PV UUID&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;S0cDcl-7mr8-2AAb-172u-HClq-J2aQ-DfC2V5<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>partprobe\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>pvresize \/dev\/sda2<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>pvdisplay \/dev\/sda2<\/code><\/pre>\n\n\n\n<p>&nbsp; &#8212; Physical volume &#8212;<\/p>\n\n\n\n<p>&nbsp; PV Name&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\/dev\/sda2<br>&nbsp; VG Name&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;vol01<br>&nbsp; PV Size&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;462.04 GB \/ not usable 1.04 MB<br>&nbsp; Allocatable&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;yes&nbsp;<br>&nbsp; PE Size (KByte)&nbsp; &nbsp; &nbsp; &nbsp;4096<br>&nbsp; Total PE&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 118281<br>&nbsp; Free PE&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;82520<br>&nbsp; Allocated PE&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 35761<br>&nbsp; PV UUID&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;S0cDcl-7mr8-2AAb-172u-HClq-J2aQ-DfC2V5<\/p>\n\n\n\n<p><br># Voala! \ud83d\ude42 The physical volume got increased.<br># Time to reactivate the volume group.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vgchange -a y vol01\n<\/code><\/pre>\n\n\n\n<p># Now check the volume group details.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vgdisplay vol01<\/code><\/pre>\n\n\n\n<p>&nbsp; &#8212; Volume group &#8212;<br>&nbsp; VG Name&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;vol01<br>&nbsp; System ID&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>&nbsp; Format&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lvm2<br>&nbsp; Metadata Areas&nbsp; &nbsp; &nbsp; &nbsp; 2<br>&nbsp; Metadata Sequence No&nbsp; 18<br>&nbsp; VG Access&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;read\/write<br>&nbsp; VG Status&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;resizable<br>&nbsp; MAX LV&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0<br>&nbsp; Cur LV&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 3<br>&nbsp; Open LV&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;3<br>&nbsp; Max PV&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0<br>&nbsp; Cur PV&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2<br>&nbsp; Act PV&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2<br>&nbsp; VG Size&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;927.79 GB<br>&nbsp; PE Size&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;4.00 MB<br>&nbsp; Total PE&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 237515<br>&nbsp; Alloc PE \/ Size&nbsp; &nbsp; &nbsp; &nbsp;68866 \/ 269.01 GB<br>&nbsp; Free&nbsp; PE \/ Size&nbsp; &nbsp; &nbsp; &nbsp;168649 \/ 658.79 GB<br>&nbsp; VG UUID&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0eY2tg-AOny-XsDL-wfLR-d290-2jxO-TDTNnQ<\/p>\n\n\n\n<p>You can now use lvextend to increase logical volumes in the volume group.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>lvextend -L +10G --name lv01 \/dev\/vol01<\/code><\/pre>\n\n\n\n<p>And resize2fs to extend the Ext2\/3 filesystem on the logical volume.<\/p>\n\n\n\n<p>And xfs_growfs \/mountpoint to extend the xfs filesystem on the logical volume.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>resize2fs \/dev\/vol01\/lv01\n<\/code><\/pre>\n\n\n\n<p>And finally mount the filesystems.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mount \/dev\/vol01\/lv01\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>mount \/dev\/vol01\/lv02<\/code><\/pre>\n\n\n\n<p>You&#8217;re now ready.<\/p>\n\n\n\n<p>source:&nbsp;<a href=\"http:\/\/muzso.hu\/2009\/07\/28\/how-to-resize-an-lvm-physical-volume-without-a-reboot\">http:\/\/muzso.hu\/2009\/07\/28\/how-to-resize-an-lvm-physical-volume-without-a-reboot<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>First unmound everything that uses the given volume group List all the logical volumes that are in vol1 &nbsp; &#8212;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"colormag_page_container_layout":"default_layout","colormag_page_sidebar_layout":"default_layout","footnotes":""},"categories":[3],"tags":[15,117,119,120,128,133,163,164],"class_list":["post-109","post","type-post","status-publish","format-standard","hentry","category-kb","tag-centos","tag-linux","tag-linux-lvm","tag-linux-lvm-resize","tag-lvm","tag-lvmresize","tag-resize-lvm","tag-resize-partition"],"_links":{"self":[{"href":"https:\/\/www.winni.at\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/109","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.winni.at\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.winni.at\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.winni.at\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.winni.at\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=109"}],"version-history":[{"count":0,"href":"https:\/\/www.winni.at\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/109\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.winni.at\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=109"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.winni.at\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=109"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.winni.at\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=109"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}