Join the discussion
Write your take first — we'll ask for email only when you're ready to publish.
- Hacker News
- You may also want to build and run busybox for your tiny userspace.
Other things you may want to experiment with is gen_init_cpio.c from linux kernel tree. It makes creating initramfs file structure easier from scripts.
And finally if sys/isolinux is also fun to use for minimal boot images.
by megous - Highly instructive. My long term goal with my lone lisp programming language is to do exactly this.
- > cpio is a very weird and ancient program with a command line which makes tar look user-friendly. But let’s not worry about the details for now.
So true. Been using cpio sporadically for many (many) years. And I still have to look it up. But at least I don't have to do `info cpio` anymore.
by -warren - > the linux kernel configuration menu, a wonderful text menu system with a thousand options which has been baffling new users for about 30 years now.
So true.
In addition to C in the article and Rust linked to in the article, Go fans can use the similar https://gokrazy.org/ project.
by mrbluecoat - It's be cool to dual boot with a Linux that has a ~1s boot time, drops you into neovim and lets you save text files to a shared partition.
- It's possible to do a similar thing with any old smartphone. :)by megous
- I... fail to see the point of running just one process.
If it's just a PoC, then:
1) I remember seeing a linux firewall/gateway set up to run with just the kernel, without any userspace at all. Completely unhackable.
2) To print some text or run a simple program, I belive DOS without a memory manager would be even faster.
3) It takes 1s to boot linux, but an ordinary PC takes 10s to get to that linux. Even U-boot on ARM takes some seconds to load a kernel.
BTW, if anyone knows any current platform that can XiP a linux kernel, please share.
by M95D - > Completely unhackable.
I don't think this could ever be true.
- Embedded devices or other SoC situations, certain limited scope situations where docker is undesirable/unnecessary, etc.by hylaride
- Wouldn't this be useful for embedded types of applications where you have a very specific task you want to do and you want to do it now.... like that firewall example?by kube-system
- > I... fail to see the point of running just one process.
It makes sense if you got some legacy piece of hardware that has extremely limited resources, both in terms of RAM and storage. Write your code in Go and you don't even need libc any more.
by mschuster91 - > I remember seeing a linux firewall/gateway set up to run with just the kernel, without any userspace at all. Completely unhackable.
Do you remember any details that would let me search for it? Because that does sound cool, and even maybe useful; the thought has certainly crossed my mind that a router or VPN box doesn't really get a lot of use out of userspace... Although maybe it's worth keeping for control/configuration/debugging.
> To print some text or run a simple program, I belive DOS without a memory manager would be even faster.
Or just make your code boot directly. It's not hard to make a .efi, or use https://github.com/jart/cosmopolitan to make a binary that runs in many places including bare metal.
by yjftsjthsd-h - I do the “Linux from Scratch” challenge every few years and the last time I did it, I got as far as I needed to be able to build antirez’ LOAD81[1] directly from single mode in a few seconds.. it was so satisfying. I lost the image in some later admin task, but I’m going to do it again, and maybe see about adding threads and SQLite support to LOAD81 alongside the other goodies, just for the fun of it ..by MomsAVoxell
- As I'm currently exploring kernel build things, the alternative to `make tinyconfig` is `make allnoconfig` which is supposedly will not disable expert options and might be a little bit safer starting point.by vbezhenar
- There's an option `make localyesconfig` (or similar)/which uses the kernel modules loaded on your current system.
- Tried out doing this kind of stuff a while back to create a custom user space, and I found that suckless’ init, sinit, was quite educational for how to deal with init’s responsibilities in a super minimal way: https://core.suckless.org/sinit/by dwroberts
- > .. There was a brief moment in the early 2000s where the newly introduced SSDs made booting quick ..
Anyone else reading this and getting the feeling someone is reminiscing about a past they didn't live and thus are seeing it through rose-colored glasses because it didn't exist?
In the early 2000s, SSDs had an obscene price tag of ~$1000 per gigabyte, so even an 8GB drive would cost you about $8000. There was nothing for the tech industry to ruin because only 0.01% of people owned a setup with an SSD. And neither Linux, NT or Mach were optimized for them. Hell, to this day Linux' VM system is by default still tuned for swap and slow HDDs (swappiness 60 and all that) because no one has bothered to update the defaults.
by jorvi - When I swapped my disk in my mac for a SSD for the first time... It was insanely faster. Booted in 5-6 seconds. Apps like photoshop opened up cold in 2 seconds. So no, I think it was a huge leap.
I think no matter what the advance in tech is, it will get enshittified to tolerated "computer is working" slowness within months of said upgrade.
by keyle - Or they meant 2010s?by abrowne
- It was also around the time of the early netbooks, when the premise was a lean laptop and you'd do tasks that'd usually be done with relatively demanding local clients by the browser, as google and others were improving their online app offerings. They'd be using things like SATA/IDE to compact flash adapters to keep power down and responsiveness up, they were an ideal candidate for early SSDs as they didn't need a lot of capacity to run a linux + lightweight DE. Then they became just cheap laptops running full windows.by keyringlight
- I distinctly remember buying my first SSD laptop in 2012 and being amazed at the boot time. At the time, I didn't realize it was because of the SSD, I just thought, "wow, the devs have made some fantastic optimizations in boot time!"
- They probably meant 2010s.
I remember this was the time when Google started pushing the Chromebook idea and highlighting how it could boot in "just a few seconds". One of the earliest models I got as a dogfooding device probably needed 20 seconds to boot or so. Nice, compared to the awful boot times of machines with HDDs... but not stellar.
But then, in 2011, my wife bought a MacBook Air with an SSD and I was blown away. That thing booted to a full desktop (and not the joke that ChromeOS was) in... 5, 6 seconds? It was ridiculous.
And we have lost all of those gains. I find it painful to witness how a recent Mac chews through I/O during boot or doing any sort of software update (iStat Menus is great to watch this sort of thing), and how these feel slower to that early experience of 15 years ago :-/
by jmmv - I went through a similar "thought process" to build this: https://www.endbasic.dev/endbox.html last year. I originally wanted to "just" launch my binary right after the kernel started... but in the end settled for a full NetBSD base system to get things like network and WiFi configuration to work with ease. (That said, I still hook very early in the boot sequence to launch my own program and take over the console so that the rest of the system is invisible and initializes in the background.)by jmmv
- Awesome work. I wish you'd write the process of getting it done step by step. I too would love to DIY my own netbsd.by keyle
- > I found “Building a tiny Linux from scratch” which does most of what I do here but in Rust and a year ago
Linux from scratch seems to still be doing fine at: https://www.linuxfromscratch.org. It's going on 27 years now.
> yeah, I know, proper C code needs to be scattered with return value checks and sensible reports of errno. I’ve left these out for clarity.
Somewhere, a LLM is trained on this code as we speak :)
But anyway, it's great that people are still interested in learning this stuff for fun.
by nottorp - > Somewhere, a LLM is trained on this code as we speak :)
Had a similar thought when I saw
dd if=/dev/zero of=/dev/sda bs=1M count=1by asalahli - > Somewhere, a LLM is trained on this code as we speak :)
If we collectively have to change the way we do things to better fit our tools rather than changing our tools to fit what we would naturally like to do, then we've failed as an industry.
by saghm