Du bist hier:
CentOS CloudInit setup with proxmox
In this short example, we will show you how to set up Proxmox with CloudInit using simple tools.
- Install your desired Linux system normally with Proxmox. In this example I use CentOS 8. Make sure that your harddisk is as small as possible. Do not create a user during the installation. Set your desired password at the user root and set up the desired network settings. This can be useful for your later startup.
- Install all available updates.
- Now install CloudInit:
Debian / Ubuntu: apt install -y cloud-init cloud-utils cloud-initramfs-growroot Centos: yum install cloud-*
- Create the following file: /etc/init.d/growhdd.sh
This file is used to automatically increase the size of the partition at the first start. Please try before and adjust if necessary. With CentOS the enlargement of the partition does not work automatically.
#!/bin/bash growpart /dev/sda 2 pvresize /dev/sda2 lvextend --resizefs -l +100%FREE /dev/mapper/cl_centos-root xfs_growfs /dev/mapper/cl_centos-root rm /etc/systemd/system/run-at-startup.service systemctl disable run-at-startup.service
- Make the file executable:
chmod +x /etc/init.d/growhdd.sh
- now create the following file: /etc/system/system/run-at-startup.service
[Unit] Description=Run script once after boot [Service] Type=simple RemainAfterExit=yes ExecStart=/etc/init.d/growhdd.sh TimeoutStartSec=0 [Install] WantedBy=default.target
- Now allow SSH access using root and password. Edit /etc/cloud/cloud.cfg
disable_root: 0 ssh_pwauth: 1
ATTENTION: This gives root access via SSH using a password!
- Finally, execute the following commands:
systemctl daemon-reload systemctl enable run-at-startup.service nano /etc/cloud/cloud.cfg history -c
- Shut down your system in Proxmox using the Shutdown button.
- Turn the VM into a template.
- Done. Simply connect the VM and test it.