{"id":301,"date":"2019-01-27T14:47:36","date_gmt":"2019-01-27T14:47:36","guid":{"rendered":"https:\/\/unsrewiki.1sys1.com\/?p=301"},"modified":"2019-01-27T15:32:09","modified_gmt":"2019-01-27T15:32:09","slug":"increase-lvm-partition-to-take-up-remaining-space","status":"publish","type":"post","link":"https:\/\/server-help.org\/index.php\/2019\/01\/27\/increase-lvm-partition-to-take-up-remaining-space\/","title":{"rendered":"Increase LVM Partition to Take Up Remaining Space"},"content":{"rendered":"\n<p>This is the process of increasing the LVM Partition to fill use up added disk space after a cloud server is reconfigured.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">  Overview: <a href=\"https:\/\/wiki.1and1.org\/WWSwiki\/IncreaseLVMPartitionToTakeUpRemainingSpaceNGCSResize#\"><\/a> <\/h5>\n\n\n\n<ol><li> Remove and Recreate physical LVM Partition(\/dev\/sda2)\n<\/li><li> Extend LVM Physical Volume(pvresize)\n<\/li><li> Extend LVM Logical Volume(lvresize)\n<\/li><li> Extend Filesystem into remaining space(xfs_growfs\/\/resize2fs)\n<\/li><\/ol>\n\n\n\n<p>In this example a Cloud Server configuration:<\/p>\n\n\n\n<p><strong>Configuration:<br> CPU: 2 vCore <br> RAM: 2 GB <br> SSD: 80 GB <\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"723\" height=\"613\" src=\"https:\/\/unsrewiki.1sys1.com\/wp-content\/uploads\/2019\/01\/1.png\" alt=\"\" class=\"wp-image-302\" srcset=\"https:\/\/server-help.org\/wp-content\/uploads\/2019\/01\/1.png 723w, https:\/\/server-help.org\/wp-content\/uploads\/2019\/01\/1-300x254.png 300w\" sizes=\"(max-width: 723px) 100vw, 723px\" \/><\/figure>\n\n\n\n<p>Now our Server has been upgraded:<\/p>\n\n\n\n<p><strong>Configuration:<br> CPU: 2 vCore <br> RAM: 4 GB <br> SSD: 120 GB <\/strong><\/p>\n\n\n\n<p>In order to increase the storage capacity of the SSD, we must adjust the hard disk configuration in our server&#8217;s operating system. <\/p>\n\n\n\n<p>When we use df -h command to list disk free space, we will noticed that there is no changes happened to the root directory. However fdisk -l command showing us the new Disk Space has been added.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"806\" height=\"645\" src=\"https:\/\/unsrewiki.1sys1.com\/wp-content\/uploads\/2019\/01\/2-1.png\" alt=\"\" class=\"wp-image-304\" srcset=\"https:\/\/server-help.org\/wp-content\/uploads\/2019\/01\/2-1.png 806w, https:\/\/server-help.org\/wp-content\/uploads\/2019\/01\/2-1-300x240.png 300w, https:\/\/server-help.org\/wp-content\/uploads\/2019\/01\/2-1-768x615.png 768w\" sizes=\"(max-width: 806px) 100vw, 806px\" \/><\/figure>\n\n\n\n<p>Now we start increasing our Storage capacity:<\/p>\n\n\n\n<p>Step 1: Delete\/Recreate the LVM partition using fdisk<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># fdisk \/dev\/sda\nWelcome to fdisk (util-linux 2.23.2).\n\nChanges will remain in memory only, until you decide to write them.\nBe careful before using the write command.\n\n\nCommand (m for help):\n<\/code><\/pre>\n\n\n\n<p>First, we list Server&#8217;s Partition (p)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Command (m for help): p\n\nDisk \/dev\/sda: 128.8 GB, 128849018880 bytes, 251658240 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: 0x000e254e\n\n   Device Boot      Start         End      Blocks   Id  System\n\/dev\/sda1   *        2048     2099199     1048576   83  Linux\n\/dev\/sda2         2099200   167772159    82836480   8e  Linux LVM<\/code><\/pre>\n\n\n\n<p>Then, we delete \/dev\/sda2 (d)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Command (m for help): d\nPartition number (1,2, default 2): 2\nPartition 2 is deleted<\/code><\/pre>\n\n\n\n<p>After that, we re-create \/dev\/sda2 again (n)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Command (m for help): n\nPartition type:\n   p   primary (1 primary, 0 extended, 3 free)\n   e   extended\nSelect (default p): p\nPartition number (2-4, default 2): 2\nFirst sector (2099200-251658239, default 2099200):\nUsing default value 2099200\nLast sector, +sectors or +size{K,M,G} (2099200-251658239, default 251658239):\nUsing default value 251658239\nPartition 2 of type Linux and of size 119 GiB is set<\/code><\/pre>\n\n\n\n<p>Please note that, to use the entire space, we select First &amp; Last sectors. Now we print Server&#8217;s Partition again.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Command (m for help): p\n\nDisk \/dev\/sda: 128.8 GB, 128849018880 bytes, 251658240 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: 0x000e254e\n\n   Device Boot      Start         End      Blocks   Id  System\n\/dev\/sda1   *        2048     2099199     1048576   83  Linux\n\/dev\/sda2         2099200   251658239   124779520   83  Linux\n<\/code><\/pre>\n\n\n\n<p>Now we change \/dev\/sda2 System type from <strong>Linux <\/strong>to <strong>Linux LVM<\/strong> (t). If you don&#8217;t know what type code you can list all types by (L).<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Command (m for help): t\nPartition number (1,2, default 2): 2\nHex code (type L to list all codes): L\n\n 0  Empty           24  NEC DOS         81  Minix \/ old Lin bf  Solaris\n 1  FAT12           27  Hidden NTFS Win 82  Linux swap \/ So c1  DRDOS\/sec (FAT-\n 2  XENIX root      39  Plan 9          83  Linux           c4  DRDOS\/sec (FAT-\n 3  XENIX usr       3c  PartitionMagic  84  OS\/2 hidden C:  c6  DRDOS\/sec (FAT-\n 4  FAT16 &lt;32M      40  Venix 80286     85  Linux extended  c7  Syrinx\n 5  Extended        41  PPC PReP Boot   86  NTFS volume set da  Non-FS data\n 6  FAT16           42  SFS             87  NTFS volume set db  CP\/M \/ CTOS \/ .\n 7  HPFS\/NTFS\/exFAT 4d  QNX4.x          88  Linux plaintext de  Dell Utility\n 8  AIX             4e  QNX4.x 2nd part 8e  Linux LVM       df  BootIt\n 9  AIX bootable    4f  QNX4.x 3rd part 93  Amoeba          e1  DOS access\n a  OS\/2 Boot Manag 50  OnTrack DM      94  Amoeba BBT      e3  DOS R\/O\n b  W95 FAT32       51  OnTrack DM6 Aux 9f  BSD\/OS          e4  SpeedStor\n c  W95 FAT32 (LBA) 52  CP\/M            a0  IBM Thinkpad hi eb  BeOS fs\n e  W95 FAT16 (LBA) 53  OnTrack DM6 Aux a5  FreeBSD         ee  GPT\n f  W95 Ext'd (LBA) 54  OnTrackDM6      a6  OpenBSD         ef  EFI (FAT-12\/16\/\n10  OPUS            55  EZ-Drive        a7  NeXTSTEP        f0  Linux\/PA-RISC b\n11  Hidden FAT12    56  Golden Bow      a8  Darwin UFS      f1  SpeedStor\n12  Compaq diagnost 5c  Priam Edisk     a9  NetBSD          f4  SpeedStor\n14  Hidden FAT16 &lt;3 61  SpeedStor       ab  Darwin boot     f2  DOS secondary\n16  Hidden FAT16    63  GNU HURD or Sys af  HFS \/ HFS+      fb  VMware VMFS\n17  Hidden HPFS\/NTF 64  Novell Netware  b7  BSDI fs         fc  VMware VMKCORE\n18  AST SmartSleep  65  Novell Netware  b8  BSDI swap       fd  Linux raid auto\n1b  Hidden W95 FAT3 70  DiskSecure Mult bb  Boot Wizard hid fe  LANstep\n1c  Hidden W95 FAT3 75  PC\/IX           be  Solaris boot    ff  BBT\n1e  Hidden W95 FAT1 80  Old Minix<\/code><\/pre>\n\n\n\n<p>Linux LVM type code is: 8e<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Hex code (type L to list all codes): 8e\nChanged type of partition 'Linux' to 'Linux LVM'<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>Command (m for help): p\n\nDisk \/dev\/sda: 128.8 GB, 128849018880 bytes, 251658240 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: 0x000e254e\n\n   Device Boot      Start         End      Blocks   Id  System\n\/dev\/sda1   *        2048     2099199     1048576   83  Linux\n\/dev\/sda2         2099200   251658239   124779520   8e  Linux LVM\n<\/code><\/pre>\n\n\n\n<p>After changing type to Linux LVM, we need to save these changes to the Operating System Kernel (w).<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Command (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)\nSyncing disks.<\/code><\/pre>\n\n\n\n<p>Now to apply all of the changes, it either by rebooting our Server, or use partprobe Command to inform the OS of partition table changes.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># partprobe<\/code><\/pre>\n\n\n\n<p>Now, we Resize LVM physical volume<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># pvresize \/dev\/sda2\n  Physical volume \"\/dev\/sda2\" changed\n  1 physical volume(s) resized or updated \/ 0 physical volume(s) not resized<\/code><\/pre>\n\n\n\n<p>We use pvs command to verify the changes:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># pvs\n  PV         VG     Fmt  Attr PSize    PFree\n  \/dev\/sda2  centos lvm2 a--  &lt;119.00g 40.00g<\/code><\/pre>\n\n\n\n<p>Now, we Resize LVM Logical volume<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># lvresize -l +100%FREE \/dev\/mapper\/centos-root\n  Size of logical volume centos\/root changed from &lt;77.00 GiB (19711 extents) to &lt;117.00 GiB (29951 extents).\n  Logical volume centos\/root successfully resized.<\/code><\/pre>\n\n\n\n<p>Check the File System with mount command to grow filesystem into remaining space<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># mount | grep centos-root\n\/dev\/mapper\/centos-root on \/ type xfs (rw,relatime,attr2,inode64,noquota)<\/code><\/pre>\n\n\n\n<p>Use xfs_growfs command to  grow filesystem:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># xfs_growfs \/dev\/mapper\/centos-root\nmeta-data=\/dev\/mapper\/centos-root isize=512    agcount=19, agsize=1113856 blks\n         =                       sectsz=512   attr=2, projid32bit=1\n         =                       crc=1        finobt=0 spinodes=0\ndata     =                       bsize=4096   blocks=20184064, imaxpct=25\n         =                       sunit=0      swidth=0 blks\nnaming   =version 2              bsize=4096   ascii-ci=0 ftype=1\nlog      =internal               bsize=4096   blocks=2560, version=2\n         =                       sectsz=512   sunit=0 blks, lazy-count=1\nrealtime =none                   extsz=4096   blocks=0, rtextents=0\ndata blocks changed from 20184064 to 30669824<\/code><\/pre>\n\n\n\n<p>Use df -h to verify<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># df -h\nFilesystem               Size  Used Avail Use% Mounted on\n\/dev\/mapper\/centos-root  117G  7.6G  110G   7% \/\ndevtmpfs                 1.9G     0  1.9G   0% \/dev\ntmpfs                    1.9G     0  1.9G   0% \/dev\/shm\ntmpfs                    1.9G   13M  1.9G   1% \/run\ntmpfs                    1.9G     0  1.9G   0% \/sys\/fs\/cgroup\n\/dev\/sda1               1014M  336M  679M  34% \/boot\ntmpfs                    378M   12K  378M   1% \/run\/user\/42\ntmpfs                    378M     0  378M   0% \/run\/user\/0<\/code><\/pre>\n\n\n\n<p>Now, our Server has been upgraded and the Disk Space has been upgraded.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is the process of increasing the LVM Partition to fill use up added disk space after a cloud server is reconfigured. Overview: Remove and Recreate physical LVM Partition(\/dev\/sda2) Extend LVM Physical Volume(pvresize) Extend LVM Logical Volume(lvresize) Extend Filesystem into remaining space(xfs_growfs\/\/resize2fs) In this example a Cloud Server configuration: Configuration: CPU: 2 vCore RAM: 2&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,4,7,1],"tags":[],"_links":{"self":[{"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/posts\/301"}],"collection":[{"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/comments?post=301"}],"version-history":[{"count":2,"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/posts\/301\/revisions"}],"predecessor-version":[{"id":309,"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/posts\/301\/revisions\/309"}],"wp:attachment":[{"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/media?parent=301"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/categories?post=301"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/tags?post=301"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}