initial VERY rough commit

This commit is contained in:
Andrea Rogers 2025-10-09 14:23:02 -05:00
commit c39e7c37ed
2 changed files with 88 additions and 0 deletions

59
GNUmakefile Normal file
View file

@ -0,0 +1,59 @@
ARCH ?= $(shell uname -m)
QEMU ?= qemu-system-$(ARCH)
UBUNTU_ROOT ?= roots/ubuntu_wiredemo-admin.targetdisk.local
SSH_PORT ?= 2222
ifeq ($(ARCH),x86_64)
OVMF_ARCH := x64
else ifeq ($(ARCH),x86)
OVMF_ARCH := ia32
else ifneq (,$(findstring arm,$(ARCH)))
OVMF_ARCH := arm
else
OVMF_ARCH := $(ARCH)
endif
QEMU_OVMF ?= /usr/share/ovmf/$(OVMF_ARCH)/OVMF.*fd
QEMUOPTS ?= -cpu max -enable-kvm -smp $(shell nproc) \
-nodefaults -no-user-config -nographic \
-chardev stdio,id=virtcons0 \
-device virtio-serial-pci \
-device virtconsole,chardev=virtcons0 \
-m 62G \
-net user,hostfwd=tcp::$(SSH_PORT)-:22 \
-net nic \
-device virtio-9p-pci,id=fs0,fsdev=fsdev-fs0,mount_tag=fs0 \
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
# -bios $(QEMU_OVMF) \
# -bios /usr/share/qemu/qboot.rom
# -machine microvm,accel=kvm,rtc=on \
UBUNTU_ISO ?= iso/ubuntu/ubuntu-24.04.2-live-server-amd64.iso
UBUNTU_ISO_ARGS ?= -drive file=$(UBUNTU_ISO),media=cdrom,id=virtiso1 \
# -device virtio-blk-pci,drive=virtiso1 \
# -kernel mnt/casper/vmlinuz \
# -append "earlyprintk=ttyS0"
UBUNTU_FAT_ARGS ?= -drive file=fat:rw:$(UBUNTU_ROOT)/boot,id=virtiso1 \
$(UBUNTU_ROOT):
mkdir -p $@
root1: $(UBUNTU_ROOT)
roots/ubuntu_wiredemo-admin.wiredemo.local:
mkdir -p $@
run1-installer: $(UBUNTU_ROOT)
$(QEMU) $(QEMUOPTS) $(UBUNTU_ISO_ARGS) \
-fsdev local,security_model=mapped,id=fsdev-fs0,multidevs=remap,path=$<
run1: $(UBUNTU_ROOT)
$(QEMU) $(QEMUOPTS) \
-kernel $(UBUNTU_ROOT)/boot/$(shell cat $(UBUNTU_ROOT)/boot/vmlinuz) \
-append "earlyprintk=ttyS0 root=fs0 rw rootfstype=9p rootflags=trans=virtio,version=9p2000.L,msize=5000000,cache=mmap,posixacl console=ttyS0" \
-initrd $(UBUNTU_ROOT)/boot/$(shell cat $(UBUNTU_ROOT)/boot/initrd.img) \
-fsdev local,security_model=mapped,id=fsdev-fs0,multidevs=remap,path=$<
.PHONY: root1 run1 run1-installer

29
README.md Normal file
View file

@ -0,0 +1,29 @@
# 9p Ubuntu Server VM
There are still some rough edges here, but this is a GNU makefile that allows
you to run a headless Ubuntu VM on a 9p filesystem.
When I get my website back up, I'll link the blog post this inspired that
explains what and why this is.
## Requirements
- A QEMU build with the 9p stuff (many distros include the stuff in their QEMU
packages)
- GNU Make
- OVMF EFI firmware (this requirement may go away later on)
## Using
Run the installer:
```
SSH_PORT=2221 UBUNTU_ISO=path/to/ubuntu_whatever.iso make run1-installer
```
More info on the installer coming soon...
Enjoy your VM:
```
make run1
```
## TODO
- pull down the Ubuntu ISO automagically so somewhere pointed to
by `UBUNTU_ISO` automagically