Cloud-init information
Much extended the original Cloud-init article Add full guide for preparing Debian as a template for XCP-ng
This commit is contained in:
parent
3a99ab7b09
commit
b3b02d13a9
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
title: Cloud-Init
|
title: Cloud-Init
|
||||||
visible: false
|
visible: true
|
||||||
---
|
---
|
||||||
|
|
||||||
[toc]
|
[toc]
|
||||||
@ -19,8 +19,41 @@ apt install cloud-init cloud-initramfs-growroot
|
|||||||
|
|
||||||
[/shroot]
|
[/shroot]
|
||||||
|
|
||||||
### AlmaLinux
|
## Cloud-init
|
||||||
|
|
||||||
## Config file
|
|
||||||
|
|
||||||
Cloud-init has a config file in `/etc/cloud/cloud.cfg`
|
Cloud-init has a config file in `/etc/cloud/cloud.cfg`
|
||||||
|
|
||||||
|
### Growing partitions
|
||||||
|
|
||||||
|
With growroot installed in the initramfs, cloud-init will expand partitions and filesystems to fit the root partition given.
|
||||||
|
|
||||||
|
### XCP-ng: Set Hostname
|
||||||
|
|
||||||
|
This cloud config snippet sets the machine hostname to the VM name.
|
||||||
|
|
||||||
|
```
|
||||||
|
#cloud-config
|
||||||
|
hostname: {name}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Network config
|
||||||
|
|
||||||
|
The network config is a special config file with cloud-init that focuses on specifying network settings.
|
||||||
|
|
||||||
|
### Set Static IP
|
||||||
|
|
||||||
|
The snippet below sets a static ip address for the specified interface.
|
||||||
|
Its syntax mainly follows the `/etc/network/interfaces` syntax.
|
||||||
|
|
||||||
|
```
|
||||||
|
network:
|
||||||
|
version: 1
|
||||||
|
config:
|
||||||
|
- type: physical
|
||||||
|
name: [INTERFACE]
|
||||||
|
subnets:
|
||||||
|
- type: static
|
||||||
|
address: [ADDRESS]
|
||||||
|
gateway: [ADDRESS]
|
||||||
|
dns_nameservers: [ADDRESS]
|
||||||
|
```
|
||||||
|
@ -0,0 +1,61 @@
|
|||||||
|
---
|
||||||
|
title: "Debian Create new template"
|
||||||
|
visible: true
|
||||||
|
---
|
||||||
|
|
||||||
|
[toc]
|
||||||
|
|
||||||
|
This guide focuses on creating a new template for Debian that can be used with XCP-ng.
|
||||||
|
|
||||||
|
## VM Creation
|
||||||
|
|
||||||
|
Before even starting the installation, a new VM has to be created.
|
||||||
|
I choose the `Other install media` template and set the Distro name prefixed with "CR".
|
||||||
|
The usual sizing is 1 vCPU and 1 GiB RAM.
|
||||||
|
Add a network interface in the most commonly used network.
|
||||||
|
Add a disk, a size of 10 GiB is a good starting point.
|
||||||
|
Finally in the advanced settings, change the boot firmware from `bios` to `uefi`
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
Most of the installation can be done as usual, though some parts must be observed.
|
||||||
|
The root user will get a password. We also create a new non-root user.
|
||||||
|
For partitioning, choose the manual method.
|
||||||
|
The following partitions should be created, all of them as primary partitions.
|
||||||
|
|
||||||
|
- Type **EFI** _128M_
|
||||||
|
- Type **Swap** _1G_
|
||||||
|
- Type **EXT4** _remaining space_
|
||||||
|
|
||||||
|
![Partitions overview](partitioning.webp)
|
||||||
|
|
||||||
|
Accept the created partitioning
|
||||||
|
|
||||||
|
> The reason for this layout is so Cloud-init can automatically grow the root partition when the underlying virtual disk is expanded
|
||||||
|
|
||||||
|
Reboot after the installation completes.
|
||||||
|
|
||||||
|
## Cloud-init
|
||||||
|
|
||||||
|
Install Cloud-init to use its configurations.
|
||||||
|
On debian the required packages are `cloud-init` and `cloud-initramfs-growroot`
|
||||||
|
|
||||||
|
> More information can be found on the [Cloud-init page](/linux/cloud-init).
|
||||||
|
|
||||||
|
## Final Configuration
|
||||||
|
|
||||||
|
### Networking
|
||||||
|
|
||||||
|
Edit `/etc/network/interfaces` and remove the network interface defined there.
|
||||||
|
Cloud-init will create a new definition under `/etc/network/interfaces.d`
|
||||||
|
|
||||||
|
### ISO-file
|
||||||
|
|
||||||
|
Unmount and remove the installation ISO-file.
|
||||||
|
|
||||||
|
## Conversion
|
||||||
|
|
||||||
|
Poweroff the VM and go to its `Advanced` tab.
|
||||||
|
![XCP-ng Advanced tab](xcp-ng-advanced-tab.webp)
|
||||||
|
|
||||||
|
Before clicking `Convert to template`, creating a clone is recommended.
|
Binary file not shown.
After Width: | Height: | Size: 28 KiB |
Binary file not shown.
After Width: | Height: | Size: 8.6 KiB |
Loading…
Reference in New Issue
Block a user