Resizing OS images
Images in the Apps are deliberately made rather small. They are usually enough to hold the operating system and allow installing some few extra software packages. And you are advised to store data in a separate Ceph image.
That description is usually valid for most use cases, but occasionally you may need to have so many different programs installed that you may require some extra space in your OS partition.
We created this page because some people think it is useful. We actually recommend NOT resizing OS images, because it is an error-prone process and may lead to data loss. We also recommend that you make a back-up of your image before attempting any of this.
The 1-2-3 summary to actually get your image resized is:
- Attach the image you want to expand in another running VM.
- In that VM, resize (and, maybe, repartition) the image.
- Export (or save) the resized image as a different image.
The steps in this page will show in detail how to do it.
Preparing the image for resizing
You must make sure that the
image you are willing to download is currently not in use by any running VM.
- On the UI: click on the
image you want to download to display the extended information about that
- On the UI: Then click on the tab VMs of the extended information, so that you can see the list of all VMs that are using the
- On the UI: For every VM that you see on the list of VMs that are using the
image, click on that VM’s line to see extended information about that VM. Then shut that VM down.
- On the UI: Go back to the Info tab of the
image’s extended information. Click on the Clone button to make a backup of the
image and name it appropriately (e.g.: with the suffix .backup).
- On the UI: Go back to the Info tab of the original
image’s extended information. Change now:
- the Type to DATABLOCK
- the Persistent to non-persistent
It is important that you make the
image you want to resize non-persistent at this point, because the new size you want to give the VM will come at the point when you create a VM later. And a new size can only be given to images that are non-persistent.
Creating a utility VM
We will be using an extra VM as the central place of operations for the rest of the tasks. We will call it Utility VM.
We will be attaching the image you want to resize in that Utility VM, then resizing the partitions in that image so that they expand to use the full available size of the image and then saving that resized image as a new image.
- On the UI: Go to the Apps option of the Storage section and import an appliance you feel comfortable with (detailed instructions in our General Start article). We will be using Ubuntu Desktop throughout this guide, so that you can use
gparted to resize the partitions.
- On the UI: Make sure that you edit the
template you have just imported from the appliance so that you:
- in the Storage tab: include a
disk with the image you want to resize.
- in the Network tab: include a
nic connected to the Internet
- On the UI: Save the changes to the
template you just edited
- On the UI: Click on the Instantiate button to show the screen that will allow you to give a name to the VM. Make sure:
- That you provide a name for the VM
- That you give the new size you require to the image you want to resize
- Then, click on the green Instantiate button to create the VM.
Make sure you can log in to the Utility VM via SSH using the
Resizing and repartitioning the image
We will now resize the partition in the
We cannot know in advance which kind of partitioning your image will have, so we cannot describe a step-by-step guide that will always work for you. In this example we will be resizing an Ubuntu image from our Apps, because we actually know what the partitioning is there.
- In your laptop: Connect via SSH to the Utility VM, using the -X flag so that you can display graphical windows.
- In the Utility VM: Run the command to install gparted:
sudo apt-get install gparted.
- In the Utility VM: launch the GParted program by running:
sudo gparted. This will open a new graphical window for GParted.
- In Gparted: On the top-right corner, next to a hard drive icon, you probably have selected, by default, the
/dev/vda drive. That is NOT the one you want to resize. Look for the right one by click on the arrow to the right of that, and click then on the right one to start operating on it (as help to identify the right one, you can already see on the drop-down list of hard drives the size you typed on the UI).
- In Gparted: Under the drop-down list where you have selected the right hard drive you now see a bar depicting the partitions that are available on that hard drive. You will probably see a dark-gray unallocated area at the right of some other partitions (each partition shown as a different colour). Under that bar, you have the same partitions in a tree (or list) with some extra information like the size, etc. Assuming the latest Ubuntu image, you should see a big ext4 partition with a dark-blue border and a second smaller extended partition with a light-blue border. Within this extended partition you have another linux-swap partition with a red border. Finally you will see the unallocated space. We will have to:
- In Gparted: Remove the linux-swap partition (right-click on it, then choose Delete)
- In Gparted: Remove the extended partition (right-click on it, then choose Delete)
- In Gparted: Expand the ext4 partition (right-click on it, then choose Resize/Move). In the dialog that appears, type in the Free space following field the size you want to leave for the swap-partition (i.e.: 512). That should automatically fill in the New size field to fill in the rest of the unallocated space. Click on the Resize/Move button.
- In Gparted: Create a new extended partition (right-click on the unallocated space, then choose New). In the dialog that appears, for the the Create as: field choose Extended partition. Click the Add button.
- In Gparted: Create a new linux-swap partition (right-click on the unallocated space, then choose New). In the dialog that appears, for the File system: field choose linux-swap. Click the Add button.
- In Gparted: We have now the new layout in the main window of GParted. Click on the Apply button to save the changes (and confirm if prompted, to actually make the changes). You can then quit GParted.
Saving the resized image
The image is now ready with the new layout and everything. However, it is non-persistent, so if we shut the VM down we will lose the changes. On the other hand, because a VM is running, you cannot guarantee that all changes have been flushed to the image. We recommend that you use the UI’s Power off action to leave the VM in a controlled shutdown (but still living), so that you can save a copy of the attached image.
- On the UI: click on the Utility VM to see its extended information. Click then on the power drop-down button and choose option Power off. After several states, your VM’s status will be POWEROFF.
- On the UI: in the extended information about the VM, go now to the Storage tab. Next to the
image you have resized, you should see a link that reads Save as. Click on the Save as link for that
image. Give the
image you are going to create a new name (e.g.: add the suffix
.resized to its original name). The state of the VM changes while the image is being copied. It can take a while before the image is copied. When the copy is finished, the VM’s status is again POWEROFF. And then you will see a new
image in the list of images with the resized
image in status READY.
- On the UI: Go back to the Info tab of the resized
image’s extended information. Change now:
- the Type to OS
- the Persistent to persistent (if you want your image to keep changes)
Changing the original template
You now need to use the new resized
image when you create a new VM. You need to change the
template for that.
- On the UI: In your templates list, locate the original template. Click on it to see the extended information.
- On the UI: With the extended information of the VM in sight, click on the Clone button. Give it a new name that describes that is the new one (e.g.: add the .resized suffix to the original name).
- On the UI: In your templates list, locate the resized template. Click on it to see the extended information.
- On the Storage tab, change the original
image for the resized one.
- On the UI: Click on Update to save the changes to the resized template.
- On the UI: Click on the Instantiate button to make a new VM out of the resized template (which now is pointing to the resized image).
If everything went well, your VM will boot normally and you will have more space in your OS partition.