LIVEMEDIA-CREATOR(1)

πŸ“¦
version 44.7 Β· 3 versions
, in fedora 43, fedora 44

✨ NAME ✨

livemedia-creator β€” Live Media Creator Documentation πŸ’–

πŸŽ€ Authors πŸŽ€

Brian C. Lane <bcl@redhat.com>


okay bestie, sit down, hydrate, because this tool is iconic and I need you to understand it. livemedia-creator uses Anaconda, kickstart and Lorax to create bootable media that use the same install path as a normal system installation. No cap. It can be used to make live isos, bootable (partitioned) disk images, tarfiles, and filesystem images for use with virtualization and container solutions like libvirt, docker, and OpenStack. it's giving versatility πŸ’…

The general idea is to use qemu with kickstart and an Anaconda boot.iso to install into a disk image and then use the disk image to create the bootable media. like, that's the whole plot πŸ¦‹

livemedia-creator --help will describe all of the options available. At the minimum you need:

  • --make-iso to create a final bootable .iso or one of the other --make-* options. ⭐
  • --iso to specify the Anaconda install media to use with qemu.
  • --ks to select the kickstart file describing what to install.
🫢 heads up bestie: to use livemedia-creator with virtualization you will need to have qemu installed.
πŸ™ˆ and if you are going to be using Anaconda directly, with --no-virt mode, make sure you have the anaconda-tui package installed. do not skip this, I am literally begging.

🌈 Conventions used in this document: 🌈

  • lmc is an abbreviation for livemedia-creator.
  • builder is the system where livemedia-creator is being run
  • image is the disk image being created by running livemedia-creator

that's the intro, bestie β€” the rest is coming, stay with me 🧚

πŸ¦‹ SYNOPSIS πŸ¦‹

okay bestie, here's the whole entire shape of the thing before we get into the vibes. it's a lot of brackets. it's giving "choose your own adventure" but make it bootable:

usage: livemedia-creator [-h]
                         (--make-iso | --make-disk | --make-fsimage | --make-appliance | --make-ami | --make-tar | --make-tar-disk | --make-pxe-live | --make-ostree-live | --make-oci | --make-vagrant)
                         [--iso ISO] [--iso-only] [--iso-name ISO_NAME] [--ks KS] [--image-only]
                         [--no-virt] [--proxy PROXY] [--anaconda-arg ANACONDA_ARGS]
                         [--armplatform ARMPLATFORM] [--location LOCATION] [--logfile LOGFILE]
                         [--lorax-templates LORAX_TEMPLATES] [--tmp TMP] [--resultdir RESULT_DIR]
                         [--macboot] [--nomacboot] [--extra-boot-args EXTRA_BOOT_ARGS] [-r RELEASE]
                         [-t VARIANT] [-b URL] [--isfinal] [--disk-image DISK_IMAGE] [--keep-image]
                         [--fs-image FS_IMAGE] [--image-name IMAGE_NAME]
                         [--tar-disk-name TAR_DISK_NAME] [--fs-label FS_LABEL]
                         [--image-size-align IMAGE_SIZE_ALIGN] [--image-type IMAGE_TYPE]
                         [--qemu-arg QEMU_ARGS] [--qcow2] [--qcow2-arg QEMU_ARGS]
                         [--compression COMPRESSION] [--compress-arg COMPRESS_ARGS]
                         [--app-name APP_NAME] [--app-template APP_TEMPLATE] [--app-file APP_FILE]
                         [--ram MEMORY] [--cpu CPU] [--vcpus VCPUS] [--vnc VNC] [--arch ARCH]
                         [--kernel-args KERNEL_ARGS] [--firmware FW_PATH] [--virt-uefi] [--no-kvm]
                         [--with-rng WITH_RNG] [--dracut-conf DRACUT_CONF] [--dracut-arg DRACUT_ARGS]
                         [--live-rootfs-size LIVE_ROOTFS_SIZE] [--live-rootfs-keep-size]
                         [--oci-config OCI_CONFIG] [--oci-runtime OCI_RUNTIME]
                         [--vagrant-metadata VAGRANT_METADATA] [--vagrantfile VAGRANTFILE]
                         [--project PRODUCT] [-p PRODUCT] [--releasever RELEASEVER] [--volid VOLID]
                         [--squashfs-only] [--rootfs-type ROOTFSTYPE] [--timeout TIMEOUT] [-V]

