Notes on qcow2 on centos

I recently had to run a centos9 qcow2 on a centos7 machine. I ran into a few problems, however, I found these steps helpful as I worked through the issue and resolved my problem. I’ve recorded them here for posterity.


  1. Navigate to
  2. Click Last Modified twice to sort the images from most recent to oldest
  3. Find the latest qcow2 image – CentOS-Stream-GenericCloud-9-20230207.0.x86_64.qcow2
  4. Right Click and Copy Link
  1. Connect to your host
❯ curl -O -L
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  930M  100  930M    0     0  63.2M      0  0:00:14  0:00:14 --:--:--  104M
  1. Install the dependencies
❯ dnf install libguestfs-tools qemu-kvm.x86_64 libvirt virt-install libguestfs-xfs.x86_64
CentOS-7 - Base         0.0  B/s |   0  B     00:00    
CentOS-7 - Updates      0.0  B/s |   0  B     00:00    
CentOS-7 - Extras       0.0  B/s |   0  B     00:00    
Package libguestfs-tools-1:1.40.2-10.el7.noarch is already installed.
Package qemu-kvm-10:1.5.3-175.el7_9.6.x86_64 is already installed.
Package libvirt-4.5.0-36.el7_9.5.x86_64 is already installed.
Package virt-install-1.5.0-7.el7.noarch is already installed.
Dependencies resolved.
Nothing to do.
  1. Move the qcow over to images
❯ mv CentOS-Stream-GenericCloud-9-20230207.0.x86_64.qcow2 /var/lib/libvirt/images/
  1. Generate a password
❯ openssl rand -hex 10
  1. Set the password based on the previous step’s output
❯ LIBGUESTFS_BACKEND=direct virt-customize --format qcow2 -a /var/lib/libvirt/images/CentOS-Stream-GenericCloud-9-20230207.0.x86_64.qcow2 --root-password password:037c94bb31a9b9870178-example

Note, if it fails, add -v -x to see verbose logging. Also make sure your base OS is one that can process the filesystem and run the qcow2 image. E.g. RHEL8 or Centos8 or higher.

  1. Startup the VM
❯ sudo virt-install
    --name ocp-bastion-server
    --ram 4096
    --vcpus 2
    --disk path=/var/lib/libvirt/images/CentOS-Stream-GenericCloud-9-20230207.0.x86_64.qcow2 
    --os-type linux
    --os-variant rhel9.0
    --network bridge=virbr0
    --graphics none
    --serial pty
    --console pty
    --boot hd



To Grab RHCOS 4.12.

  1. Download from the mirror
❯ curl -O -L
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1149M  100 1149M    0     0  25.5M      0  0:00:45  0:00:45 --:--:-- 32.1M
  1. Unzip
❯ gunzip rhcos-qemu.x86_64.qcow2.gz

Debugging the FileSystem

If you have the wrong version installed, sometimes the file system echos issues with superblock.

guestfish -a /var/lib/libvirt/images/CentOS-Stream-GenericCloud-9-20230207.0.x86_64.qcow2 
mount /dev/sda1 /
dmesg | tail
><fs> run
><fs> list-filesystems
/dev/sda1: xfs
><fs> mount /dev/sda1 /
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.
><fs> dmesg | tail
[   19.169691]  sda: sda1
[   19.191795]  sda: sda1
[   19.211130]  sda: sda1
[   19.232340]  sda: sda1
[   76.488398] SGI XFS with ACLs, security attributes, no debug enabled
[   76.493455] XFS (sda1): Superblock has unknown read-only compatible features (0x4) enabled.
[   76.504604] XFS (sda1): Attempted to mount read-only compatible filesystem read-write.
[   76.505325] XFS (sda1): Filesystem can only be safely mounted read only.
[   76.505362] XFS (sda1): SB validate failed with error -22.
><fs> quit






Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.