{"id":2696,"date":"2015-10-02T00:50:57","date_gmt":"2015-10-02T00:50:57","guid":{"rendered":"https:\/\/qbytes.cloud\/?p=2696"},"modified":"2015-10-02T00:50:57","modified_gmt":"2015-10-02T00:50:57","slug":"resize-a-cloud-server","status":"publish","type":"post","link":"https:\/\/www.qbytes.cloud\/index.php\/2015\/10\/02\/resize-a-cloud-server\/","title":{"rendered":"Resize a Cloud Server"},"content":{"rendered":"<p>New server created with 20GB Drive.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# fdisk -l\n\nDisk \/dev\/xvda: 21.5 GB, 21474836480 bytes\n255 heads, 63 sectors\/track, 2610 cylinders\nUnits = cylinders of 16065 * 512 = 8225280 bytes\nSector size (logical\/physical): 512 bytes \/ 512 bytes\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes\nDisk identifier: 0x00028fed\n\n    Device Boot      Start         End      Blocks   Id  System\n\/dev\/xvda1   *           1          66      524288   83  Linux\nPartition 1 does not end on cylinder boundary.\n\/dev\/xvda2              66        2611    20446208   8e  Linux LVM\n\nDisk \/dev\/mapper\/centos-swap: 1073 MB, 1073741824 bytes\n255 heads, 63 sectors\/track, 130 cylinders\nUnits = cylinders of 16065 * 512 = 8225280 bytes\nSector size (logical\/physical): 512 bytes \/ 512 bytes\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes\nDisk identifier: 0x00000000\n\n\nDisk \/dev\/mapper\/centos-root: 19.9 GB, 19860029440 bytes\n255 heads, 63 sectors\/track, 2414 cylinders\nUnits = cylinders of 16065 * 512 = 8225280 bytes\nSector size (logical\/physical): 512 bytes \/ 512 bytes\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes\nDisk identifier: 0x00000000\n<\/pre>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n\n# lvs\n  LV   VG     Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert\n  root centos -wi-ao---- 18.50g\n  swap centos -wi-ao----  1.00g\n\n<\/pre>\n<p>Check Physical Volumes<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# pvs\n  PV         VG     Fmt  Attr PSize  PFree\n  \/dev\/xvda2 centos lvm2 a--  19.50g    0\n<\/pre>\n<p>Now I upgrade the cloud server<br \/>\nto<br \/>\n1024 MB RAM, 1 Core, 40 GB Disk<\/p>\n<p>After upgrade&#8230;<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# fdisk -l\n\nDisk \/dev\/xvda: 40.8 GB, 40802189312 bytes\n255 heads, 63 sectors\/track, 4960 cylinders\nUnits = cylinders of 16065 * 512 = 8225280 bytes\nSector size (logical\/physical): 512 bytes \/ 512 bytes\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes\nDisk identifier: 0x00028fed\n\n    Device Boot      Start         End      Blocks   Id  System\n\/dev\/xvda1   *           1          66      524288   83  Linux\nPartition 1 does not end on cylinder boundary.\n\/dev\/xvda2              66        2611    20446208   8e  Linux LVM\n\nDisk \/dev\/mapper\/centos-swap: 1073 MB, 1073741824 bytes\n255 heads, 63 sectors\/track, 130 cylinders\nUnits = cylinders of 16065 * 512 = 8225280 bytes\nSector size (logical\/physical): 512 bytes \/ 512 bytes\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes\nDisk identifier: 0x00000000\n\n\nDisk \/dev\/mapper\/centos-root: 19.9 GB, 19860029440 bytes\n255 heads, 63 sectors\/track, 2414 cylinders\nUnits = cylinders of 16065 * 512 = 8225280 bytes\nSector size (logical\/physical): 512 bytes \/ 512 bytes\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes\nDisk identifier: 0x00000000\n\n<\/pre>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# lvs\n  LV   VG     Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert\n  root centos -wi-ao---- 18.50g\n  swap centos -wi-ao----  1.00g\n<\/pre>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# pvs\n  PV         VG     Fmt  Attr PSize  PFree\n  \/dev\/xvda2 centos lvm2 a--  19.50g    0\n<\/pre>\n<p>Create a new partition (n). Make it primary (p). The start and end should be the defaults provided by fdisk.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# fdisk \/dev\/xvda\n\nWARNING: DOS-compatible mode is deprecated. It&#039;s strongly recommended to\n         switch off the mode (command &#039;c&#039;) and change display units to\n         sectors (command &#039;u&#039;).\n\nCommand (m for help): p\n\nDisk \/dev\/xvda: 40.8 GB, 40802189312 bytes\n255 heads, 63 sectors\/track, 4960 cylinders\nUnits = cylinders of 16065 * 512 = 8225280 bytes\nSector size (logical\/physical): 512 bytes \/ 512 bytes\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes\nDisk identifier: 0x00028fed\n\n    Device Boot      Start         End      Blocks   Id  System\n\/dev\/xvda1   *           1          66      524288   83  Linux\nPartition 1 does not end on cylinder boundary.\n\/dev\/xvda2              66        2611    20446208   8e  Linux LVM\n\nCommand (m for help): n\nCommand action\n   e   extended\n   p   primary partition (1-4)\np\nPartition number (1-4): 3\nFirst cylinder (2611-4960, default 2611):\nUsing default value 2611\nLast cylinder, +cylinders or +size{K,M,G} (2611-4960, default 4960):\nUsing default value 4960\n\nCommand (m for help): w\nThe partition table has been altered!\n\nCalling ioctl() to re-read partition table.\n\nWARNING: Re-reading the partition table failed with error 16: Device or resource busy.\nThe kernel still uses the old table. The new table will be used at\nthe next reboot or after you run partprobe(8) or kpartx(8)\n<\/pre>\n<p>Reboot the VM so the kernel picks up the partition changes.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# shutdown -r now\n<\/pre>\n<p>Check for the new partition<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# fdisk -l\n\nDisk \/dev\/xvda: 40.8 GB, 40802189312 bytes\n255 heads, 63 sectors\/track, 4960 cylinders\nUnits = cylinders of 16065 * 512 = 8225280 bytes\nSector size (logical\/physical): 512 bytes \/ 512 bytes\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes\nDisk identifier: 0x00028fed\n\n    Device Boot      Start         End      Blocks   Id  System\n\/dev\/xvda1   *           1          66      524288   83  Linux\nPartition 1 does not end on cylinder boundary.\n\/dev\/xvda2              66        2611    20446208   8e  Linux LVM\n\/dev\/xvda3            2611        4960    18869680   83  Linux\n\nDisk \/dev\/mapper\/centos-swap: 1073 MB, 1073741824 bytes\n255 heads, 63 sectors\/track, 130 cylinders\nUnits = cylinders of 16065 * 512 = 8225280 bytes\nSector size (logical\/physical): 512 bytes \/ 512 bytes\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes\nDisk identifier: 0x00000000\n\n\nDisk \/dev\/mapper\/centos-root: 19.9 GB, 19860029440 bytes\n255 heads, 63 sectors\/track, 2414 cylinders\nUnits = cylinders of 16065 * 512 = 8225280 bytes\nSector size (logical\/physical): 512 bytes \/ 512 bytes\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes\nDisk identifier: 0x00000000\n\n<\/pre>\n<p>Run &#8220;pvcreate \/dev\/xvda3&#8221; to make \/dev\/xvda3 a LVM partition.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# pvcreate \/dev\/xvda3\n  Physical volume &quot;\/dev\/xvda3&quot; successfully created\n<\/pre>\n<p>Check for the name<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# vgs\n  VG     #PV #LV #SN Attr   VSize  VFree\n  centos   1   2   0 wz--n- 19.50g    0\n<\/pre>\n<p>Run &#8220;vgextend centos \/dev\/xvda3&#8221; to add \/dev\/xvda3 to the centos volume group.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# vgextend centos \/dev\/xvda3\n  Volume group &quot;centos&quot; successfully extended\n<\/pre>\n<p>Check again&#8230;<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n\n# lvs\n  LV   VG     Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert\n  root centos -wi-ao---- 18.50g\n  swap centos -wi-ao----  1.00g\n\n<\/pre>\n<p>Root &#8220;lvresize -r -l +100%FREE centos\/root&#8221; to resize the \/ partition.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# lvresize -r -l +100%FREE centos\/root\n  Size of logical volume centos\/root changed from 18.50 GiB (4735 extents) to 36.49 GiB (9341 extents).\n  Logical volume root successfully resized\nresize2fs 1.41.12 (17-May-2010)\nFilesystem at \/dev\/mapper\/centos-root is mounted on \/; on-line resizing required\nold desc_blocks = 2, new_desc_blocks = 3\nPerforming an on-line resize of \/dev\/mapper\/centos-root to 9565184 (4k) blocks.\nThe filesystem on \/dev\/mapper\/centos-root is now 9565184 blocks long.\n<\/pre>\n<p>Run &#8220;df -H&#8221;. You should now see 30+ GB size on the \/ partition.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# df -h\nFilesystem            Size  Used Avail Use% Mounted on\n\/dev\/mapper\/centos-root\n                       36G  928M   34G   3% \/\ntmpfs                 496M     0  496M   0% \/dev\/shm\n\/dev\/xvda1            504M   62M  417M  13% \/boot\n<\/pre>\n<p>And fdisk again<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# fdisk -l\n\nDisk \/dev\/xvda: 40.8 GB, 40802189312 bytes\n255 heads, 63 sectors\/track, 4960 cylinders\nUnits = cylinders of 16065 * 512 = 8225280 bytes\nSector size (logical\/physical): 512 bytes \/ 512 bytes\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes\nDisk identifier: 0x00028fed\n\n    Device Boot      Start         End      Blocks   Id  System\n\/dev\/xvda1   *           1          66      524288   83  Linux\nPartition 1 does not end on cylinder boundary.\n\/dev\/xvda2              66        2611    20446208   8e  Linux LVM\n\/dev\/xvda3            2611        4960    18869680   83  Linux\n\nDisk \/dev\/mapper\/centos-swap: 1073 MB, 1073741824 bytes\n255 heads, 63 sectors\/track, 130 cylinders\nUnits = cylinders of 16065 * 512 = 8225280 bytes\nSector size (logical\/physical): 512 bytes \/ 512 bytes\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes\nDisk identifier: 0x00000000\n\n\nDisk \/dev\/mapper\/centos-root: 39.2 GB, 39178993664 bytes\n255 heads, 63 sectors\/track, 4763 cylinders\nUnits = cylinders of 16065 * 512 = 8225280 bytes\nSector size (logical\/physical): 512 bytes \/ 512 bytes\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes\nDisk identifier: 0x00000000\n\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>New server created with 20GB Drive. # fdisk -l Disk \/dev\/xvda: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors\/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical\/physical): 512 bytes \/ 512 bytes I\/O size (minimum\/optimal): 512 bytes \/ 512 bytes Disk identifier: 0x00028fed Device Boot Start End Blocks &#8230; <a title=\"Resize a Cloud Server\" class=\"read-more\" href=\"https:\/\/www.qbytes.cloud\/index.php\/2015\/10\/02\/resize-a-cloud-server\/\" aria-label=\"Read more about Resize a Cloud Server\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[],"class_list":["post-2696","post","type-post","status-publish","format-standard","hentry","category-cloud"],"_links":{"self":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/2696","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/comments?post=2696"}],"version-history":[{"count":0,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/2696\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/media?parent=2696"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/categories?post=2696"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/tags?post=2696"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}