Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/build-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ on:
description: 'Distribution'
default: 'ubuntu2604'
type: choice
options: [all, ubuntu2604, arch, cachyos, fedora, proxmox, debian, debian13, bazzite, bazzite-deck, steamos]
workflow_call:
options: [all, ubuntu2604, arch, cachyos, omarchy, fedora, proxmox, debian, debian13, bazzite, bazzite-deck, steamos]
ow_call:
inputs:
distro:
type: string
Expand All @@ -34,7 +34,7 @@ jobs:
run: |
INPUT="${{ inputs.distro || 'ubuntu2604' }}"
if [ "$INPUT" = "all" ]; then
echo 'distros=["ubuntu2604","arch","cachyos","fedora","proxmox","debian","debian13","bazzite","bazzite-deck","steamos"]' >> "$GITHUB_OUTPUT"
echo 'distros=["ubuntu2604","arch","cachyos","omarchy","fedora","proxmox","debian","debian13","bazzite","bazzite-deck","steamos"]' >> "$GITHUB_OUTPUT"
else
echo "distros=[\"$INPUT\"]" >> "$GITHUB_OUTPUT"
fi
Expand Down Expand Up @@ -190,6 +190,7 @@ jobs:
{ key: 'ubuntu2604', label: 'Ubuntu 26.04', file: 'ps5-ubuntu2604.img.xz' },
{ key: 'arch', label: 'Arch', file: 'ps5-arch.img.xz' },
{ key: 'cachyos', label: 'CachyOS', file: 'ps5-cachyos.img.xz' },
{ key: 'omarchy', label: 'Omarchy', file: 'ps5-omarchy.img.xz' },
{ key: 'fedora', label: 'Fedora 44', file: 'ps5-fedora.img.xz' },
{ key: 'proxmox', label: 'Proxmox VE 8', file: 'ps5-proxmox.img.xz' },
{ key: 'debian', label: 'Debian 12', file: 'ps5-debian.img.xz' },
Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# PS5 Linux Image Builder

Builds bootable Linux USB images for PlayStation 5 using Docker containers. Supports Ubuntu 26.04, Arch, CachyOS (Gamescope + Steam), Fedora (GNOME), individually or as a multi-distro image with kexec switching.
Builds bootable Linux USB images for PlayStation 5 using Docker containers. Supports Ubuntu 26.04, Arch, CachyOS (Gamescope + Steam), Omarchy (Arch + Hyprland), Fedora (GNOME), individually or as a multi-distro image with kexec switching.

## Prerequisites

Expand All @@ -27,6 +27,9 @@ OR

OR

# Build Omarchy (Arch-based, Hyprland desktop)
./build_image.sh --distro omarchy

OR

# Build Fedora (GNOME desktop)
Expand All @@ -50,7 +53,7 @@ sudo dd if=output/ps5-ubuntu2604.img of=/dev/sdX bs=4M status=progress

| Flag | Description | Default |
|------|-------------|---------|
| `--distro` | `ubuntu2604`, `arch`, `cachyos`, `fedora`, or `all` | `ubuntu2604` |
| `--distro` | `ubuntu2604`, `arch`, `cachyos`, `omarchy`, `fedora`, or `all` | `ubuntu2604` |
| `--kernel` | Path to kernel source directory | auto-clone version selected by PS5 patch set |
| `--img-size` | Disk image size in MB | `12000` (`32000` for `all`) |
| `--clean` | Remove all cached build artifacts and start fresh | off |
Expand Down Expand Up @@ -98,6 +101,7 @@ All verbose output goes to `build.log`. The terminal shows a spinner with live p
| Ubuntu 26.04 (Resolute) | GNOME | `.deb` | systemd |
| Arch | Sway | `.pkg.tar.zst` | systemd |
| CachyOS | Gamescope + Steam Big Picture (Arch + `[cachyos]` repo, no v3 migration in image build) | `.pkg.tar.zst` | systemd |
| Omarchy | Hyprland (Arch + the Omarchy packages from `pkgs.omarchy.org`, see `distros/omarchy/README.md`) | `.pkg.tar.zst` | systemd |

## Multi-distro Image

