{"id":1464,"date":"2016-11-14T19:16:23","date_gmt":"2016-11-15T02:16:23","guid":{"rendered":"http:\/\/jim-zimmerman.com\/?p=1464"},"modified":"2016-11-14T19:16:23","modified_gmt":"2016-11-15T02:16:23","slug":"ubuntu-resize-partition-when-a-vmware-virtual-machine","status":"publish","type":"post","link":"https:\/\/jim-zimmerman.com\/?p=1464","title":{"rendered":"Ubuntu &#8211; resize partition when a VMware Virtual Machine."},"content":{"rendered":"<p>Ubuntu: 12.04 LTS<br \/>\nVMware ESXi: 5.5<\/p>\n<p>I wanted increase the store on one partition by 100GB to 250GB on a system and minimize down time.  I was almost able to pull it off.  I need one quick reboot to get the new size to show up.<\/p>\n<p>With the system up, I used the vSphere client and modifed the size of the disk.<\/p>\n<blockquote><p>root@myhostname~:# df -h<br \/>\nFilesystem                             Size  Used Avail Use% Mounted on<br \/>\n\/dev\/mapper\/vg_myhostname_subdir-lv_subdir          <strong>148G<\/strong>  125G   16G  90% \/mountpt\/subdir<\/p><\/blockquote>\n<blockquote><p>root@myhostname~:# mount | grep subdir<br \/>\n\/dev\/mapper\/vg_myhostname_subdir-lv_subdir on \/mountpt\/subdir type <strong>ext4<\/strong> (rw)<\/p><\/blockquote>\n<blockquote><p>root@myhostname~:# fdisk -l <\/p>\n<p>Disk \/dev\/sde: 161.1 GB, <strong>161061273600<\/strong> bytes<br \/>\n255 heads, 63 sectors\/track, 19581 cylinders, total 314572800 sectors<br \/>\nUnits = sectors of 1 * 512 = 512 bytes<br \/>\nSector size (logical\/physical): 512 bytes \/ 512 bytes<br \/>\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes<br \/>\nDisk identifier: 0x00000000<\/p>\n<p>Disk \/dev\/sde doesn&#8217;t contain a valid partition table<\/p><\/blockquote>\n<p>Scan for new hardware or changes:<\/p>\n<blockquote><p>root@myhostname~:# echo &#8220;- &#8211; -&#8221; > \/sys\/class\/scsi_host\/host0\/scan<br \/>\nroot@myhostname~:# echo &#8220;- &#8211; -&#8221; > \/sys\/class\/scsi_host\/host1\/scan<br \/>\nroot@myhostname~:# echo &#8220;- &#8211; -&#8221; > \/sys\/class\/scsi_host\/host2\/scan <\/p><\/blockquote>\n<p>Still didn&#8217;t show up with the new size:<\/p>\n<blockquote><p>root@myhostname~:# pvdisplay<br \/>\n  &#8212; Physical volume &#8212;<br \/>\n  PV Name               \/dev\/sde<br \/>\n  VG Name               vg_myhostname_subdir<br \/>\n  PV Size               150.00 GiB \/ not usable 4.00 MiB<br \/>\n  Allocatable           yes (but full)<br \/>\n  PE Size               4.00 MiB<br \/>\n  Total PE              38399<br \/>\n  Free PE               0<br \/>\n  Allocated PE          38399<br \/>\n  PV UUID               dkK9oP-XQq2-p2CM-BVBZ-pv0r-J9cP-Hnc0UB<\/p><\/blockquote>\n<p>I rebooted at this point.<\/p>\n<blockquote><p>root@myhostname:~# fdisk \/dev\/sde<br \/>\nDevice contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel<br \/>\nBuilding a new DOS disklabel with disk identifier 0xeeb3e856.<br \/>\nChanges will remain in memory only, until you decide to write them.<br \/>\nAfter that, of course, the previous content won&#8217;t be recoverable.<\/p>\n<p>Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)<\/p>\n<p>Command (m for help): p<\/p>\n<p>Disk \/dev\/sde: 268.4 GB, <strong>268435456000<\/strong> bytes<br \/>\n255 heads, 63 sectors\/track, 32635 cylinders, total 524288000 sectors<br \/>\nUnits = sectors of 1 * 512 = 512 bytes<br \/>\nSector size (logical\/physical): 512 bytes \/ 512 bytes<br \/>\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes<br \/>\nDisk identifier: 0xeeb3e856<\/p>\n<p>   Device Boot      Start         End      Blocks   Id  System<\/p>\n<p>Command (m for help): quit<\/p><\/blockquote>\n<blockquote><p>root@myhostname:~# pvdisplay<br \/>\n  &#8212; Physical volume &#8212;<br \/>\n  PV Name               \/dev\/sde<br \/>\n  VG Name               vg_myhostname_subdir<br \/>\n  PV Size               150.00 GiB \/ not usable 4.00 MiB<br \/>\n  Allocatable           yes (but full)<br \/>\n  PE Size               4.00 MiB<br \/>\n  Total PE              38399<br \/>\n  Free PE               0<br \/>\n  Allocated PE          38399<br \/>\n  PV UUID               dkK9oP-XQq2-p2CM-BVBZ-pv0r-J9cP-Hnc0UB<\/p><\/blockquote>\n<p>Resize physical volume to reflect the new size:<\/p>\n<blockquote><p>root@myhostname:~# pvresize \/dev\/sde<br \/>\n  Physical volume &#8220;\/dev\/sde&#8221; changed<br \/>\n  1 physical volume(s) resized \/ 0 physical volume(s) not resized<\/p><\/blockquote>\n<blockquote><p>root@myhostname:~# pvdisplay \/dev\/sde<br \/>\n  &#8212; Physical volume &#8212;<br \/>\n  PV Name               \/dev\/sde<br \/>\n  VG Name               vg_myhostname_subdir<br \/>\n<strong>  PV Size               250.00 GiB \/ not usable 3.81 MiB<\/strong><br \/>\n  Allocatable           yes<br \/>\n  PE Size               4.00 MiB<br \/>\n  Total PE              63999<br \/>\n  Free PE               25600<br \/>\n  Allocated PE          38399<br \/>\n  PV UUID               dkK9oP-XQq2-p2CM-BVBZ-pv0r-J9cP-Hnc0UB<\/p><\/blockquote>\n<p>Interestingly, the volume group updated with the new size:<\/p>\n<blockquote><p>root@myhostname:~# vgdisplay<br \/>\n  &#8212; Volume group &#8212;<br \/>\n  VG Name               vg_myhostname_subdir<br \/>\n  System ID<br \/>\n  Format                lvm2<br \/>\n  Metadata Areas        1<br \/>\n  Metadata Sequence No  3<br \/>\n  VG Access             read\/write<br \/>\n  VG Status             resizable<br \/>\n  MAX LV                0<br \/>\n  Cur LV                1<br \/>\n  Open LV               1<br \/>\n  Max PV                0<br \/>\n  Cur PV                1<br \/>\n  Act PV                1<br \/>\n<strong>  VG Size               250.00 GiB<\/strong><br \/>\n  PE Size               4.00 MiB<br \/>\n  Total PE              63999<br \/>\n  Alloc PE \/ Size       38399 \/ 150.00 GiB<br \/>\n  Free  PE \/ Size       25600 \/ 100.00 GiB<br \/>\n  VG UUID               QNgKYt-ueHo-hq54-kvWB-HRcd-3Guq-yfBwhu<\/p><\/blockquote>\n<p>However, the logical volume did not:<\/p>\n<blockquote><p>root@myhostname:~# lvdisplay<br \/>\n  &#8212; Logical volume &#8212;<br \/>\n  LV Name                \/dev\/vg_myhostname_subdir\/lv_subdir<br \/>\n  VG Name                vg_myhostname_subdir<br \/>\n  LV UUID                D4xZEe-yAfH-pJoH-51Na-5l2B-Baqu-b37tOw<br \/>\n  LV Write Access        read\/write<br \/>\n  LV Status              available<br \/>\n  # open                 1<br \/>\n<strong>  LV Size                150.00 GiB<\/strong><br \/>\n  Current LE             38399<br \/>\n  Segments               1<br \/>\n  Allocation             inherit<br \/>\n  Read ahead sectors     auto<br \/>\n  &#8211; currently set to     256<br \/>\n  Block device           252:1<\/p><\/blockquote>\n<p>So, I had to extend it:<\/p>\n<blockquote><p>root@myhostname:~# lvextend \/dev\/vg_myhostname_subdir\/lv_subdir \/dev\/sde<br \/>\n<strong>  Extending logical volume lv_subdir to 250.00 GiB<\/strong><br \/>\n  Logical volume lv_subdir successfully resized<\/p><\/blockquote>\n<blockquote><p>root@myhostname:~# lvdisplay<br \/>\n  &#8212; Logical volume &#8212;<br \/>\n  LV Name                \/dev\/vg_myhostname_subdir\/lv_subdir<br \/>\n  VG Name                vg_myhostname_subdir<br \/>\n  LV UUID                D4xZEe-yAfH-pJoH-51Na-5l2B-Baqu-b37tOw<br \/>\n  LV Write Access        read\/write<br \/>\n  LV Status              available<br \/>\n  # open                 1<br \/>\n<strong>  LV Size                250.00 GiB<\/strong><br \/>\n  Current LE             63999<br \/>\n  Segments               1<br \/>\n  Allocation             inherit<br \/>\n  Read ahead sectors     auto<br \/>\n  &#8211; currently set to     256<br \/>\n  Block device           252:1<\/p><\/blockquote>\n<p>Now, to resize the filesystem:<\/p>\n<blockquote><p>root@myhostname:~# <strong>resize2fs \/dev\/mapper\/vg_myhostname_subdir-lv_subdir<\/strong><br \/>\nresize2fs 1.42 (29-Nov-2011)<br \/>\nFilesystem at \/dev\/mapper\/vg_myhostname_subdir-lv_subdir is mounted on \/mountpt\/subdir; on-line resizing required<br \/>\nold_desc_blocks = 10, new_desc_blocks = 16<br \/>\nThe filesystem on \/dev\/mapper\/vg_myhostname_subdir-lv_subdir is now 65534976 blocks long.<\/p><\/blockquote>\n<p>Success:<\/p>\n<blockquote><p>root@myhostname:~# df -h<br \/>\nFilesystem                             Size  Used Avail Use% Mounted on<br \/>\n\/dev\/mapper\/vg_myhostname_subdir-lv_subdir          <strong>247G<\/strong>  125G  110G  54% \/mountpt\/subdir<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Ubuntu: 12.04 LTS VMware ESXi: 5.5 I wanted increase the store on one partition by 100GB to 250GB on a system and minimize down time. I was almost able to pull it off. I need one quick reboot to get the new size to show up. With the system up, I used the vSphere client [&#038;hellip<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[438,132,33,303],"class_list":["post-1464","post","type-post","status-publish","format-standard","hentry","category-documentation","tag-resize","tag-ubuntu","tag-vmware","tag-volume"],"share_on_mastodon":{"url":"","error":""},"_links":{"self":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/posts\/1464","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1464"}],"version-history":[{"count":5,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/posts\/1464\/revisions"}],"predecessor-version":[{"id":1469,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/posts\/1464\/revisions\/1469"}],"wp:attachment":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1464"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1464"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1464"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}