see that big parenthesised pile up top? you have to pick exactly one of those mode flags. that's your main character decision. everything else is optional garnish ✨


✨ OPTIONS ✨

πŸ’– Named Arguments πŸ’–

the modes first, because they're the moment:

  • --make-iso β€” Build a live iso. Default: False
  • --make-disk β€” Build a partitioned disk image. Default: False
  • --make-fsimage β€” Build a filesystem image. Default: False
  • --make-appliance β€” Build an appliance image and XML description. Default: False
  • --make-ami β€” Build an ami image. Default: False
  • --make-tar β€” Build a tar of the root filesystem. Default: False
  • --make-tar-disk β€” Build a tar of a partitioned disk image. Default: False
  • --make-pxe-live β€” Build a live pxe boot squashfs image. Default: False
  • --make-ostree-live β€” Build a live pxe boot squashfs image of Atomic Host. Default: False
  • --make-oci β€” Build an Open Container Initiative image. Default: False
  • --make-vagrant β€” Build a Vagrant Box image. Default: False

then the rest of the gang:

  • --iso β€” Anaconda installation .iso path to use for qemu. 🫢
  • --iso-only β€” Remove all iso creation artifacts except the boot.iso, combine with --iso-name to rename the boot.iso. Default: False
  • --iso-name β€” Name of output iso file for --iso-only. Default is boot.iso
  • --ks β€” Kickstart file defining the install. (yes. this is THE one you actually care about πŸ’…)
  • --image-only β€” Exit after creating fs/disk image. Default: False
  • --no-virt β€” Run anaconda directly on host instead of using qemu. Default: False
  • --proxy β€” proxy URL to use for the install
  • --anaconda-arg β€” Additional argument to pass to anaconda (no-virt mode). Pass once for each argument
  • --armplatform β€” the platform to use when creating images for ARM, i.e., highbank, mvebu, omap, tegra, etc.
  • --location β€” location of iso directory tree with initrd.img and vmlinuz. Used to run qemu with a newer initrd than the iso.
  • --logfile β€” Name and path for primary logfile, other logs will be created in the same directory. Default: ./livemedia.log
  • --lorax-templates β€” Path to mako templates for lorax
  • --tmp β€” Top level temporary directory. Default: /var/tmp
  • --resultdir β€” Directory to copy the resulting images and iso into. Defaults to the temporary working directory
  • --macboot β€” Make the iso bootable on UEFI based Mac systems. Default: True
  • --nomacboot β€” Do not create a Mac bootable iso. Default: False
  • --extra-boot-args β€” Extra arguments to add to the bootloader kernel cmdline in the templates. Default: ""
  • -r, --release β€” release information. Default: ""
  • -t, --variant β€” variant name. Default: ""
  • -b, --bugurl β€” bug reporting URL for the product. Default: "your distribution provided bug reporting tool"
  • --isfinal β€” Default: False
  • --project β€” substituted for @PRODUCT@ in bootloader config files. Default: "Linux"
  • -p, --product β€” Alias for --project. Default: ""
  • --releasever β€” substituted for @VERSION@ in bootloader config files. Default: "41"
  • --volid β€” volume id
  • --squashfs-only β€” Ignored, provided for backward compatibility. Default: False
  • --rootfs-type β€” Type of rootfs: squashfs,squashfs-ext4,erofs,erofs-ext4. Default: "squashfs"
  • --timeout β€” Cancel installer after X minutes
  • -V β€” show program's version number and exit
fr fr, that's a LOT of flags and you will not need all of them at once. breathe. 🌸

πŸ’½ disk/fs image arguments

  • --disk-image β€” Path to existing disk image to use for creating final image.
  • --keep-image β€” Keep raw disk image after .iso creation. Default: False
  • --fs-image β€” Path to existing filesystem image to use for creating final image.
  • --image-name β€” Name of output file to create. Used for tar, fs and disk image. Default is a random name.
  • --tar-disk-name β€” Name of the archive member for make-tar-disk.
  • --fs-label β€” Label to set on fsimage, default is 'Anaconda'. Default: "Anaconda"
  • --image-size-align β€” Create a disk image with a size that is a multiple of this value in MiB. Default: 0
  • --image-type β€” Create an image with qemu-img. See qemu-img --help for supported formats.
  • --qemu-arg β€” Arguments to pass to qemu-img. Pass once for each argument, they will be used for ALL calls to qemu-img. Default: []
  • --qcow2 β€” Create qcow2 image instead of raw sparse image when making disk images. Default: False
  • --qcow2-arg β€” Arguments to pass to qemu-img. Pass once for each argument, they will be used for ALL calls to qemu-img. Default: []
  • --compression β€” Compression binary for make-tar. xz, lzma, gzip, and bzip2 are supported. xz is the default. Default: "xz"
  • --compress-arg β€” Arguments to pass to compression. Pass once for each argument. Default: []