Expand Down Expand Up @@ -153,6 +157,7 @@ distros/
ubuntu2604/ # Ubuntu 26.04 (Resolute)
arch/ # Arch Linux
cachyos/ # CachyOS repos + Gamescope/Steam
omarchy/ # Omarchy (Arch + Hyprland) packages + setup
shared/ # Kernel postinst hooks (single + multi)
boot/
cmdline.txt # Kernel cmdline template (__DISTRO__ placeholder)
Expand Down
4 changes: 2 additions & 2 deletions build_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ usage() {
echo "Usage: $0 [--distro <distro>] [--kernel <path>] [--img-size <MB>] [--boot-part-size <MB>] [--clean]"
echo ""
echo "Options:"
echo " --distro Distribution to build: ubuntu2604, arch, cachyos, fedora, proxmox, debian, bazzite, bazzite-deck, batocera, all (default: ubuntu2604)"
echo " --distro Distribution to build: ubuntu2604, arch, cachyos, omarchy, fedora, proxmox, debian, debian13, bazzite, bazzite-deck, steamos"
echo " --kernel Path to kernel source directory (default: auto-clone to work/linux/)"
echo " --img-size Disk image size in MB (default: 12000, 32000 for --distro all)"
echo " --boot-part-size Boot partition size in MB (default: 500)"
Expand Down Expand Up @@ -88,7 +88,7 @@ esac

if [ -z "$FORMAT" ]; then
case "$DISTRO" in
arch|cachyos|steamos) FORMAT="arch" ;;
arch|cachyos|omarchy|steamos) FORMAT="arch" ;;
fedora|bazzite*) FORMAT="rpm" ;;
all) FORMAT="all" ;;
*) FORMAT="deb" ;;
Expand Down
61 changes: 61 additions & 0 deletions distros/omarchy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# omarchy

[Omarchy](https://omarchy.org) — DHH's opinionated Arch + Hyprland desktop — on
PS5 hardware with our `linux-ps5` kernel.

## How it is built

Omarchy's installer is an ISO wizard (`archinstall` plus the target-side
`omarchy apply system` step), but the desktop itself ships as ordinary Arch
packages in Omarchy's own repo (`omarchy`, `omarchy-settings`,
`omarchy-keyring`, themes, nvim config, titlebars). Omarchy's own docs describe
prebuilt images as a supported shape: the builder installs the packages and
their setup, and hardware leaves run on the machine's first boot
(`docs/file-layout.md`, `agents/skills/install-scripts.md`).

So this distro is not a hand-assembled copy of the package lists:

1. `distros/omarchy/build-rootfs.sh` fetches `omarchy.db` plus the six
runtime/support packages from `https://pkgs.omarchy.org/stable/x86_64` into
the build cache (`stage-pkgs.sh`), then runs distrobuilder on
`distros/omarchy/image.yaml`.
2. `image.yaml` installs a small Arch base — GPU, session plumbing, network,
plus `gum`/`perl`/`sddm` for `omarchy-settings` — drops in `linux-ps5`, and
rebuilds the initramfs without `autodetect`.
3. Its post-files action installs the staged Omarchy packages
(`pacman -U --nodeps`, the chroot has no DNS), uses Omarchy's pacman
configuration (its repo first, then Arch off Omarchy's stable mirror, as
`omarchy apply pacman` would), and runs
`distros/omarchy/post-install.sh`: Omarchy's `config/` and `login/` setup
leaves (locale, firewall, services, docker, passwordless keyring) and
`omarchy-finalize-user` for `ps5`.
4. Login is tty1 autologin as `ps5` → `exec Hyprland`, no SDDM, matching the
Arch / CachyOS / SteamOS images.

Omarchy's `hardware/` leaves are **not** run at build time: they are the
per-machine steps (vulkan vendor, bluetooth, wifi regdom, platform fixes), and
several of them build DKMS modules against the image kernel, which is
`linux-ps5`, not `linux-omarchy`.

## Build locally

```bash
./build_image.sh --distro omarchy
```

The `.img.xz` lands in `output/ps5-omarchy.img.xz`. `OMARCHY_CHANNEL`
(`stable`, `rc`, `edge`) selects the repo channel; it defaults to `stable`.

## Caveats

