Fornitura di Fedora CoreOS su libvirt
Questa guida mostra come eseguire il provisioning di nuove istanze Fedora CoreOS (FCOS) su una piattaforma [libvirt](https://libvirt.org/), utilizzando l’hypervisor [QEMU](https://www.qemu.org/).
Prerequisiti
Prima di configurare una macchina FCOS, è necessario avere un file di configurazione Ignition con le proprie personalizzazioni. Se non ne hai uno, consulta Produzione di un File Ignition.
Fedora CoreOS dispone di un utente predefinito core che può essere utilizzato per esplorare il sistema operativo. Se desideri utilizzarlo, completa la sua configurazione fornendo, ad esempio, una chiave SSH.
|
You also need to have access to a host machine with libvirt
. The examples below use the virt-install
command-line tool, which must be separately installed beforehand.
If running on a host with SELinux enabled (use the sestatus command to check SELinux status), make sure your OS image and Ignition file are labeled as svirt_home_t . You can do this by placing them under ~/.local/share/libvirt/images/ or running chcon -t svirt_home_t /path/to/file .
|
Avvio di un’istanza VM
-
Recupera l’immagine più recente adatta alla piattaforma
qemu
usandocoreos-installer
(oppure scaricala e verifica dal web all’indirizzo https://fedoraproject.org/coreos/download/). Puoi usarecoreos-installer
come container da https://quay.io/repository/coreos/coreos-installer, oppure su Fedora installalo dai repository.STREAM="stable" # come binario installato: coreos-installer download -s $STREAM -p qemu -f qcow2.xz --decompress -C ~/.local/share/libvirt/images/ # o come container: podman run --pull=always --rm -v "${HOME}/.local/share/libvirt/images/:/data" -w /data \ quay.io/coreos/coreos-installer:release download -s $STREAM -p qemu -f qcow2.xz --decompress
-
Avvia una nuova macchina tramite
virt-install
, utilizzando il file Ignition con le tue personalizzazioni.# Percorso al file di configurazione Ignition IGNITION_CONFIG="/percorso/a/example.ign" # Percorso all'immagine disco QCOW2 IMAGE="/percorso/a/image.qcow2" # Nome della macchina virtuale VM_NAME="fcos-test-01" # Numero di CPU virtuali assegnate VCPUS="2" # Quantità di RAM (in megabyte) RAM_MB="2048" # Canale di aggiornamento di Fedora CoreOS (es. stable, testing, next) STREAM="stable" # Dimensione del disco (in gigabyte) DISK_GB="10" # Per architetture x86 / aarch64 IGNITION_DEVICE_ARG=(--qemu-commandline="-fw_cfg name=opt/com.coreos/config,file=${IGNITION_CONFIG}") # Per s390x / ppc64le, IGNITION_DEVICE_ARG=(--disk path="${IGNITION_CONFIG}",format=raw,readonly=on,serial=ignition,startup_policy=optional) # Setup the correct SELinux label to allow access to the config chcon --verbose --type svirt_home_t ${IGNITION_CONFIG} virt-install --connect="qemu:///system" --name="${VM_NAME}" --vcpus="${VCPUS}" --memory="${RAM_MB}" \ --os-variant="fedora-coreos-$STREAM" --import --graphics=none \ --disk="size=${DISK_GB},backing_store=${IMAGE}" \ --network bridge=virbr0 "${IGNITION_DEVICE_ARG[@]}"
virt-install requires both the OS image and Ignition file to be specified as absolute paths.
|
Depending on your version of virt-install , you may not be able to use --os-variant=fedora-coreos-* and will get an error. In this case, you should pick an older Fedora variant (--os-variant=fedora31 for example). You can find the variants that are supported by you current version of virt-install with osinfo-query os | grep '^\s*fedora' .
|
DISK_GB should be at least as big as the default size of the image. For Fedora CoreOS, this is currently 10 GB.
|
Make sure that your user has access to /dev/kvm . The default is to allow access for everyone, but on some distributions you may need to add yourself to the kvm group.
|
Puoi uscire dalla console seriale premendo CTRL + ] .
|
If you set up an SSH key for the default core
user, you can SSH into the VM and explore the OS:
ssh core@<ip address>
Want to help? Learn how to contribute to Fedora Docs ›