πŸŽ€ appliance arguments πŸŽ€

  • --app-name β€” Name of appliance to pass to template
  • --app-template β€” Path to template to use for appliance data.
  • --app-file β€” Appliance template results file. Default: "appliance.xml"

πŸ–₯️ qemu arguments πŸ–₯️

  • --ram β€” Memory to allocate for installer in megabytes. Default: 2048
  • --cpu β€” Passed to qemu -cpu command. Default is to use -cpu host.
  • --vcpus β€” Passed to qemu -smp command. Number of virtual cpus.
  • --vnc β€” Passed to qemu -display command. eg. vnc=127.0.0.1:5, default is to choose the first unused vnc port.
  • --arch β€” System arch to build for. Used to select qemu-system-* command. Defaults to qemu-system-<arch>
  • --kernel-args β€” Additional argument to pass to the installation kernel
  • --firmware, --ovmf-path β€” Path to top of the EDK2 UEFI firmware directory tree. Default: "/usr/share/edk2/"
  • --virt-uefi β€” Use UEFI firmware to boot the VM in UEFI mode. Default: False
  • --no-kvm β€” Skip using kvm with qemu even if it is available. Default: False
  • --with-rng β€” RNG device for QEMU (none for no RNG). Default: "/dev/random"

🧚 dracut arguments: (default: ) 🧚

  • --dracut-conf β€” Path to a dracut.conf file to use instead of the default arguments. See the dracut.conf(5) manpage.
  • --dracut-arg β€” Argument to pass to dracut when rebuilding the initramfs. Pass this once for each argument. NOTE: this overrides the defaults.
heads up bestie: --dracut-arg overrides the defaults. not "adds to", not "nudges" β€” overrides. 😭

🌈 pxe to live arguments 🌈

  • --live-rootfs-size β€” Size of root filesystem of live image in GiB. Default: 0
  • --live-rootfs-keep-size β€” Keep the original size of root filesystem in live image. Default: False

πŸ“¦ OCI arguments πŸ“¦

  • --oci-config β€” config.json OCI configuration file
  • --oci-runtime β€” runtime.json OCI configuration file

🚐 Vagrant arguments 🚐

  • --vagrant-metadata β€” optional metadata.json file
  • --vagrantfile β€” optional vagrantfile

πŸš€ QUICKSTART πŸš€

okay so you wanna make a bootable live iso? run this, it's literally the whole vibe:

sudo livemedia-creator --make-iso \
--iso=/extra/iso/boot.iso --ks=./docs/fedora-livemedia.ks

and you can run it straight out of the lorax git repo like this, no install needed:

sudo PATH=./src/sbin/:$PATH PYTHONPATH=./src/ ./src/sbin/livemedia-creator \
--make-iso --iso=/extra/iso/boot.iso \
--ks=./docs/fedora-livemedia.ks --lorax-templates=./share/

you can watch the installation happen over vnc πŸ‘€ the logs will show what port was chosen, or you can use a specific port by passing it. eg. --vnc vnc:127.0.0.1:5

this is usually a good idea when testing changes to the kickstart. lmc tries to monitor the logs for fatal errors, but may not catch everything.

translation: watch it with your own eyeballs, don't just trust the logs to tell you something went sideways πŸ’€

✨ HOW ISO CREATION WORKS ✨

okay bestie, deep breath, this is the lore πŸ’– there are literally 2 stages and once u get them u get everything:

  1. the install stage β€” this is the one that spits out a disk or filesystem image as its output
  2. the boot media creation β€” this one takes that image and uses it as its input

normally you'd run both stages, no thoughts, just vibes. but you can also stop after the install stage if u want, by using --image-only. OR you can skip the install stage entirely and just use a disk image you made earlier by passing --disk-image or --fs-image. mix and match, ur the main character 🫢