- The image ships the Omarchy *packages*. Anything the ISO wizard does outside
them — partition layout, LUKS, `limine`/`snapper` boot and snapshot setup —
is replaced by this repo's kexec boot flow and ext4 layout, as for every
other PS5 image.
- Some Omarchy packages pull things that only make sense in Omarchy's own
installer (e.g. `omarchy-settings` on `plymouth`); the Omarchy packages are
installed with `--nodeps` so this does not fail the build, and the image
boots with this repo's own `linux-ps5` + kexec flow rather than upstream's.
If the transaction fails on the real image, it is the first place to look.
- Default credentials are `ps5` / `ps5` with passwordless sudo, same as the
other images. Change them before exposing the machine to a network.
61 changes: 61 additions & 0 deletions distros/omarchy/build-rootfs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/bin/bash
# distros/omarchy/build-rootfs.sh — Arch rootfs + the real Omarchy packages.
# Called from docker/image-builder/entrypoint.sh for DISTRO=omarchy.
#
# Omarchy's installer is an ISO wizard, but the Omarchy packages are normal Arch
# packages in Omarchy's own repo, and Omarchy's docs cover image builds: a
# prebuilt image carries the packages and defers hardware setup to first boot
# (docs/file-layout.md). The distrobuilder recipe (image.yaml) installs the Arch
# side, pulls the Omarchy packages from here and then runs
# distros/omarchy/post-install.sh — the same system setup Omarchy's installer
# runs in the target chroot.
#
# Expects in env: DISTRO=omarchy, CHROOT, KVER, ROOT_LABEL, EFI_LABEL
# Expects on disk: /kernel-debs/linux-ps5-*.pkg.tar.zst,
# /repo/distros/omarchy/{grow-rootfs,grow-rootfs.service},
# /repo/distros/shared/zz-update-boot
set -eux
: "${CHROOT:?ERROR: \$CHROOT unset/empty}"
[ -d "$CHROOT" ] || { echo "ERROR: \$CHROOT=$CHROOT not a directory"; exit 2; }
case "$CHROOT" in /) echo "ERROR: refuse to operate on /"; exit 2 ;; esac

STAGING=/tmp/build-staging
OMARCHY_CHANNEL="${OMARCHY_CHANNEL:-stable}"
OMARCHY_REPO_URL="${OMARCHY_REPO_URL:-https://pkgs.omarchy.org/$OMARCHY_CHANNEL/x86_64}"
OMARCHY_MIRROR_URL="${OMARCHY_MIRROR_URL:-https://$OMARCHY_CHANNEL-mirror.omarchy.org}"

