|
| 1 | +https://wiki.almalinux.org/cloud/Generic-cloud.html#download-images |
| 2 | + |
| 3 | +https://github.com/AlmaLinux/cloud-images |
| 4 | + |
| 5 | +``` |
| 6 | +$ curl -LO https://repo.almalinux.org/almalinux/9/cloud/x86_64/images/CHECKSUM |
| 7 | +$ curl -LO https://repo.almalinux.org/almalinux/9/cloud/x86_64/images/AlmaLinux-9-GenericCloud-latest.x86_64.qcow2 |
| 8 | +
|
| 9 | +$ qemu-img info AlmaLinux-9-GenericCloud-latest.x86_64.qcow2 |
| 10 | +
|
| 11 | +$ sudo qemu-img convert \ |
| 12 | + -f qcow2 \ |
| 13 | + -O qcow2 \ |
| 14 | + AlmaLinux-9-GenericCloud-latest.x86_64.qcow2 \ |
| 15 | + /var/lib/libvirt/images/almalinux-9.qcow2 |
| 16 | +$ sudo qemu-img resize \ |
| 17 | + -f qcow2 \ |
| 18 | + /var/lib/libvirt/images/almalinux-9.qcow2 \ |
| 19 | + 32G |
| 20 | +``` |
| 21 | + |
| 22 | +``` |
| 23 | +touch network-config |
| 24 | +
|
| 25 | +cat >meta-data <<EOF |
| 26 | +instance-id: almalinux-9 |
| 27 | +local-hostname: almalinux-9 |
| 28 | +EOF |
| 29 | +
|
| 30 | +cat >user-data <<EOF |
| 31 | +#cloud-config |
| 32 | +password: superseekret |
| 33 | +chpasswd: |
| 34 | + expire: False |
| 35 | +ssh_pwauth: True |
| 36 | +EOF |
| 37 | +``` |
| 38 | + |
| 39 | +``` |
| 40 | +sudo apt-get update |
| 41 | +sudo apt-get install genisoimage |
| 42 | +genisoimage \ |
| 43 | + -input-charset utf-8 \ |
| 44 | + -output almalinux-9-cloud-init.img \ |
| 45 | + -volid cidata -rational-rock -joliet \ |
| 46 | + user-data meta-data network-config |
| 47 | +sudo cp almalinux-9-cloud-init.img \ |
| 48 | + /var/lib/libvirt/boot/almalinux-9-cloud-init.iso |
| 49 | +``` |
| 50 | + |
| 51 | +``` |
| 52 | +$ sudo apt-get install libosinfo-bin |
| 53 | +$ osinfo-query os |
| 54 | +``` |
| 55 | + |
| 56 | +``` |
| 57 | +virt-install \ |
| 58 | + --connect qemu:///system \ |
| 59 | + --name almalinux-9 \ |
| 60 | + --boot uefi \ |
| 61 | + --memory 4096 \ |
| 62 | + --vcpus 2 \ |
| 63 | + --os-variant almalinux9 \ |
| 64 | + --disk /var/lib/libvirt/images/almalinux-9.qcow2,bus=virtio \ |
| 65 | + --disk /var/lib/libvirt/boot/almalinux-9-cloud-init.iso,device=cdrom \ |
| 66 | + --network network=default,model=virtio \ |
| 67 | + --graphics spice \ |
| 68 | + --noautoconsole \ |
| 69 | + --console pty,target_type=serial \ |
| 70 | + --import \ |
| 71 | + --debug |
| 72 | +
|
| 73 | +virsh console almalinux-9 |
| 74 | +
|
| 75 | +# login with almalinux user |
| 76 | +
|
| 77 | +$ cloud-init status --wait |
| 78 | +status: done |
| 79 | +
|
| 80 | +# Verify networking is working |
| 81 | +$ ip -br a |
| 82 | +
|
| 83 | +# If networking isn't correct, regenerate only the network config |
| 84 | +$ sudo cloud-init clean --configs network |
| 85 | +$ sudo cloud-init init --local |
| 86 | +
|
| 87 | +# Disable cloud-init |
| 88 | +$ sudo touch /etc/cloud/cloud-init.disabled |
| 89 | +
|
| 90 | +$ cloud-init status |
| 91 | +status: disabled |
| 92 | +
|
| 93 | +$ sudo shutdown -h now |
| 94 | +
|
| 95 | +$ virsh domblklist almalinux-9 |
| 96 | + Target Source |
| 97 | +------------------------------------------------------------ |
| 98 | + vda /var/lib/libvirt/images/almalinux-9.qcow2 |
| 99 | + sda /var/lib/libvirt/boot/almalinux-9-cloud-init.iso |
| 100 | + |
| 101 | +$ virsh change-media almalinux-9 sda --eject |
| 102 | +Successfully ejected media. |
| 103 | +
|
| 104 | +$ sudo rm /var/lib/libvirt/boot/almalinux-9-cloud-init.iso |
| 105 | +
|
| 106 | +# Verify image boots without cloud-init iso being mounted |
| 107 | +``` |
| 108 | + |
| 109 | +``` |
| 110 | +$ virsh snapshot-create-as --domain almalinux-9 --name clean --description "Initial install" |
| 111 | +$ virsh snapshot-list almalinux-9 |
| 112 | +$ virsh snapshot-revert almalinux-9 clean |
| 113 | +$ virsh snapshot-delete almalinux-9 clean |
| 114 | +
|
| 115 | +$ virsh shutdown almalinux-9 |
| 116 | +$ virsh undefine almalinux-9 --nvram --remove-all-storage |
| 117 | +``` |
0 commit comments