When creating an iso, qemu boots using the Anaconda installer iso you passed it, and installs the system based on the kickstart. The %post section of the kickstart is what customizes the installed system, in the exact same way that current spin-kickstarts do. slay.

livemedia-creator monitors the install process for problems by watching the install logs. they get written to the current directory, or to the base directory you specified with the --logfile command. you can also monitor the install with a vnc client β€” and honestly? recommended when you're first modifying a kickstart, because there are still places where Anaconda may get stuck without the log monitor catching it 😭 like it'll just be sitting there. vibing. not installing. so use vnc bestie.

The output from this process is a partitioned disk image. kpartx can be used to mount and examine it when there's a problem with the install. It can also be booted using kvm πŸŽ€

When creating an iso, the disk image's / partition is copied into a formatted filesystem image, which is then used as the input to lorax for creation of the final media.

The final image is created by lorax, using the templates in /usr/share/lorax/live/ or the live directory below the directory specified by --lorax-templates. The templates are written using the Mako template system with some extra commands added by lorax ✨

NOTE: The output from --make-iso includes the artifacts used to create the boot.iso β€” the kernel, initrd, the squashfs filesystem, etc. If you only want the boot.iso you can pass --iso-only and the other files will be removed. You can also name the iso by using --iso-name my-live.iso. πŸ’…

🌸 KICKSTARTS 🌸

The docs/ directory includes several example kickstarts β€” one to create a live desktop iso using GNOME, and another to create a minimal disk image. When you're making your own kickstarts you should start with the minimal example, it includes several needed packages that are not always included by dependencies. (rude of the dependencies tbh.)

Or you can use existing spin kickstarts to create live media with a few changes. Here are the steps I used to convert the Fedora XFCE spin, fr fr:

  1. Flatten the xfce kickstart using ksflatten
  2. Add zerombr so you don't get the disk init dialog
  3. Add clearpart --all
  4. Add swap partition
  5. bootloader target
  6. Add shutdown to the kickstart
  7. Add network --bootproto=dhcp --activate to activate the network. This works for F16 builds but for F15 and before you need to pass something on the cmdline that activates the network, like sshd:
livemedia-creator --kernel-args="sshd"
  1. Add a root password:
rootpw rootme
network --bootproto=dhcp --activate
zerombr
clearpart --all
bootloader --location=mbr
part swap --size=512
shutdown
  1. In the livesys script section of the %post, remove the root password. This really depends on how the spin wants to work. You could add the live user that you create to the %wheel group so that sudo works, if you wanted to:
passwd -d root > /dev/null
  1. Remove /etc/fstab in %post, dracut handles mounting the rootfs:
cat /dev/null > /dev/fstab

Do this only for live iso's β€” the filesystem will be mounted read only if there is no /etc/fstab

  1. Don't delete initramfs files from /boot in %post
  2. When creating live iso's you need to have, at least, these packages in the %package section:
dracut-config-generic
dracut-live
-dracut-config-rescue
grub2-efi
syslinux
NOTE: The kickstart must contain part / --size=1024 in order to set the size of the root filesystem's disk image. Other partitions may be included, depending on the image type being created. autopart cannot be supported due to lmc needing to create the disk image file before running the installer on it. 🫠 so yeah, no autopart bestie, we're doing this by hand.

πŸ’œ User created repositories

If you're using your own repositories and installing groups (eg. @core) make sure you create the repodata with groups like this: createrepo -g /path/to/groups.xml /path/to/rpms

πŸ’œ Using a Proxy with repos

One drawback to using qemu is that it pulls the packages from the repo each and every time you run it 😭 to speed things up you either need a local mirror of the packages, or you can use a caching proxy. When using a proxy you pass it to livemedia-creator like this:

--proxy=http://proxy.yourdomain.com:3128

You also need to use a specific mirror instead of mirrormanager so that the packages will get cached, so your kickstart url would look like:

url --url="http://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/x86_64/os/"

You can also add an update repo, but don't name it updates. Add --proxy to it as well. You can use all of the kickstart commands in your kickstart. Make sure there is only one url command β€” other repos have to use the repo command and cannot be named updates, which is reserved for Anaconda's use. eg.:

url --url=PRIMARY-REPO-URL --proxy=PROXY-URL
repo --name="repo1" --baseurl=FIRST-REPO-URL --proxy=PROXY-URL
repo --name="repo2" --baseurl=SECOND-REPO_URL --proxy=PROXY-URL

πŸ¦‹ ANACONDA IMAGE INSTALL (NO-VIRT) πŸ¦‹

You can create images without using qemu by passing --no-virt on the cmdline. This will use Anaconda's directory install feature to handle the install. There are a couple of things to keep in mind when doing this, and bestie, listen up:

  1. It will be most reliable when building images for the same release that the host is running. Because Anaconda has expectations about the system it's running under, you may encounter strange bugs if you try to build newer or older releases. πŸ‘€
  2. It may totally trash your host. So far I haven't had this happen, but the possibility exists that a bug in Anaconda could result in it operating on real devices. I recommend running it in a virt or on a system that you can afford to lose all data from. πŸ’€ not me saying back up ur stuff, but like. back up ur stuff.

The logs from anaconda will be placed in an ./anaconda/ directory, in either the current directory or in the directory used for --logfile

Example cmdline:

sudo livemedia-creator --make-iso --no-virt --ks=./fedora-livemedia.ks
NOTE: Using no-virt to create a partitioned disk image (eg. --make-disk or --make-vagrant) will only create disks usable on the host platform (BIOS or UEFI). You can create BIOS partitioned disk images on UEFI by using virt. 🧚
NOTE: As of version 30.7 SELinux can be set to Enforcing. The current state is logged for debugging purposes and if there are SELinux denials they should be reported as a bug. πŸ‘‘

🌈 AMI IMAGES 🌈

Amazon EC2 images can be created by using the --make-ami switch and an appropriate kickstart file. All of the work to customize the image is handled by the kickstart. The example currently included was modified from the cloud-kickstarts version so that it would work with livemedia-creator.

Example cmdline:

sudo livemedia-creator --make-ami --iso=/path/to/boot.iso --ks=./docs/fedora-livemedia-ec2.ks

This will produce an ami-root.img file in the working directory. ✨

