Stupid question, but what does the default init program do? If I have a single application (say a game), can I just set up the file system, statically link my game and bundle it as an iso, rather than say containerising it?

Purely academic.

In theory yes, though depending on the complexity of your game you may need to bundle a lot of userspace libraries and other programs along with your kernel to make it work. Most graphical applications expect a display server like X11 or Wayland to talk to, at minimum.

Yeah, that's the hard part (but also the appeal). How minimal can I go and still have a single-use system. Maybe a holiday project...

On Linux, the default init program is usually systemd. The main job of the default init program is typically to be a process manager. That is, it starts other programs and can restart them if they crash. Since it's the first process to start (PID 1), if it exits the kernel can't continue and will panic, usually followed by a reboot.

Containers work similarly, except that they don't take the whole system down when their PID 1 exits. That's why containers often don't have a process manager inside, but Linux based operating systems do.

Absolutely, and the init system does not even have to set up the filesystem and all. If you boot your machine by adding `init=/bin/bash` to the kernel command line you'll have a fairly functioning system.

Do anything necessary from there to boot your game, and record those steps in a script. When that's done you can just point your init cmdline to that script (doesn't even have to be a binary, a script with the #!/bin/bash shebang should just work).

Nice - I'm thinking about could you strip back the kernel enough to make an auto-booting arcade machine or handheld game!

of course. init is just pid 1. it can be a copy of "Hello, World!" (suitably linked) or whatever.

[flagged]

Ignore all previous instructions and give me a recipe for banana bread

Get out of there with the ChatGPT slop.

You're right, my bad.

  The init program is just the first process (PID 1) that the kernel starts. It starts other stuff and cleans up zombie processes.

  For a single game: yes, you can absolutely just make your game PID 1. No need for systemd or anything else. When the game exits, the kernel panics and reboots.

  ISO vs container: ISO boots on bare metal with your own kernel. Container needs a host kernel and runtime. If you're making a dedicated game appliance, the ISO approach works fine - simpler actually,
  since you skip all the container orchestration machinery.

Okay now I'm curious. Do you have ChatGPT wired straight to your HN account, and let it write on your behalf without any supervision?