{"id":1025,"date":"2015-07-23T03:05:35","date_gmt":"2015-07-23T03:05:35","guid":{"rendered":"http:\/\/www.incredigeek.com\/home\/?p=1025"},"modified":"2024-02-26T17:38:54","modified_gmt":"2024-02-26T23:38:54","slug":"how-to-add-extra-space-to-linux-vm-in-xenserver","status":"publish","type":"post","link":"https:\/\/www.incredigeek.com\/home\/how-to-add-extra-space-to-linux-vm-in-xenserver\/","title":{"rendered":"How to add extra space to Linux VM in XenServer"},"content":{"rendered":"<p>Before we start you will need to do the following in XenCenter<\/p>\n<ul>\n<li>Shutdown the VM<\/li>\n<li>Increase the virtual hard drive size of the Linux VM<\/li>\n<li>Boot the VM back up<\/li>\n<\/ul>\n<p>Before starting any of the following, it is a good idea to backup any data you would not want to lose.\u00a0 You should not lose any data following these steps, but there is always the possibility for something to go wrong.<\/p>\n<p>What is going to happen<\/p>\n<ol>\n<li>Delete the main partition.\u00a0 We are going to recreate it.<\/li>\n<li>Create a new partition that starts on the same boundary as the previous partition<\/li>\n<li>Write changes to disk and reboot<\/li>\n<li>Resize the Disk<\/li>\n<li>Check that everything went well<\/li>\n<\/ol>\n<p>The path to the disk is &#8220;\/dev\/xvda&#8221; the LVM path\/name is &#8220;\/dev\/VolGroup\/lv_root&#8221;\u00a0 The goal is to increase lv_root&#8217;s size from about 8GB to about 12GB. If for some reason your drive is not &#8220;xvda&#8221; or your LVM name is different, change the commands accordingly.<\/p>\n<p>Here are the commands in a nutshell.<\/p>\n<pre>fdisk \/dev\/xvda                        &lt;-- Edit the Partition Table\nreboot                                 &lt;-- Reboot to apply the partition table updates\npvdisplay                              &lt;-- Display Physical Volume info\npvresize \/dev\/xvda2                    &lt;-- Resize Physical Volume\nlvresize \/dev\/xvda2 -l +100%FREE       &lt;-- Resize Logical Volume\nresize2fs \/dev\/VolGroup\/lv_root        &lt;-- Resize File System<\/pre>\n<p>Example:<\/p>\n<p>You may be able to substitute all the fdisk commands with<br \/>\n`parted \/dev\/xvda resizepart 2 100%`<br \/>\nChange 2 for the actual partition you need to resize.<\/p>\n<p>All the keys and command that were hit and executed are in bold.<\/p>\n<pre>[root@localhost ~]# <strong>fdisk \/dev\/xvda<\/strong>\n\nWARNING: DOS-compatible mode is deprecated. It's strongly recommended to\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 switch off the mode (command 'c') and change display units to\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 sectors (command 'u').\n\nCommand (m for help): <strong>p<\/strong>\n\nDisk \/dev\/xvda: 12.9 GB, 12884901888 bytes\n255 heads, 63 sectors\/track, 1566 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: 0x00066ace\n\n\u00a0\u00a0\u00a0 Device Boot\u00a0\u00a0\u00a0\u00a0\u00a0 Start\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 End\u00a0\u00a0\u00a0\u00a0\u00a0 Blocks\u00a0\u00a0 Id\u00a0 System\n\/dev\/xvda1\u00a0\u00a0 *\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 64\u00a0\u00a0\u00a0\u00a0\u00a0 512000\u00a0\u00a0 83\u00a0 Linux\nPartition 1 does not end on cylinder boundary.\n\/dev\/xvda2\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 64\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1045\u00a0\u00a0\u00a0\u00a0 7875584\u00a0\u00a0 8e\u00a0 Linux LVM\nCommand (m for help): <strong>d<\/strong>\nPartition number (1-4): <strong>2<\/strong>\n\nCommand (m for help): <strong>p<\/strong>\n\nDisk \/dev\/xvda: 12.9 GB, 12884901888 bytes\n255 heads, 63 sectors\/track, 1566 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: 0x00066ace\n\n\u00a0\u00a0\u00a0 Device Boot\u00a0\u00a0\u00a0\u00a0\u00a0 Start\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 End\u00a0\u00a0\u00a0\u00a0\u00a0 Blocks\u00a0\u00a0 Id\u00a0 System\n\/dev\/xvda1\u00a0\u00a0 *\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 64\u00a0\u00a0\u00a0\u00a0\u00a0 512000\u00a0\u00a0 83\u00a0 Linux\nPartition 1 does not end on cylinder boundary.\n\nCommand (m for help): <strong>n<\/strong>\nCommand action\n\u00a0\u00a0 e\u00a0\u00a0 extended\n\u00a0\u00a0 p\u00a0\u00a0 primary partition (1-4)\n<strong>p<\/strong>\nPartition number (1-4): <strong>2<\/strong>\nFirst cylinder (64-1566, default 64): \nCommand (m for help): <strong>p<\/strong>\n\nDisk \/dev\/xvda: 12.9 GB, 12884901888 bytes\n255 heads, 63 sectors\/track, 1566 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: 0x00066ace\n\n\u00a0\u00a0\u00a0 Device Boot\u00a0\u00a0\u00a0\u00a0\u00a0 Start\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 End\u00a0\u00a0\u00a0\u00a0\u00a0 Blocks\u00a0\u00a0 Id\u00a0 System\n\/dev\/xvda1\u00a0\u00a0 *\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 64\u00a0\u00a0\u00a0\u00a0\u00a0 512000\u00a0\u00a0 83\u00a0 Linux\nPartition 1 does not end on cylinder boundary.\n\/dev\/xvda2\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 64\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1566\u00a0\u00a0\u00a0 12065871\u00a0\u00a0 83\u00a0 Linux\n\nCommand (m for help): <strong>wq<\/strong>\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.\n[root@localhost ~]# <strong>reboot\n<\/strong><\/pre>\n<p>Show the current size of the Physical Volume<\/p>\n<pre>pvdisplay<\/pre>\n<pre>[root@localhost ~]# <strong>pvdisplay<\/strong>\n\u00a0 --- Physical volume ---\n\u00a0 PV Name\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/dev\/xvda2\n\u00a0 VG Name\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 VolGroup\n\u00a0 PV Size\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 7.51 GiB \/ not usable 3.00 MiB\n\u00a0 Allocatable\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 yes (but full)\n\u00a0 PE Size\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 4.00 MiB\n\u00a0 Total PE\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1922\n\u00a0 Free PE\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0\n\u00a0 Allocated PE\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1922\n\u00a0 PV UUID\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 zKmGEt-Uf0A-I14h-NDYc-53rf-micT-VxNqsP\n\u00a0 \u00a0\n[root@localhost ~]#<\/pre>\n<p>Resize the Physical Volume<\/p>\n<pre>pvresize \/dev\/xvda2<\/pre>\n<pre>[root@localhost ~]# <strong>pvresize \/dev\/xvda2<\/strong>\n\u00a0 Physical volume \"\/dev\/xvda2\" changed\n\u00a0 1 physical volume(s) resized \/ 0 physical volume(s) not resized\n[root@localhost ~]#<\/pre>\n<p>Run pvdisplay again.\u00a0 You should see more space under PV Size.<\/p>\n<pre>[root@localhost ~]# <strong>pvdisplay<\/strong>\n\u00a0 --- Physical volume ---\n\u00a0 PV Name\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/dev\/xvda2\n\u00a0 VG Name\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 VolGroup\n\u00a0 PV Size\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 11.51 GiB \/ not usable 2.08 MiB\n\u00a0 Allocatable\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 yes \n\u00a0 PE Size\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 4.00 MiB\n\u00a0 Total PE\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 2945\n\u00a0 Free PE\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1023\n\u00a0 Allocated PE\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1922\n\u00a0 PV UUID\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 zKmGEt-Uf0A-I14h-NDYc-53rf-micT-VxNqsP\n\u00a0 \u00a0\n[root@localhost ~]#<\/pre>\n<p>Notice the &#8220;Free PE&#8221; section above.\u00a0 If it says 0 then you won&#8217;t be able to run the next command.<\/p>\n<p>Resize LVM<\/p>\n<p>the &#8220;+100%FREE&#8221; part of the command tells it to uses up all of the free space available<\/p>\n<pre>lvresize \/dev\/VolGroup\/lv_root -l +100%FREE<\/pre>\n<pre>[root@localhost ~]# <strong>lvresize \/dev\/VolGroup\/lv_root -l +100%FREE<\/strong>\n\u00a0 Extending logical volume lv_root to 10.71 GiB\n\u00a0 Logical volume lv_root successfully resized\n[root@localhost ~]#<\/pre>\n<p>Resize the File System<\/p>\n<pre>resize2fs \/dev\/VolGroup\/lv_root<\/pre>\n<pre>[root@localhost ~]# <strong>lvresize \/dev\/VolGroup\/lv_root -l +100%FREE<\/strong>\n\u00a0 Extending logical volume lv_root to 10.71 GiB\n\u00a0 Logical volume lv_root successfully resized\n[root@localhost ~]#<\/pre>\n<p>And that is it.\u00a0 Check out the extra space.<\/p>\n<pre>[root@localhost ~]# <strong>df -h \/<\/strong>\nFilesystem\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Size\u00a0 Used Avail Use% Mounted on\n\/dev\/mapper\/VolGroup-lv_root\u00a0\u00a0 11G\u00a0 733M\u00a0 9.3G\u00a0\u00a0 8% \/\n[root@localhost ~]# <strong>exit<\/strong><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Before we start you will need to do the following in XenCenter Shutdown the VM Increase the virtual hard drive size of the Linux VM Boot the VM back up Before starting any of the following, it is a good &hellip; <a href=\"https:\/\/www.incredigeek.com\/home\/how-to-add-extra-space-to-linux-vm-in-xenserver\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,3,29],"tags":[8,7,148,222],"class_list":["post-1025","post","type-post","status-publish","format-standard","hentry","category-centos-linux","category-linux","category-xenserver","tag-command-line-2","tag-linux-2","tag-lvm","tag-xen"],"_links":{"self":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/1025","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/comments?post=1025"}],"version-history":[{"count":33,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/1025\/revisions"}],"predecessor-version":[{"id":5712,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/1025\/revisions\/5712"}],"wp:attachment":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/media?parent=1025"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/categories?post=1025"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/tags?post=1025"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}