# --- Stage files distrobuilder's copy generators need ------------------------
rm -rf "$STAGING"
mkdir -p "$STAGING/pkgs"
cp /repo/distros/omarchy/grow-rootfs "$STAGING/"
cp /repo/distros/omarchy/grow-rootfs.service "$STAGING/"
cp /repo/distros/shared/zz-update-boot "$STAGING/"
cp /kernel-debs/*.pkg.tar.zst "$STAGING/pkgs/"
cat > "$STAGING/fstab" <<EOF
# /etc/fstab: static file system information.
#
# <file system> <mount point> <type> <options> <dump> <pass>
LABEL=$ROOT_LABEL / ext4 defaults 0 1
LABEL=$EFI_LABEL /boot/efi vfat defaults 0 1
EOF
find "$STAGING" -type f ! -path "$STAGING/pkgs/*" -exec sed -i 's/\r$//' {} +

if [ "${SKIP_CHROOT:-false}" = "true" ] && [ -d "$CHROOT/usr/share/omarchy" ]; then
echo "=== Reusing cached $DISTRO rootfs ==="
exit 0
fi

# --- Omarchy packages, fetched once and reused across rebuilds ---------------
echo "=== Fetching Omarchy $OMARCHY_CHANNEL packages ==="
OMARCHY_CHANNEL="$OMARCHY_CHANNEL" \
OMARCHY_REPO_URL="$OMARCHY_REPO_URL" \
OMARCHY_MIRROR_URL="$OMARCHY_MIRROR_URL" \
bash /repo/distros/omarchy/stage-pkgs.sh /build/cache/omarchy >&2

rm -rf "$CHROOT"/* "$CHROOT"/.[!.]* 2>/dev/null || true
mkdir -p "$CHROOT"
cp -a /build/cache/omarchy/omarchy-pkgs "$CHROOT/omarchy-pkgs"
cp -a /build/cache/omarchy/omarchy-db "$CHROOT/omarchy-db"
distrobuilder build-dir /repo/distros/omarchy/image.yaml "$CHROOT" \
--with-post-files --cache-dir /build/cache --cleanup=false >&2
rm -rf "$CHROOT/omarchy-pkgs" "$CHROOT/omarchy-db"
1 change: 1 addition & 0 deletions distros/omarchy/cmdline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
root=LABEL=__DISTRO__ rw rootwait console=ttyTitania0 console=tty0 mitigations=off idle=halt preempt=full
91 changes: 91 additions & 0 deletions distros/omarchy/grow-rootfs
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#!/bin/bash
# Grows the root partition + filesystem to fill the disk on first boot.
# Self-disables after success.
#
# Uses sfdisk + partx + resize2fs (all in util-linux + e2fsprogs, both
# present in the minimal Arch/SteamOS base). Earlier versions called
# growpart from cloud-utils — but that package isn't in the SteamOS
# recovery image, so the unit failed with "growpart: command not found"
# and rootfs stayed at the dd'd image size (~14 GB) on any disk larger
# than that.
set -e

ROOT_DEV=$(findmnt -no SOURCE /)
DISK="/dev/$(lsblk -ndo PKNAME "$ROOT_DEV")"

# PS5 M.2 drive appear as /dev/nvme*. Do not modify partition table,
# because it contains m2_init PS5 offset. Only USB drive (/dev/sd*)
# are safe for automatic grow root partition.
if [[ "$(basename "$DISK")" == nvme* ]]; then
echo "grow-rootfs: M.2 detected, skipping"
systemctl disable grow-rootfs.service
exit 0
fi

PART_NUM=$(cat /sys/class/block/$(basename "$ROOT_DEV")/partition)

# Our images dd at their built size (~14 GB) onto a much larger USB. The GPT
# backup header is therefore at byte ~built-size, not at end of disk. Move
# the backup header to end-of-disk first so partition table growth works.
sgdisk -e "$DISK"

# If a previous flash left behind partitions BEYOND our rootfs + boot pair
# (e.g. a stale `linux-home` partset at part 3 from a prior SteamOS install
# on the same drive), the partition extend refuses to grow into the space
# already claimed by the leftover partition. Delete every partition with a
# number higher than 2 — we only ever create partitions 1 (rootfs) + 2 (boot).
# Important: sgdisk only rewrites the on-disk GPT; we must ALSO drop those
# stale entries from the kernel's in-memory partition table via partx -d,
# or BLKPG_RESIZE_PARTITION below returns EBUSY because the kernel still
# thinks sda1 would have to grow into space owned by phantom sda3.
for n in $(parted -ms "$DISK" print 2>/dev/null \
| awk -F: 'NR>2 && $1+0>2 {print $1}'); do
sgdisk -d "$n" "$DISK" 2>/dev/null || true
partx -d --nr "$n" "$DISK" 2>/dev/null || true
done

# sfdisk `,+` extends partition $PART_NUM to consume all available free
# space. Works on a mounted/live partition because sfdisk only rewrites
# the GPT entry (kernel re-read of the partition table comes next).
echo ",+" | sfdisk --no-reread -N "$PART_NUM" "$DISK"

# Make the kernel pick up the new partition size without unmounting via
# BLKPG_RESIZE_PARTITION. partx -u also uses BLKPG, but on some images
# (notably SteamOS recovery loop-mounted btrfs) partx returns an error
# updating the mounted partition; the direct ioctl is more reliable.
python3 - "$DISK" "$PART_NUM" <<'PY'
import sys, os, fcntl, ctypes, subprocess
disk, pno = sys.argv[1], int(sys.argv[2])
out = subprocess.run(["sfdisk","--bytes","-q","-l",disk],
capture_output=True, text=True, check=True).stdout
start = sectors = None
for line in out.splitlines():
if line.startswith(f"{disk}{pno} ") or line.startswith(f"{disk}p{pno} "):
f = line.split()
start, sectors = int(f[1]), int(f[3])
break
if start is None:
sys.exit(f"could not parse partition {pno} from sfdisk -l {disk}")
class P(ctypes.Structure):
_fields_=[("start",ctypes.c_longlong),("length",ctypes.c_longlong),
("pno",ctypes.c_int),("devname",ctypes.c_char*64),
("volname",ctypes.c_char*64)]
class A(ctypes.Structure):
_fields_=[("op",ctypes.c_int),("flags",ctypes.c_int),
("datalen",ctypes.c_int),("data",ctypes.c_void_p)]
p = P(start=start*512, length=sectors*512, pno=pno)
a = A(op=3, flags=0, datalen=ctypes.sizeof(p), data=ctypes.addressof(p))
fd = os.open(disk, os.O_RDONLY)
try:
fcntl.ioctl(fd, 0x1269, a) # BLKPG, BLKPG_RESIZE_PARTITION
finally:
os.close(fd)
PY

# Belt-and-suspenders: also try partx in case BLKPG via python failed.
partx -u --nr "$PART_NUM" "$DISK" 2>/dev/null || true

# Online ext4 grow.
resize2fs "$ROOT_DEV"

systemctl disable grow-rootfs.service
13 changes: 13 additions & 0 deletions distros/omarchy/grow-rootfs.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Unit]
Description=Grow root filesystem to fill disk
DefaultDependencies=no
Before=local-fs.target
After=local-fs-pre.target

[Service]
Type=oneshot
ExecStart=/usr/local/sbin/grow-rootfs
RemainAfterExit=yes

[Install]
WantedBy=local-fs.target
Loading