Skip to content

Instantly share code, notes, and snippets.

@gridhead
Last active August 25, 2023 05:26
Show Gist options
  • Save gridhead/5f8eb15d4f995151229539d85f009a7c to your computer and use it in GitHub Desktop.
Save gridhead/5f8eb15d4f995151229539d85f009a7c to your computer and use it in GitHub Desktop.
Messing Around With Building Images
# Download the file to a local directory
# Rename the file to `mkosi.conf`
# Run `sudo mkosi build` in that directory
# mkosi 15.1 on fedora rawhide (i.e. 40) works the best
[Distribution]
Distribution=centos
Release=9
Architecture=x86-64
Bootable=yes
[Output]
Format=disk
Output=centgrid
# CompressOutput=xz
ImageVersion=0.1.1
[Content]
Packages=kernel
systemd
systemd-boot
udev
dnf
NetworkManager
iproute
ncurses
basesystem
sudo
Bootable=yes
Locale=en_US.UTF-8
Timezone=Asia/Kolkata
Hostname=centgrid
RootPassword=centgrid
RootShell=/usr/bin/bash
Autologin=yes
[Validation]
Checksum=yes
# Download the file to a local directory
# Rename the file to `mkosi.conf`
# Run `sudo mkosi build` in that directory
# mkosi 15.1 on fedora rawhide (i.e. 40) works the best
[Distribution]
Distribution=fedora
Release=40
Architecture=x86-64
Bootable=yes
[Output]
Format=disk
Output=fedogrid
CompressOutput=yes
ImageVersion=0.1.1
[Content]
Packages=kernel
systemd
systemd-boot
udev
util-linux
NetworkManager
iproute
ncurses
basesystem
sudo
Bootable=yes
Locale=en_US.UTF-8
Timezone=Asia/Kolkata
Hostname=fedogrid
RootPassword=fedogrid
RootShell=/usr/bin/bash
Autologin=yes
[Validation]
Checksum=yes

Make Arch Linux images on Fedora Rawhide using Systemd Mkosi

Step 1

Install mkosi and arch-install-scripts on your Fedora Rawhide installation.

$ sudo dnf install mkosi arch-install-scripts

Step 2

Initialize the client GPG key for the pacman package manager and populate the official repositories for archlinuxarm.

$ sudo pacman-key --init
$ sudo pacman-key --populate archlinux

Step 3

Create a directory for building the Arch Linux OS image and make it the present working directory.

$ mkdir archgrid
$ cd archgrid

Step 4

Configure the OS image specification using the text editor of your choice.

$ nano mkosi.conf
[Distribution]
Distribution=arch
Architecture=x86-64
Bootable=yes

[Output]
Format=disk
Output=archgrid
# CompressOutput=xz
ImageVersion=0.1.0

[Content]
Packages=linux
         systemd
Bootable=yes
Locale=en_US.UTF-8
Timezone=Asia/Kolkata
Hostname=archgrid
RootPassword=archgrid
RootShell=/usr/bin/bash
Autologin=yes

[Validation]
Checksum=yes

Step 5

Start building the operating system image by executing the following command.

$ sudo mkosi build

Building OS images for multiple architecures

Step 1

sudo dnf install qemu --setopt=install_weak_deps=False

Step 2

sudo dnf install qemu-user-static --setopt=install_weak_deps=False

Step 3

nano mkosi.conf
[Distribution]
Distribution=fedora
Release=40
Architecture=arm64
# Bootable=yes

[Output]
Format=disk
Output=fedogrid
# CompressOutput=yes
ImageVersion=0.1.2

[Content]
Packages=kernel
         systemd
         systemd-boot
         udev
         util-linux
         ncurses
         basesystem
         sudo
         dnf
# Bootable=yes
Locale=en_US.UTF-8
Timezone=Asia/Kolkata
Hostname=fedogrid
RootPassword=fedogrid
RootShell=/usr/bin/bash
Autologin=yes

[Validation]
Checksum=yes

Step 4

sudo mkosi build

Step 5

Copy over the image to a Raspberry Pi device running aarch64-based operating system and set up symbolic link

In the Raspberry Pi device

ln -sf fedogrid_0.1.2.raw fedogrid

Step 6

In the Raspberry Pi device

sudo machinectl import-raw fedogrid

Step 7

In the Raspberry Pi device

sudo machinectl start fedogrid

Step 8

In the Raspberry Pi device

sudo machinectl shell fedogrid
# Download the file to a local directory
# Rename the file to `mkosi.conf`
# Run `sudo mkosi build` in that directory
# Ensure that `zypper` is installed
# mkosi 15.1 on fedora rawhide (i.e. 40) works the best
[Distribution]
Distribution=opensuse
Release=tumbleweed
Architecture=x86-64
Bootable=yes
[Output]
Format=disk
Output=susegrid
# CompressOutput=xz
ImageVersion=0.1.1
[Content]
Packages=kernel-default
systemd
systemd-boot
udev
Bootable=yes
Locale=en_US.UTF-8
Timezone=Asia/Kolkata
Hostname=susegrid
RootPassword=susegrid
RootShell=/usr/bin/bash
Autologin=yes
[Validation]
Checksum=yes
1. Download the fedora-minimal kickstart file
```
wget https://github.com/weldr/lorax/raw/master/docs/fedora-minimal.ks
```
2. Disable the SELinux first
```
setenforce 0
```
3. Create an Anaconda boot ISO
```
sudo \
lorax \
--product Fedora \
--version 38 \
--release 38 \
--source http://dl.fedoraproject.org/pub/fedora/linux/releases/38/Everything/x86_64/os/ \
rslt/
```
4. Make the resulting directory as the present working directory of the livemedia generation.
```
cd rslt/
```
5. Create a live media from the generated ISO with logs being displayed on 0 port offset from the default VNC port (i.e. 5900)
```
sudo \
livemedia-creator \
--make-iso \
--iso=/path/to/the/generated/anaconda/boot/ISO/in/previous/step \
--ks=fedora-minimal.ks
sudo \
livemedia-creator \
--make-iso \
--iso=rslt/images/boot.iso \
--ks=fedora-minimal.ks \
--vnc=vnc=0.0.0.0:0 \
--virt-uefi
```
6. Re-enable the SELinux after completion
```
setenforce 1
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment