weldr / lorax

Tools for creating images, including the Anaconda boot.iso, live disk images, iso's, and filesystem images.
GNU General Public License v2.0
295 stars 158 forks source link

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

Closed Cameronsplaze closed 9 months ago

Cameronsplaze commented 10 months ago

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 ```cfg # 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 ```yaml 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?


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 commented 10 months ago

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 commented 10 months ago

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 commented 10 months ago

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 commented 9 months ago

Thank you for waiting, just got back from a little vacation. I'm working on the PR in https://github.com/weldr/lorax/pull/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.