Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Guide + Question] Using livemedia-creator to create an ISO in Github Actions #1362

Closed
Cameronsplaze opened this issue Jan 16, 2024 · 4 comments

Comments

@Cameronsplaze
Copy link
Contributor

I think I finally have a custom Fedora ISO built from inside Github Actions! There's a couple areas I have questions on. (Fyi it takes ~40-50min)

My command to create the image so far is:

livemedia-creator --ks Fedora-custom-ks.cfg --no-virt --make-iso --iso-only --iso-name Fedora-custom-39-KDE.iso --project Fedora-custom--volid Fedora-custom-39 --releasever 39
Contents of Fedora-custom-ks.cfg so far
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --iscrypted --lock locked
# System language
lang en_US.UTF-8
# System timezone
timezone US/Eastern
# Network information
network  --bootproto=dhcp --device=link --activate
# Firewall configuration
firewall --enabled # --service=mdns
# Use network installation
url --mirrorlist="https://mirrors.fedoraproject.org/mirrorlist?repo=fedora-$releasever&arch=$basearch"

## System services (UNCOMMENT for example of error)
# services --disabled="sshd,custom-device-pollrates" --enabled="NetworkManager,ModemManager,supergfxd,akmods"

# System bootloader configuration
bootloader --location=none

# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all
# Disk partitioning information
# autopart
part / --size=6144 --fstype="ext4" --grow --asprimary --recommended
part swap --recommended # Is this line not needed for --iso-only?

# Shutdown after installation
shutdown

# Packages to be installed
%packages
# Required for livemedia-creator:
dracut-live
@^kde-desktop-environment
# Everything else:
@virtualization
@anaconda-tools
%end

# pre-installation commands
%pre --erroronfail
# Add pre-installation commands here
%end

# Post-installation commands
%post --erroronfail
# Add post-installation commands here
%end
A working GH action, in case anyone is looking to do the same
name: Build Fedora ISO

on:
  workflow_dispatch: {}

jobs:

  fedora-build:
    runs-on: ubuntu-latest
    container:
      image: fedora:latest
      # --privileged needed for livemedia-creator
      options: --privileged
    steps:
      - uses: actions/checkout@v4

      - name: Install dependencies
        run: |
          # zstd: Lets you use github caching actions inside fedora too
          # lorax lorax-lmc-novirt anaconda pykickstart: To actually build the ISO
          dnf install -y zstd lorax lorax-lmc-novirt anaconda pykickstart

      ## Create the ISO
      - name: Create the custom ISO
        run: |
          cd ./OS-Builder
          livemedia-creator \
            --ks CustomFedora-ks.cfg \
            --no-virt \
            --make-iso \
            --iso-only \
            --iso-name CustomFedora-39-KDE.iso \
            --project CustomFedora \
            --volid CustomFedora-39 \
            --releasever 39 \
            --resultdir ./Results

      - name: Upload ISO
        uses: actions/upload-artifact@v3
        with:
          name: CustomFedora-39-KDE.iso
          path: ./OS-Builder/Results/CustomFedora-39-KDE.iso

      ## Capture debug info if it fails, and logs exist:
      - name: "DEBUG: Print virt-install log"
        if: failure() && hashFiles('./OS-Builder/virt-install.log') != ''
        run: cat ./OS-Builder/virt-install.log

      - name: "DEBUG: Print livemedia log"
        if: failure() && hashFiles('./OS-Builder/livemedia.log') != ''
        run: cat ./OS-Builder/livemedia.log

My main goal is to have a custom ISO with extra packages installed, and (eventually) a custom Desktop Environment added to the iso. I still want users to "install" the iso to their system with setting up partitions themselves, along with the root and user accounts, etc.


It seems like with livemedia-creator --make-iso --iso-only --no-virt ..., the part / argument is still required. I can't use autopart either to just ignore it. I want this part to be exactly like the Fedora install setup, where users customize it themselves. Maybe I don't understand what this param does? Or is livemedia-creator not the right tool for what I'm trying to do?

  • If part / is setting up the partitions to use after the install, I want this to be completely on the user. Like fedora currently, where you have to select what drives to wipe, then click a button to add a sensible /boot, /, swap, etc. But you still can override and customize that area. Does this just declare what "sensible" is maybe? With --iso-only, I'm hoping users can still customize the install process.
  • If this argument is just how to configure the VM when creating it with QEMU, I have --no-virt passed, so it should be doing everything inside the container. No vm needed?
  • If it's the size of the ISO, is there a way to make it minimal? I had a size error with --size=1 --grow. Can I just have a placeholder one like above, and ignore this key otherwise?

Also I've noticed the longest step is easily when it says Creating a squashfs+ext4 runtime towards the end of the output to the console. Is there anything I could potentially do to speed this up? I'm going to look at adding caching to the dnf install step too, is there another directory I could try to cache too maybe?

@bcl
Copy link
Contributor

bcl commented Jan 16, 2024

The part / is needed because it has to make a disk image to install everything onto. It only effects the iso / filesystem not the final install, that's all handled by anaconda being run after booting the iso. The size of / doesn't actually matter too much, it gets compressed so making it large has a minimal size penalty on the final image. To make things a bit smaller you can use the new --squashfs-only argument and it skips the ext4 wrapped in squashfs step and just makes a squashfs filesystem. It should be slightly faster than the squashfs+ext4 method.

@Cameronsplaze
Copy link
Contributor Author

Thanks! I simplified the part / section, and the --squashfs-only flag saved ~5 minutes too.

Would you like a PR to add an example livemedia-creator GH action to this repo? I could try pointing it at https://github.com/weldr/lorax/blob/master/docs/fedora-minimized.ks since it's already there, and it uses url= so --no-virt should work. With the trigger as a workflow_dispatch, the action will only run when you want it to. I also added a ksvalidator step to help it error faster if something's wrong.

@bcl
Copy link
Contributor

bcl commented Jan 17, 2024

Thanks! I simplified the part / section, and the --squashfs-only flag saved ~5 minutes too.

Nice!

Would you like a PR to add an example livemedia-creator GH action to this repo?

Sure, PR's always welcome!

@Cameronsplaze
Copy link
Contributor Author

Thank you for waiting, just got back from a little vacation. I'm working on the PR in #1374. I think you can only link the issue if you're a maintainer? But feel free to close this issue too, I'm just not sure how you like to organize this project.

@bcl bcl closed this as completed Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants