{"id":8406,"date":"2019-01-21T04:29:03","date_gmt":"2019-01-21T04:29:03","guid":{"rendered":"https:\/\/www.appservgrid.com\/paw92\/?p=8406"},"modified":"2019-03-09T04:43:05","modified_gmt":"2019-03-09T04:43:05","slug":"how-to-resize-openstack-instance-virtual-machine-from-command-line","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/01\/21\/how-to-resize-openstack-instance-virtual-machine-from-command-line\/","title":{"rendered":"How to Resize OpenStack Instance (Virtual Machine) from Command line"},"content":{"rendered":"<h1 class=\"post-title entry-title\">How to Resize OpenStack Instance (Virtual Machine) from Command line<\/h1>\n<div class=\"clear\"><span style=\"font-size: 1rem;\">Being a Cloud administrator, resizing or changing resources of an instance or virtual machine is one of the most common tasks.<\/span><\/div>\n<div class=\"entry themeform share\">\n<div class=\"entry-inner\">\n<p><a title=\"\" href=\"https:\/\/www.linuxtechi.com\/wp-content\/uploads\/2019\/01\/Resize-openstack-instance.jpg\" data-rel=\"lightbox-image-0\" data-rl_title=\"\" data-rl_caption=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-8173 aligncenter\" src=\"https:\/\/www.linuxtechi.com\/wp-content\/uploads\/2019\/01\/Resize-openstack-instance.jpg\" sizes=\"auto, (max-width: 521px) 100vw, 521px\" srcset=\"https:\/\/www.linuxtechi.com\/wp-content\/uploads\/2019\/01\/Resize-openstack-instance.jpg 521w, https:\/\/www.linuxtechi.com\/wp-content\/uploads\/2019\/01\/Resize-openstack-instance-300x169.jpg 300w\" alt=\"Resize-openstack-instance\" width=\"521\" height=\"294\" \/><\/a><\/p>\n<p>In Openstack environment, there are some scenarios where cloud user has spin a vm using some flavor( like m1.smalll) where root partition disk size is 20 GB, but at some point of time user wants to extends the root partition size to 40 GB. So resizing of vm\u2019s root partition can be accomplished by using the resize option in nova command. During the resize, we need to specify the new flavor that will include disk size as 40 GB.<\/p>\n<p><strong>Note:<\/strong>\u00a0Once you extend the instance resources like RAM, CPU and disk using resize option in openstack then you can\u2019t reduce it.<\/p>\n<p><strong>Read More on<\/strong>\u00a0:\u00a0<a href=\"https:\/\/www.linuxtechi.com\/create-delete-virtual-machine-command-line-openstack\/\" target=\"_blank\" rel=\"noopener\"><strong>How to Create and Delete Virtual Machine(VM) from Command line in OpenStack<\/strong><\/a><\/p>\n<p>In this tutorial I will demonstrate how to resize an openstack instance from command line. Let\u2019s assume I have an existing instance named \u201c<strong>test_resize_vm<\/strong>\u201d and it\u2019s associated flavor is \u201cm1.small\u201d and root partition disk size is 20 GB.<\/p>\n<p>Execute the below command from controller node to check on which compute host our vm \u201ctest_resize_vm\u201d is provisioned and its flavor details<\/p>\n<pre>:~# openstack server show test_resize_vm | grep -E \"flavor|hypervisor\"\r\n| OS-EXT-SRV-ATTR:hypervisor_hostname\u00a0 | compute-57\u00a0\u00a0\u00a0 |\r\n| flavor\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | m1.small (2)\u00a0 |\r\n:~#<\/pre>\n<p>Login to VM as well and check the root partition size,<\/p>\n<pre>[root@test-resize-vm ~]# df -Th\r\nFilesystem\u00a0\u00a0\u00a0\u00a0 Type\u00a0\u00a0\u00a0\u00a0\u00a0 Size\u00a0 Used Avail Use% Mounted on\r\n<strong>\/dev\/vda1\u00a0\u00a0\u00a0\u00a0\u00a0 xfs\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 20G\u00a0 885M\u00a0\u00a0 20G\u00a0\u00a0 5% \/<\/strong>\r\ndevtmpfs\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 devtmpfs\u00a0 900M\u00a0\u00a0\u00a0\u00a0 0\u00a0 900M\u00a0\u00a0 0% \/dev\r\ntmpfs\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0tmpfs\u00a0\u00a0\u00a0\u00a0 920M\u00a0\u00a0\u00a0\u00a0 0\u00a0 920M\u00a0\u00a0 0% \/dev\/shm\r\ntmpfs\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 tmpfs\u00a0\u00a0\u00a0\u00a0 920M\u00a0 8.4M\u00a0 912M\u00a0\u00a0 1% \/run\r\ntmpfs\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 tmpfs\u00a0\u00a0\u00a0\u00a0 920M\u00a0\u00a0\u00a0\u00a0 0\u00a0 920M\u00a0\u00a0 0% \/sys\/fs\/cgroup\r\ntmpfs\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 tmpfs\u00a0\u00a0\u00a0\u00a0 184M\u00a0\u00a0\u00a0\u00a0 0\u00a0 184M\u00a0\u00a0 0% \/run\/user\/1000\r\n[root@test-resize-vm ~]# echo \"test file for resize operation\" &gt; demofile\r\n[root@test-resize-vm ~]# cat demofile\r\ntest file for resize operation\r\n[root@test-resize-vm ~]#<\/pre>\n<p>Get the available flavor list using below command,<\/p>\n<pre>:~# openstack flavor list\r\n+--------------------------------------+-----------------+-------+------+-----------+-------+-----------+\r\n| ID\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | Name\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0\u00a0 RAM | Disk | Ephemeral | VCPUs | Is Public |\r\n+--------------------------------------+-----------------+-------+------+-----------+-------+-----------+\r\n| 2\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | m1.small\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 2048 |\u00a0\u00a0 20 |\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0 |\u00a0\u00a0\u00a0\u00a0 1 | True\u00a0\u00a0\u00a0\u00a0\u00a0 |\r\n| 3\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | m1.medium\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 4096 |\u00a0\u00a0 40 |\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0 |\u00a0\u00a0 \u00a0\u00a02 | True\u00a0\u00a0\u00a0\u00a0\u00a0 |\r\n| 4\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | m1.large\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 8192 |\u00a0\u00a0 80 |\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0 |\u00a0\u00a0\u00a0\u00a0 4 | True\u00a0\u00a0\u00a0\u00a0\u00a0 |\r\n| 5\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | m1.xlarge\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | 16384 |\u00a0 160 |\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0 |\u00a0\u00a0\u00a0\u00a0 8 | True\u00a0\u00a0\u00a0\u00a0\u00a0 |\r\n+--------------------------------------+-----------------+-------+------+-----------+-------+-----------+<\/pre>\n<p>So we will be using the flavor \u201cm1.medium\u201d for resize operation, Run the beneath nova command to resize \u201ctest_resize_vm\u201d,<\/p>\n<p>Syntax:\u00a0# nova resize {VM_Name}\u00a0 {flavor_id}\u00a0 \u2014poll<\/p>\n<pre>:~# nova resize test_resize_vm 3 --poll\r\nServer resizing... 100% complete\r\nFinished\r\n:~#<\/pre>\n<p>Now confirm the resize operation using \u201c<strong>openstack server \u2013confirm\u201d<\/strong>\u00a0command,<\/p>\n<pre>~# openstack server list | grep -i test_resize_vm\r\n| 1d56f37f-94bd-4eef-9ff7-3dccb4682ce0 | test_resize_vm | VERIFY_RESIZE |private-net=10.20.10.51\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\r\n:~#<\/pre>\n<p>As we can see in the above command output\u00a0 the current status of the vm is \u201c<strong>verify_resize<\/strong>\u201c, execute below command to confirm resize,<\/p>\n<pre>~# openstack server resize --confirm 1d56f37f-94bd-4eef-9ff7-3dccb4682ce0\r\n~#<\/pre>\n<p>After the resize confirmation, status of VM will become active, now re-verify hypervisor and flavor details for the vm<\/p>\n<pre>:~# openstack server show test_resize_vm | grep -E \"flavor|hypervisor\"\r\n| OS-EXT-SRV-ATTR:hypervisor_hostname\u00a0 | compute-58\u00a0\u00a0 |\r\n| flavor\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | m1.medium (3)|<\/pre>\n<p>Login to your VM now and verify the root partition size<\/p>\n<pre>[root@test-resize-vm ~]# df -Th\r\nFilesystem\u00a0\u00a0\u00a0\u00a0 Type\u00a0\u00a0\u00a0\u00a0\u00a0 Size\u00a0 Used Avail Use% Mounted on\r\n<strong>\/dev\/vda1\u00a0\u00a0\u00a0\u00a0\u00a0 xfs\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 40G\u00a0 887M\u00a0\u00a0 40G\u00a0\u00a0 3% \/<\/strong>\r\ndevtmpfs\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 devtmpfs\u00a0 1.9G\u00a0\u00a0\u00a0\u00a0 0\u00a0 1.9G\u00a0\u00a0 0% \/dev\r\ntmpfs\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 tmpfs\u00a0\u00a0\u00a0\u00a0 1.9G\u00a0\u00a0\u00a0\u00a0 0\u00a0 1.9G\u00a0\u00a0 0% \/dev\/shm\r\ntmpfs\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 tmpfs\u00a0\u00a0\u00a0\u00a0 1.9G\u00a0 8.4M\u00a0 1.9G\u00a0\u00a0 1% \/run\r\ntmpfs\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 tmpfs\u00a0\u00a0\u00a0\u00a0 1.9G\u00a0\u00a0\u00a0\u00a0 0\u00a0 1.9G\u00a0\u00a0 0% \/sys\/fs\/cgroup\r\ntmpfs\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 tmpfs\u00a0\u00a0\u00a0\u00a0 380M\u00a0\u00a0\u00a0\u00a0 0\u00a0 380M\u00a0\u00a0 0% \/run\/user\/1000\r\n[root@test-resize-vm ~]# cat demofile\r\ntest file for resize operation\r\n[root@test-resize-vm ~]#<\/pre>\n<p>This confirm that VM root partition has been resized successfully.<\/p>\n<p><strong>Note:<\/strong>\u00a0Due to some reason if resize operation was not successful and you want to revert the vm back to previous state, then run the following command,<\/p>\n<pre># openstack server resize --revert {instance_uuid}<\/pre>\n<p>If have noticed \u201c<strong>openstack server show<\/strong>\u201d commands output, VM is migrated from compute-57 to compute-58 after resize. This is the default behavior \u00a0of \u201cnova resize\u201d command ( i.e nova resize command will migrate the instance to another compute &amp; then resize it based on the flavor details)<\/p>\n<p>In case if you have only one compute node then nova resize will not work, but we can make it work by changing the below parameter in nova.conf file on compute node,<\/p>\n<p>Login to compute node, verify the parameter value<\/p>\n<pre>[root@devstack-linuxtechi ~]# grep -i resize \/etc\/nova\/nova.conf\r\nallow_resize_to_same_host = True\r\n[root@devstack-linuxtechi ~]#<\/pre>\n<p>If \u201c<strong>allow_resize_to_same_host<\/strong>\u201d is set as False then change it to True and restart the nova compute service.<\/p>\n<p><strong>Read More on<\/strong>\u00a0<a href=\"https:\/\/www.linuxtechi.com\/openstack-deployment-devstack-centos-7-rhel-7\/\" target=\"_blank\" rel=\"noopener\"><strong>OpenStack Deployment using Devstack on CentOS 7 \/ RHEL 7 System<\/strong><\/a><\/p>\n<p>That\u2019s all from this tutorial, in case it helps you technically then please do share your feedback and comments.<\/p>\n<\/div>\n<\/div>\n<p><a href=\"https:\/\/www.linuxtechi.com\/resize-openstack-instance-command-line\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to Resize OpenStack Instance (Virtual Machine) from Command line Being a Cloud administrator, resizing or changing resources of an instance or virtual machine is one of the most common tasks. In Openstack environment, there are some scenarios where cloud user has spin a vm using some flavor( like m1.smalll) where root partition disk size &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/01\/21\/how-to-resize-openstack-instance-virtual-machine-from-command-line\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to Resize OpenStack Instance (Virtual Machine) from Command line&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-8406","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/8406","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=8406"}],"version-history":[{"count":2,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/8406\/revisions"}],"predecessor-version":[{"id":10928,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/8406\/revisions\/10928"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=8406"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=8406"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=8406"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}