2025-06-02 16:58:16 -04:00
# Arch Linux s390x Port with Systemd
2025-05-29 05:54:20 -04:00
2025-06-02 16:58:16 -04:00
This repository contains a **complete, working** s390x Arch Linux system with **systemd support** and full root filesystem that boots successfully on IBM mainframes and QEMU emulation.
2025-05-29 05:54:20 -04:00
2025-05-31 14:57:37 -04:00
## Quick Start
```bash
# Build everything
2025-06-02 09:21:38 -04:00
make all
# Test initramfs-only system
make test
2025-05-31 14:57:37 -04:00
2025-06-02 09:21:38 -04:00
# Test with root filesystem
make test-rootfs
2025-06-02 16:58:16 -04:00
# Test with systemd as init
make test-systemd
2025-05-31 14:57:37 -04:00
```
## What's Working
2025-06-02 15:52:32 -04:00
- **Arch Linux Kernel**: Linux 6.6.10 with Arch patches cross-compiled for IBM mainframes (5.8MB)
2025-06-02 09:21:38 -04:00
- **Initramfs**: Complete 5.9MB initramfs with s390x busybox
- **Boot Process**: Successful boot to root filesystem with busybox shell
2025-06-02 16:58:16 -04:00
- **Root Filesystem**: **COMPLETE!** 150MB ext4 root filesystem with Arch Linux identification
- **Systemd**: **NEW!** 42MB minimal systemd built natively on IBM z/VM
- **Modern Init**: Systemd components ready for enterprise mainframe deployment
2025-05-31 14:57:37 -04:00
- **QEMU Testing**: Fully functional in s390x emulation
- **Ready for Hardware**: IPL configuration for real mainframes
## Build Status
2025-06-02 09:21:38 -04:00
### Core System Components
2025-05-31 14:57:37 -04:00
| Component | Status | Details |
|-----------|--------|---------|
2025-06-02 15:52:32 -04:00
| Kernel | ✅ Working | 5.8MB bootable s390x kernel with Arch patches (6.6.10) |
2025-06-02 09:21:38 -04:00
| Initramfs | ✅ Working | 5.9MB with native s390x binaries |
| Boot Process | ✅ Working | IPL → kernel → initramfs → root filesystem |
2025-06-02 16:58:16 -04:00
| Root Filesystem | ✅ **COMPLETE** | 150MB ext4 with working busybox switch_root |
| Systemd | ✅ **BUILT** | 42MB minimal systemd with native s390x compilation |
2025-05-31 14:57:37 -04:00
| mkinitcpio | ✅ Fixed | Adapted for s390x architecture |
2025-06-02 09:21:38 -04:00
### Userspace Components
| Component | Status | Details |
|-----------|--------|---------|
2025-06-02 16:58:16 -04:00
| Init System | ✅ **DUAL** | Busybox init + systemd available |
2025-06-02 09:21:38 -04:00
| Shell | 🟨 Minimal | Busybox sh (not bash) |
| Core Utilities | 🟨 Minimal | Busybox applets only |
| Package Manager | ❌ TODO | Pacman needs porting |
2025-06-02 16:58:16 -04:00
| Systemd | ✅ **BUILT** | Native s390x compilation complete |
2025-06-02 09:21:38 -04:00
| Bash | ❌ TODO | Needs s390x build |
| GNU Coreutils | ❌ TODO | Replace busybox applets |
### Legend
- ✅ **Complete** - Fully working
- 🟨 **Minimal** - Working but minimal implementation
- ❌ **TODO** - Not yet implemented
2025-05-31 14:57:37 -04:00
## Build System
Uses **Fedora containers with Podman** for cross-compilation:
```bash
2025-06-02 09:21:38 -04:00
# Container image:
2025-06-01 08:31:36 -04:00
s390x-archlinux-dev # All-in-one development container
2025-05-29 05:54:20 -04:00
```
2025-05-31 14:57:37 -04:00
2025-06-02 09:21:38 -04:00
### Build Targets:
- `make all` - Build complete system (kernel + initramfs)
2025-06-02 15:52:32 -04:00
- `make kernel` - Cross-compile Arch Linux kernel for s390x
2025-06-02 09:21:38 -04:00
- `make initramfs` - Generate initramfs with mkinitcpio
2025-06-02 16:58:16 -04:00
- `make systemd` - Build systemd natively on z/VM
2025-06-02 09:21:38 -04:00
- `make test` - Test initramfs-only system with QEMU
- `make test-rootfs` - Test with root filesystem switching
2025-06-02 16:58:16 -04:00
- `make test-systemd` - Test with systemd as init
2025-06-02 09:21:38 -04:00
- `make clean` - Clean build artifacts
2025-05-31 14:57:37 -04:00
### Key Scripts:
2025-06-02 15:52:32 -04:00
- `scripts/build-arch-kernel.sh` - Cross-compile Arch Linux kernel
2025-05-31 14:57:37 -04:00
- `scripts/build-initramfs-final.sh` - Generate initramfs
2025-06-02 16:58:16 -04:00
- `scripts/build-systemd-zvm.sh` - Build systemd on z/VM
- `scripts/deploy-and-build-systemd-zvm.sh` - Orchestrate systemd build
2025-06-02 09:21:38 -04:00
- `scripts/run-qemu-initramfs-only.sh` - Test initramfs-only system
- `scripts/test-qemu-rootfs.sh` - Test with root filesystem
2025-06-02 16:58:16 -04:00
- `scripts/test-qemu-systemd.sh` - Test with systemd as init
2025-06-02 09:21:38 -04:00
- `scripts/build-busybox-zvm.sh` - Build static busybox on z/VM
2025-05-31 14:57:37 -04:00
## Testing
```bash
# Install QEMU s390x
sudo pacman -S qemu-system-s390x # Arch Linux
# or
sudo apt install qemu-system-s390x # Ubuntu/Debian
2025-06-02 09:21:38 -04:00
# Test initramfs-only system
make test
# Test root filesystem switching
make test-rootfs
2025-05-29 05:54:20 -04:00
```
2025-06-02 09:21:38 -04:00
**Expected**:
- `make test` - System boots to emergency shell in initramfs-only mode (press Ctrl-A X to exit)
- `make test-rootfs` - Boots completely to root filesystem with busybox shell
2025-05-31 14:57:37 -04:00
[](https://asciinema.org/a/QVmnI1tyJjjFp4cps93qiTbM9)
## Output Files
After building:
- `boot/vmlinuz-linux` - Ready-to-use s390x kernel
2025-06-02 09:21:38 -04:00
- `boot/initramfs-linux.img` - Working initramfs
- `boot/rootfs-s390x.img` - Root filesystem image (created by test-rootfs)
2025-05-31 14:57:37 -04:00
- `boot/generic.ins` - IPL configuration for real hardware
- `boot/arch.prm` - Kernel parameters
2025-06-02 09:21:38 -04:00
- `boot/busybox-s390x-static` - Static busybox binary built on z/VM
2025-05-31 14:57:37 -04:00
## Technical Details
### s390x Adaptations:
- Big-endian architecture support
- IPL boot process (not BIOS/UEFI)
- Channel I/O subsystem drivers
- mkinitcpio modified for cross-architecture builds
2025-06-02 09:21:38 -04:00
### Key Fixes Applied:
1. **mkinitcpio adaptation** - Fixed `add_binary` vs `add_file` issue for init scripts
2. **Static busybox** - Built natively on z/VM to eliminate dynamic linking
3. **Architecture compatibility** - Fixed base hook to exclude x86_64 binaries
4. **Init script patching** - Modified standard Arch init to use `busybox switch_root`
2025-05-31 14:57:37 -04:00
2025-06-02 09:21:38 -04:00
## System Boot Success
2025-05-31 14:57:37 -04:00
2025-06-02 09:21:38 -04:00
The system successfully boots from initramfs to root filesystem:
2025-05-31 14:57:37 -04:00
2025-06-02 09:21:38 -04:00
```
[ 22.867595] Run /init as init process
:: mounting '/dev/vda' on real root
[ 23.131648] EXT4-fs (vda): mounted filesystem r/w with ordered data mode
/ # cat /etc/os-release
NAME="Arch Linux"
PRETTY_NAME="Arch Linux"
ID=arch
/ # uname -a
Linux arch 6.6.10 #14 SMP Mon Jun 2 14:59:34 UTC 2025 s390x GNU/Linux
```