Build Fedora ISO in 3 Commands
Why? In a word, you may be not satisfied by official build.
Many packages in the official build were outdated, even suffered by CVEs. Run
dnf updatein a newly installed environment will need to download a lot.
Remove rarely used packages to reduce iso size. Add packages, change theme, tweak some settings.
Enable more optimization to speed up livecd booting and install progress.
And there's a prebuilt custom fedora 37 x86_64 iso.
As the title, we only needs 3 commands:
# sudo -i # or add sudo before every command # setenforce 0 # if you get any errors like memory permission # 1. clone this repo git clone --depth=1 https://github.com/kkocdko/utils4fedora # 2. build the docker image docker build -t makeimage utils4fedora/makeimage # 3. build your custom fedora iso! docker run --network=host --privileged -v $(pwd):$(pwd) --name mkimg0 makeimage \ $(pwd)/utils4fedora/makeimage/custom.ks $(pwd)/result \ --make-iso --iso-only --compression zstd --compress-arg=-b --compress-arg=1M --compress-arg=-Xcompression-level --compress-arg=22
Then, see what's produced,
ls -lh ./result/*. It takes 4 minutes on my machine with local mirror (make download time zero) and 15 minutes on GitHub Actions.
Using docker, easy to build and avoid most of troubles caused by environment.
Like other distros, Fedora Linux is built on top of many prebuilt packages. You can still mount a raw img file and copy files into it manually, but Fedora usually uses lorax to build the image.
Lorax builds image / tarball from kickstart file, and Fedora's offical build (including spins) uses the kickstart files in https://pagure.io/fedora-kickstarts .
In this project (my utils4fedora), I include these in docker image. So now you only need to write a kickstart file.
# comments %include fedora-live-workstation.ks # based on offical workstation edition part / --size=8192 # set image root size %packages # modify packages -firefox # exclude a package htop # include a package %end # end this session %post # run in the image's chroot systemctl disable dnf-makecache %end
If you want an origin workstation edition, remove all lines expect of
%include fedora-live-workstation.ks. And kickstart file has a reference here.
After that, let's see the command line switches:
# we only want iso file --make-iso --iso-only # use zstd compression and tweak args, result in smaller size and faster decompression --compression zstd --compress-arg=-b --compress-arg=1M --compress-arg=-Xcompression-level --compress-arg=22
Every time building the image will take about 1.7 GiB of data traffic, so running a local mirror may be a good idea if you want to build multi times. I recommend a HTTP proxy caching instead of a traditional mirror which used huge disk space. Try squid or my server program. See how fast it is:
2023-01-10 07:33:55,507: Starting package installation process 2023-01-10 07:33:56,507: Downloading packages 2023-01-10 07:33:58,508: Downloading 1132 RPMs, 52.95 MiB / 1001.38 MiB (5%) done. 2023-01-10 07:34:00,509: Downloading 1132 RPMs, 959.15 MiB / 1001.38 MiB (95%) done. 2023-01-10 07:34:01,511: Preparing transaction from installation source
If you search "build fedora install iso" with Google, the first result is this one in Fedora wiki, but it's outdated now (20230110). As a result, I wasted a lot of time.
Then I found the osbuild, a "modern" way, but has many limitations. It may be suitable for some company's IT managers.
Finally, I found the right path. Ultramarine-Linux/build-scripts, a distro based on Fedora. Their repo shows the right way to build a custom Fedora image.
To be continue...