From Fedora Project Wiki

Description

Download, Install, Configure and autologin Fedora CoreOS as a virtual machine with Podman

Setup

  1. Install podman by running sudo dnf install podman -y
  2. Download and verify the desired image for QEMU

How to test

  1. Create an working directory by running mdkir ~/coreos && cd ~/coreos. Please skip this step if you already have a working directory.
  2. Download the latest Fedora CoreOS QCOW2 image, we will grab coreos-installer by runningpodman pull quay.io/coreos/coreos-installer:release
  3. Generate Ignition configuration from Fedora CoreOS Config files, we will grab fcct by runningpodman pull quay.io/coreos/fcct:release
  4. Validate Ignition configuration files, we will need ignition-validate by running podman pull quay.io/coreos/ignition-validate:release
  5. To make config easier, add the following alias
$ alias coreos-installer='podman run --pull=always            \
                        --rm --tty --interactive            \
                        --security-opt label=disable        \
                        --volume ${PWD}:/pwd --workdir /pwd \
                        quay.io/coreos/coreos-installer:release'
$ alias ignition-validate='podman run --rm --tty --interactive \
                         --security-opt label=disable        \
                         --volume ${PWD}:/pwd --workdir /pwd \
                         quay.io/coreos/ignition-validate:release'
$ alias fcct='podman run --rm --tty --interactive \
            --security-opt label=disable        \
            --volume ${PWD}:/pwd --workdir /pwd \
            quay.io/coreos/fcct:release'
  1. Using coreos-installer to download and decompress the image $coreos-installer download -p qemu -f qcow2.xz --decompress
  2. Execute touch fcct-autologin.yaml and make sure it has the following content
variant: fcos
version: 1.2.0
systemd:
  units:
    - name: serial-getty@ttyS0.service
      dropins:
      - name: autologin-core.conf
        contents: |
          [Service]
          # Override Execstart in main unit
          ExecStart=
          # Add new Execstart with `-` prefix to ignore failure`
          ExecStart=-/usr/sbin/agetty --autologin core --noclear %I $TERM
storage:
  files:
    - path: /etc/hostname
      mode: 0644
      contents:
        inline: |
          test
    - path: /etc/profile.d/systemd-pager.sh
      mode: 0644
      contents:
        inline: |
          # Tell systemd to not use a pager when printing information
          export SYSTEMD_PAGER=cat
    - path: /etc/sysctl.d/20-silence-audit.conf
      mode: 0644
      contents:
        inline: |
          # Raise console message logging level from DEBUG (7) to WARNING (4)
          # to hide audit messages from the interactive console
          kernel.printk=4

  1. Run $ fcct --pretty --strict fcct-autologin.yaml --output autologin.ign to convert the above yaml into a ignition config by fcct
  2. Setup the correct SELinux label to allow access to the config $ chcon --verbose --type svirt_home_t autologin.ign
  3. Start FCOS VM by running
virt-install --name=fcos --vcpus=2 --ram=2048 --os-variant=fedora-coreos-stable \
    --import --network=bridge=virbr0 --graphics=none \
    --qemu-commandline="-fw_cfg name=opt/com.coreos/config,file=${PWD}/autologin.ign" \
    --disk=size=20,backing_store=${PWD}/fedora-coreos-''XXYYYYYZZZZZ''.qcow2

<note> always remember to substitute the xxxyzzz with the downloaded image name </note>

Expected Results

  1. The system shows up and autologin is sucessful
  2. You can read the IP address of the machine from the serial console.
  3. You can run $ cat /etc/hostname to get test as output