At this time I have not tested the image with EC2. Feedback would be welcome πŸ™ˆ (pls someone test it, i'm curious)


πŸŽ€ APPLIANCE CREATION πŸŽ€

livemedia-creator can now replace appliance-tools by using the --make-appliance switch. This will create the partitioned disk image and an XML file that can be used with virt-image to setup a virtual system. iconic tbh.

The XML is generated using the Mako template from /usr/share/lorax/appliance/libvirt.xml. You can use a different template by passing --app-template <template path>

Documentation on the Mako template system can be found at the Mako site.

The name of the final output XML is appliance.xml, this can be changed with --app-file <file path>

The following variables are passed to the template:

  • disks β€” A list of disk_info about each disk. Each entry has the following attributes:
    • name β€” base name of the disk image file
    • format β€” "raw"
    • checksum_type β€” "sha256"
    • checksum β€” sha256 checksum of the disk image
  • name β€” Name of appliance, from --app-name argument
  • arch β€” Architecture
  • memory β€” Memory in KB (from --ram)
  • vcpus β€” from --vcpus
  • networks β€” list of networks from the kickstart or []
  • project β€” from --project
  • releasever β€” from --releasever

The created image can be imported into libvirt using:

virt-image appliance.xml

You can also create qcow2 appliance images using --image-type=qcow2, for example:

sudo livemedia-creator --make-appliance --iso=/path/to/boot.iso --ks=./docs/fedora-minimal.ks \
--image-type=qcow2 --app-file=minimal-test.xml --image-name=minimal-test.img

πŸ’– FILESYSTEM IMAGE CREATION πŸ’–

livemedia-creator can be used to create un-partitined filesystem images using the --make-fsimage option. As of version 21.8 this works with both qemu and no-virt modes of operation. Previously it was only available with no-virt. glow up ✨

Kickstarts should have a single / partition with no extra mountpoints:

livemedia-creator --make-fsimage --iso=/path/to/boot.iso --ks=./docs/fedora-minimal.ks

You can name the output image with --image-name and set a label on the filesystem with --fs-label


πŸ“ TAR FILE CREATION πŸ“

The --make-tar command can be used to create a tar of the root filesystem. By default it is compressed using xz, but this can be changed using the --compression and --compress-arg options. This option works with both virt and no-virt install methods. 🫢

As with --make-fsimage the kickstart should be limited to a single / partition.

For example:

livemedia-creator --make-tar --iso=/path/to/boot.iso --ks=./docs/fedora-minimal.ks \
--image-name=fedora-root.tar.xz

⭐ LIVE IMAGE FOR PXE BOOT ⭐

The --make-pxe-live command will produce a squashfs image containing a live root filesystem that can be used for pxe boot. Directory with results will contain the live image, kernel image, initrd image and template of pxe configuration for the images. it's giving complete package πŸ’…


πŸ’œ ATOMIC LIVE IMAGE FOR PXE BOOT πŸ’œ

The --make-ostree-live command will produce the same result as --make-pxe-live for installations of Atomic Host. Example kickstart for such an installation using Atomic installer iso with local repo included in the image can be found in docs/rhel-atomic-pxe-live.ks.

The PXE images can also be created with --no-virt by using the example kickstart in docs/fedora-atomic-pxe-live-novirt.ks. This also works inside the mock environment. πŸ”₯

🧱 USING MOCK AND --NO-VIRT TO CREATE IMAGES 🧱

okay so bestie, listen β€” since lorax version 22.2 you can run livemedia-creator plus anaconda version 22.15 inside a mock chroot, using --make-iso and --make-fsimage. no cap, it's a whole vibe. πŸ’…

NOTE: ✨ as of mock version 2.0 you do not need to pass --old-chroot anymore. but you will need to pass --enable-network so the mock container can download packages, bestie. don't forget it or it's giving sad empty chroot energy. 😭
Older versions of mock, between 1.3.4 and 2.0, do need --old-chroot with mock. those versions now default to using systemd-nspawn which literally cannot create the needed loop device nodes. passing --old-chroot uses the old system where /dev/loop* is set up for you. 🌸
SELinux and mock do not work well together, and I mean at all. inside mock, SELinux is reported as disabled, so the images you produce will not have the correct SELinux labels. if that matters to you (and honestly? it might), run livemedia-creator on the host, or in a VM. periodt. πŸ’€

On the host system, do these in order:

  1. yum install -y mock
  2. Add a user to the mock group to use for running mock. eg. builder
  3. Create a new /etc/mock/ config file based on the rawhide one, or modify the existing one so that the following options are setup:
config_opts['chroot_setup_cmd'] = 'install @buildsys-build anaconda-tui lorax'

# build results go into /home/builder/results/
config_opts['plugin_conf']['bind_mount_opts']['dirs'].append(('/home/builder/results','/results/'))

If you are creating images for a branched release of Fedora you should also enable the updates-testing repository so that you get the latest builds in your mock chroot. πŸ¦‹

The following steps are run as the builder user who is a member of the mock group.

  1. Make a directory for results matching the bind mount above mkdir ~/results/
  2. Copy the example kickstarts cp /usr/share/docs/lorax/*ks .
  3. Make sure tar and dracut-network are in the %packages section and that the url points to the correct repo
  4. Init the mock mock -r fedora-rawhide-x86_64 --init
  5. Copy the kickstart inside the mock mock -r fedora-rawhide-x86_64 --copyin ./fedora-minimal.ks /root/
  6. Make a minimal iso:
mock -r fedora-rawhide-x86_64 --enable-network --chroot -- livemedia-creator --no-virt \
--resultdir=/results/try-1 --logfile=/results/logs/try-1/try-1.log \
--make-iso --ks /root/fedora-minimal.ks

Results will be in ./results/try-1 and logs under /results/logs/try-1/ including anaconda logs and livemedia-creator logs. The new iso will be located at ~/results/try-1/images/boot.iso, and the ~/results/try-1/ directory tree will also contain the vmlinuz, initrd, etc. πŸŽ€


πŸ–₯️ USING MOCK AND QEMU TO CREATE IMAGES πŸ–₯️

Version 25.0 of livemedia-creator switches to using qemu for virtualization. This allows creation of all image types, and use of the KVM on the host if /dev/kvm is present in the mock environment. iconic behaviour honestly. πŸ‘‘

On the host system:

  1. yum install -y mock
  2. Add a user to the mock group to use for running mock. eg. builder
  3. Create a new /etc/mock/ config file based on the rawhide one, or modify the existing one so that the following options are setup:
config_opts['chroot_setup_cmd'] = 'install @buildsys-build lorax qemu'

# build results go into /home/builder/results/
config_opts['plugin_conf']['bind_mount_opts']['dirs'].append(('/home/builder/results','/results/'))

If you are creating images for a branched release of Fedora you should also enable the updates-testing repository so that you get the latest builds in your mock chroot. ✨

The following steps are run as the builder user who is a member of the mock group.

  1. Make a directory for results matching the bind mount above mkdir ~/results/
  2. Copy the example kickstarts cp /usr/share/docs/lorax/*ks .
  3. Make sure tar and dracut-network are in the %packages section and that the url points to the correct repo
  4. Init the mock mock -r fedora-rawhide-x86_64 --init
  5. Copy the kickstart inside the mock mock -r fedora-rawhide-x86_64 --copyin ./fedora-minimal.ks /root/
  6. Copy the Anaconda boot.iso inside the mock mock -r fedora-rawhide-x86_64 --copyin ./boot.iso /root/
  7. Make a minimal iso:
mock -r fedora-rawhide-x86_64 --enable-network --chroot -- livemedia-creator \
--resultdir=/results/try-1 --logfile=/results/logs/try-1/try-1.log \
--make-iso --ks /root/fedora-minimal.ks --iso /root/boot.iso

Results will be in ./results/try-1 and logs under /results/logs/try-1/ including anaconda logs and livemedia-creator logs. The new iso will be located at ~/results/try-1/images/boot.iso, and the ~/results/try-1/ directory tree will also contain the vmlinuz, initrd, etc. πŸ’–

This will run qemu without kvm support, which is going to be very slow. You can add mknod /dev/kvm c 10 232; to create the device node before running lmc. like, do it, your future self will thank you. πŸ™ˆ


☁️ OPENSTACK IMAGE CREATION ☁️

OpenStack supports partitioned disk images so --make-disk can be used to create images for importing into glance, OpenStack's image storage component. You need to have access to an OpenStack provider that allows image uploads, or setup your own using the instructions from the RDO Project. 🌈

The example kickstart, fedora-openstack.ks, is only slightly different than the fedora-minimal.ks one. It adds the cloud-init and cloud-utils-growpart packages. OpenStack supports setting up the image using cloud-init, and cloud-utils-growpart will grow the image to fit the instance's disk size. so helpful, honestly. 🫢

Create a qcow2 image using the kickstart like this:

sudo livemedia-creator --make-disk --iso=/path/to/boot.iso
--ks=/path/to/fedora-openstack.ks --image-type=qcow2
NOTE: on the RHEL7 version of lmc, --image-type isn't supported. You can only create a bare partitioned disk image. sad but true bestie. 😭

Import the resulting disk image into the OpenStack system, either via the web UI, or glance on the cmdline:

glance image-create --name "fedora-openstack" --is-public true --disk-format qcow2 \
--container-format bare --file ./fedora-openstack.qcow2

If qcow2 wasn't used then --disk-format should be set to raw. πŸ’…


🐳 DOCKER IMAGE CREATION 🐳

Use lmc to create a tarfile as described in the TAR File Creation section, but substitute the fedora-docker.ks example kickstart which removes the requirement for core files and the kernel. lowkey genius.

You can then import the tarfile into docker like this (as root):

cat /var/tmp/fedora-root.tar.xz | docker import - fedora-root

And then run bash inside of it:

sudo docker run -i -t fedora-root /bin/bash

slay. πŸŽ€


πŸ“¦ OPEN CONTAINER INITIATIVE IMAGE CREATION πŸ“¦

The OCI is a new specification that is still being worked on. You can read more about it at the Open Container Initiative website. You can create OCI images using the following command:

sudo livemedia-creator --make-oci --oci-config /path/to/config.json --oci-runtime /path/to/runtime.json \
--iso=/path/to/boot.iso --ks=/path/to/fedora-minimal.ks

You must provide the config.json and runtime.json files to be included in the bundle, their specifications can be found on the OCI github project. output will be in the results directory with a default name of bundle.tar.xz. πŸ”₯

This will work with --no-virt and inside a mock since it doesn't use any partitioned disk images. so chill of it honestly. 🧚


πŸš— VAGRANT IMAGE CREATION πŸš—

Vagrant images can be created using the following command:

sudo livemedia-creator --make-vagrant --vagrant-metadata /path/to/metadata.json \
--iso=/path/to/boot.iso --ks=/path/to/fedora-vagrant.ks

The image created is a vagrant-libvirt provider image and needs to have vagrant setup with libvirt before you can use it. ✨

The --vagrant-metadata file is optional, it will create a minimal one by default, and if one is passed it will make sure the disk size is setup correctly. If you pass a --vagrant-vagrantfile it will be included in the image verbatim. By default no vagrantfile is created. πŸ¦‹

There is an example Vagrant kickstart file in the docs directory that sets up the vagrant user with the default insecure SSH pubkey and a few useful utilities.

This also works with --no-virt, but will not work inside a mock due to its use of partitioned disk images and qcow2. 🫢


πŸ–€ CREATING UEFI DISK IMAGES WITH VIRT πŸ–€

Partitioned disk images can only be created for the same platform as the host system (BIOS or UEFI). You can use virt to create BIOS images on UEFI systems, and it is also possible to create UEFI images on BIOS systems using OVMF firmware and qemu. okay that's actually kind of iconic. πŸ‘‘

Install the lorax-lmc-virt package, this will install qemu and the OVMF firmware files.

Now you can run livemedia-creator with --virt-uefi to boot and install using UEFI:

sudo livemedia-creator --make-disk --virt-uefi --iso=/path/to/boot.iso \
--ks=/path/to/fedora-minimal.ks

Make sure that the kickstart you are using creates a /boot/efi partition by including this:

part /boot/efi --fstype="efi" --size=500

Or use reqpart in the kickstart and Anaconda will create the required partitions. 🌸

NOTE: the --virt-uefi method is currently only supported on the x86_64 architecture. πŸ’…

πŸ’€ DEBUGGING PROBLEMS πŸ’€

ok so sometimes an install just… gets stuck. it happens bestie, it's not you. when you're using qemu the logs go to ./virt-install.log and like, most of the time whatever went wrong is chillin' near the end of that file. lmc does try to catch common errors and it will cancel the install when they pop off, but not everything can be caught πŸ’€. so when you're making a new kickstart it's genuinely helpful to use vnc so you can watch the install happen live, and if it gets stuck without lmc noticing, you can switch to tty1 and poke at the system directly. very main character of you tbh.

if you're sus that %pre or %post sections are the problem, you can redirect the output to the terminal and examine it by logging into the VM. like this, eg.:

%pre
chvt
exec < /dev/tty3 > /dev/tty3 2>/dev/tty3
#do stuff
echo hello world
%end

and if it does get stuck, the best way to cancel is to hit the qemu pid with kill -9 β€” lmc will clock that the process died and clean up after itself ✨.

if lmc didn't handle the cleanup for some reason (rude of it), you can do this:

  1. sudo umount /tmp/lmc-XXXX to unmount the iso from its mountpoint.
  2. sudo rm -rf /tmp/lmc-XXXX
  3. sudo rm /var/tmp/lmc-disk-XXXXX to remove the disk image.
ngl, lmc uses the lmc- prefix for all of its temporary files and directories so it's way easier to find and clean up the leftovers. iykyk 🧚

the logs from the qemu run are stored in virt-install.log, logs from livemedia-creator are in livemedia.log and program.log.

you can add --image-only to skip the .iso creation entirely and just examine the resulting disk image. or you can pass --keep-image to keep it around after the iso has been created 🫢.

cleaning up aborted --no-virt installs can sometimes be accomplished by running the anaconda-cleanup script. as of Fedora 18 anaconda is multi-threaded and it can sometimes become stuck and refuse to exit 😭. when that happens you can usually clean up by first killing the anaconda process then running anaconda-cleanup.


🌈 HACKING 🌈

development on this will take place as part of the lorax project, and on the anaconda-devel-list mailing list, and on github πŸ’…

feedback, enhancements and bugs are welcome. you can use bugzilla to report bugs against the lorax component. pls do, we love hearing from you πŸŽ€


πŸ‘‘ AUTHOR πŸ‘‘

Weldr Team


2024, Red Hat, Inc.


ok that's the whole page bestie, you made it to the end πŸŽ‰ this was LIVEMEDIA-CREATOR(1), source/version 41.3, dated Aug 12, 2024 β€” go make something iconic with it, no cap πŸ’–βœ¨

πŸ“¦ where this page comes from