Sometimes, when we upgrade our systems, it happens that the cloud-init package has an update and the system asks you exactly what to do with the configuration file. What often happens is that the user chooses the Yes option to continue with the update and does not realise that this deletes the default configuration of cloud-init in our images.
Cloud-init is a service that we use to interact with the server and the user's portal. For example, when a resource resize is requested, the disk can be automatically expanded. If your server has not resized correctly, it means that you have the cloud-init service unconfigured. And therefore you will have to manually extend the partitions so that you have the correct space.
This is the message that usually appears during package updates:
If we have given the YES option, the installer will probably replace the service configuration file and the service will stop working. In the following tutorial we will explain the best way to reconfigure this service and make it work again without problems so that the next time you resize the disk it will work without problems.
Reconfigure cloud-init service
To solve this problem, we will create a new server with the minimum resources and the same distribution as our server. Once created, we will connect via SSH and copy the cloud-init configuration file to the affected server:
# scp /etc/cloud/cloud.cfg root@[IP_Server_Affected]:/etc/cloud/cloud.cfg
Also, if your server is Ubuntu 18.04 you will have to copy one more file. This process should only be done for Ubuntu 18.04 servers:
# scp /usr/lib/python3/dist-packages/cloudinit/config/cc_resizefs.py root@[IP_Server_Affected]:/usr/lib/python3/dist-packages/cloudinit/config/cc_resizefs.py
After copying the configuration file, we will have to restart the service:
# systemctl restart cloud-init
Now when you resize your server's disk again during the process, the partitions will be correctly extended and you will not have to manually extend the partitions because cloud-init will be occupied.
If you have any doubts or queries, please do not hesitate to contact us at firstname.lastname@example.org
We will be happy to help you :)