ResizingVMDisk: Difference between revisions

From T2B Wiki
Jump to navigation Jump to search
 
Line 23: Line 23:


6. Resize the partition:
6. Resize the partition:
<pre>growpart <device> <partition_number> +<number>GB</pre>
<pre>growpart <device> <partition_number></pre>
7. Resize the filesystem of the partition:
7. Resize the filesystem of the partition:
<pre>resize2fs <partition></pre>
<pre>resize2fs <partition></pre>

Latest revision as of 13:43, 13 October 2022

Goal

On this page, we will explain how to increase the size of a partition in a VM. The steps are the following:

  1. Increase the size of the image
  2. Increase the size of a partition
  3. Resize the filesystem

The details of the steps of this generic procedure will change depending on:

  • the type of backend storage (ONE datastore) for VM images (NFS share or Ceph);
  • the format of the image (qcow2, raw,...);
  • the type of partition (standard partitioning or LVM);
  • the type of filesystem (xfs, ext3/4,...).

Cloud1: qcow2 images on NFS with a standard partition in ext4

1. Poweroff the VM

2. On the frontend of the ONE cloud, find the full path of the image of the VM with the command:

oneimage show <image_id>

3. Resize the image:

qemu-img resize <path_of_image> +<number>GB

4. Restart the VM and login into it

5. Install the following packages:

yum install cloud-utils-growpart gdisk

6. Resize the partition:

growpart <device> <partition_number>

7. Resize the filesystem of the partition:

resize2fs <partition>

Cloud2: raw images on Ceph with standard ext4 partition

Based on our tests with OpenNebula 6.4, you can do a "live" resize of the image (without having to power cycle the VM) from the Sunstone GUI:

  • Click on the VM
  • Go to the "Storage" tab
  • On the right side of the vda drive, you can see the "Actions" button. Click on the "Resize" blue button and set the desired size in the "Disk resize" box and validate by clicking on the "Resize" green button. That's it!

Now, if you login into the VM, you can see that the disk size has changed with "lsblk" command. But you still have to extend the partition and its filesystem like in the previous section:

yum install cloud-utils-growpart gdisk

growpart <device> <partition_number> +<number>GB

resize2fs <partition>