CloudInit set up

Support Wissensdatenbank

Du bist hier:
Print

CentOS CloudInit setup with proxmox

In this short example, we will show you how to set up Proxmox with CloudInit using simple tools.

  1. 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.
  2. Install all available updates.
  3. Now install CloudInit:
    Debian / Ubuntu:
    apt install -y cloud-init cloud-utils cloud-initramfs-growroot
    
    Centos:
    yum install cloud-*
  4. 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
  5. Make the file executable:
    chmod +x /etc/init.d/growhdd.sh

     

  6. 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
  7. 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!

  8. Finally, execute the following commands:
    systemctl daemon-reload
    systemctl enable run-at-startup.service
    nano /etc/cloud/cloud.cfg
    history -c

     

  9. Shut down your system in Proxmox using the Shutdown button.
  10. Turn the VM into a template.
  11. Done. Simply connect the VM and test it.

 

War dieser Artikel hilfreich?
0 out Of 5 Stars
5 Stars 0%
4 Stars 0%
3 Stars 0%
2 Stars 0%
1 Stars 0%
Wie können wir diesen Artikel verbessern?
Please submit the reason for your vote so that we can improve the article.
Brauchst du Hilfe?
Related Post