Hello,
Is there going to be a generic cloud image or .qcow that can be downloaded for Rocky? this is useful in cloud or virtualization envoirnment, an image contains cloud tools.
Hello,
Is there going to be a generic cloud image or .qcow that can be downloaded for Rocky? this is useful in cloud or virtualization envoirnment, an image contains cloud tools.
Support this idea! It is absolutely necessary to have such cloud images. CentOS and Ubuntu are have such images which allow to start a virtual server on systems like SolusIO.
AlmaLinux doesnât provide cloud images now, but they are create scripts for Packer which makes creation a cloud image a super easy GitHub - AlmaLinux/cloud-images: Packer templates and other tools for building AlmaLinux images for various cloud platforms.
In case anyone else has been watching this like I have, the generic cloud image is available at Index of /pub/rocky/8.4/images/.
Hi,
Iâve tested the cloud image and it doesnât work.
It cannot allocate the kernel
looking into the grub there are some variables in there that not have been resolved. especially the ($root). which should point to the correct device.
Rob
the qcow booted fine for me. Maybe this is a silly question, but what are the creds?
@adamaze usually the image when boots uses cloud-init, which would inject the SSH key for you to be able to gain access. Assuming that you did provide your ssh key to do this when booting the image, then you should be able to ssh using rocky as the username, which should have your SSH key attached to it. This is the normal practice for example when booting instances with AWS, OpenStack, etc that use such images.
To be honest, I ended up here with a quick Google. I saw that there was a qcow file mentioned, so I literally just downloaded that and made a VM off of it⌠So I didnât do anything custom to it. It seemed to good to be true, and it looks like it was. I have only ever used cloud images on AWS, and I was looking for something that simple for my home lab using libvirt/virt-manager.
Is there something I can do to this official image to inject my key in? Or am I asking the wrong question?
With libvirt/kvm I doubt very much that is possible. At best, boot from an ISO in rescue mode, mount the partition chroot into it and reset the password for the rocky user using passwd rocky
you will have to do touch /.autorelabel so that selinux will fix the contexts on /etc/passwd and /etc/shadow after the password change. Then you exit chroot, and reboot and you should be able to gain access to the system.
Although probably easier download the minimal iso and do a Rocky install like I did in virt-manager with libvirt/kvm.
In centos 7 you can use âguestfishâ command to mount and make changes to qcow2 image, it should be part of libguestfs tools and it can be used to change the password or add a new user etcâŚ
Hi,
Since these are cloud images they very likely run cloud-init.
All devs who use cloud-init take the following info for granted and assume you already know all this.
Hence the really poorly written documentation on this subject.
You probably need to provide user-data and meta-data to configure the pubkey for root and/or any other user
also the root account is default disabled and only pubkey auth is allowed.
So you either unlock the root account or add a user that is allowed to do sudo.
Also provide pubkeys or enable password auth.
I personally use the nocloud way to do this
ie: on an iso image with the label cidata (the label MUST be cidata or CIDATA)
containing two files: meta-data and user-data (when using redhat family distros the file network-config wonât work)
[root@home~]#cat meta-data
instance-id: 7fb51d52-b760-59f9-af13-eb63a61b0afb
network-interfaces: |
auto eth0
iface eth0 inet static
address 192.168.100.3
network 192.168.100.0
netmask 255.255.255.0
broadcast 192.168.100.255
gateway 192.168.100.1
dns-nameservers 192.168.100.2
dns-search linux.lab
[root@home~]#cat user-data
#cloud-config
preserve_hostname: false
hostname: rocky8
fqdn: rocky8.linux.lab
ssh_pwauth: True
users:
- name: root
hashed_passwd: $6$h1yH04xTmMdzeQoL$1CurwduV5JjozaxnrsHj/UaO7PIrnI89l0s.2/jdesNtHwf6tmUs5fK9HH38wikGXyzY2u1fOoBQ.TVTdTWEl/
lock_passwd: false
ssh_authorized_keys:
- ssh-rsa <your pubkey here>
runcmd:
- echo 'hello world 1'
- echo 'hello world 2'
- echo 'hello world 3'
then create the iso
genisoimage -volid cidata -joliet -rock -output /path/to/my_config.iso /path/to/user-data /path/to/meta-data
this will create the iso
mount it in the cdrom of the vm running the qcow then (re)boot it.
some details
meta-data
user-data
details about everything can be found in the cloud-init docs
which are horrible to read (they really do take this stuff for granted), but they do contain an awfull lot detailed information.
Which you will realize after you googled for weeks on how to use them.
Rob
thanks everyone for the great responses!
I went with what seemed the simplest fix for what I needed.
grab cloud image
wget https://download.rockylinux.org/pub/rocky/8.4/images/Rocky-8-GenericCloud-8.4-20210620.0.x86_64.qcow2 -O /var/lib/libvirt/images/rocky_gold_template.qcow2
install libguestfs-tools to get guestfish
yum install -y libguestfs-tools
âmountâ up image RW
guestfish --rw -a /var/lib/libvirt/images/rocky_gold_template.qcow2 -i
inside the guestfish prompt, run the following (i just paste in all at once)
mkdir /root/.ssh
touch /root/.ssh/authorized_keys
chmod 0700 /root/.ssh/
chmod 0600 /root/.ssh/authorized_keys
touch /.autorelabel
vi /root/.ssh/authorized_keys
paste your desired public key in and save/quit
exit guestfish shell:
quit
copy your new gold template to a new file for use by a new VM
cp /var/lib/libvirt/images/rocky_gold_template.qcow2 /var/lib/libvirt/images/rocky-test-vm.qcow2
and now you are ready to import a VM specifying the new rocky-test-vm.qcow2
feel free to tell me if this is a terrible way to do it, but it seemed to work just fine for me
I also wanted to note here that virt-install and the like accept a --cloud-init
argument which, by default, will generate a random root password for the host and display it to the user during installation. Itâs also super simple to add a key using the --cloud-init argument using some simple userdata. If anyone needs a tutorial on that, Iâd be happy to find some time to write something up, but Iâm sure there are some online already too!
E.g., the auto-generation of a root pw
The command:
virt-install --name "your-vm-name" \
--virt-type kvm --import \
--memory 1024 --vcpus 2 \
--disk path=/tmp/cloud.qcow2,device=disk \
--os-type Linux --os-variant centos8 \
--network default \
--console pty,target_type=serial --graphics vnc \
--cloud-init root-password-generate=on,disable=on
This isnât working for me, Iâm getting the following error:
[root@util QCOWs]# guestfish --rw -a Rocky-8-GenericCloud-8.5-20211114.2.x86_64.qcow2 -i
libguestfs: error: mount: mount exited with status 32: mount: wrong fs type, bad option, bad superblock on /dev/sda1,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so.
Do we have any workaround for this issue, Please
Hi neil,
I just tried this out, only to realize that the --cloud-init option was introduced in version 3.0.0, but rocky 8.5 uses version 2.2.1. Am I missing something, or gasp are you not using Rocky as your kvm server?
i ended up using virt-customize to replace my guestfish steps. Here is a tiny bash script I made:
# Set a few variables
hostname_to_build=rocky-forum-test
ram=4096
vcpu=4
disk_size=10
ssh_key=/var/lib/libvirt/images/cenmain_id_rsa.pub
rocky_image_url=https://download.rockylinux.org/pub/rocky/8.5/images/Rocky-8-GenericCloud-8.5-20211114.2.x86_64.qcow2
# Grab Rocky 8.5 image if it doesnt already exist
if [[ ! -f /var/lib/libvirt/images/rocky_gold_template.qcow2 ]]; then
wget $rocky_image_url -O /var/lib/libvirt/images/rocky_gold_template.qcow2
fi
# copy/rename image for use with new VM
cp /var/lib/libvirt/images/rocky8.5_gold.qcow2 /var/lib/libvirt/images/${hostname_to_build}.qcow2
# use virt-customize to set hostname and place ssh key
virt-customize -a /var/lib/libvirt/images/${hostname_to_build}.qcow2 --hostname $hostname_to_build --ssh-inject "root:file:$ssh_key" --uninstall cloud-init --selinux-relabel
# use virt-install to deploy customized VM image
virt-install -n $hostname_to_build --os-type=Linux --os-variant=centos8 --ram=$ram --vcpus=$vcpus --disk path=/var/lib/libvirt/images/${hostname_to_build}.qcow2,bus=virtio,size=$disk_size --network bridge:br0 --import --noautoconsole
If you are still on this, I would suggest trying the other way I found (virt-customize)
Great point! My workstation here runs fedora
I have a different question although somewhat related. Let me get to the question. Can you successfully install a Rocky 8.x image that is hardened using the Standard Red Hat Linux VM hardening?
I built my Rocky 8.x VM with hardening on Virtual Box (vmdk format) and then converted with qemu-img tools to qcow2. When I install on the Openstack cloud, it only triggers initramfs and when I run blkid, I do not pickup my hard drive partitions.
As youâve posted a duplicate question, I will answer it in your other post. Itâs best not to double-post to save people confusion.
to @adamaze and @iwalker : walkthrough about how to authenticate a cloud image using virsh (so virt-manager should be easy to get to from there)
I also came here looking for said cloud images. any tar.xz for systemd? Will keep scouring âŚ
Nice, glad you got it sorted ⌠should have read the rest of the thread before posting anyway, hope the link helps, too âŚ