Hugo Hacker News

NetBSD Explained: The Unix System That Can Run on Anything

blippage 2021-08-18 09:39:20 +0000 UTC [ - ]

Linux user here, not NetBSD. My exposure to NetBSD is infinitesimal. But ...

I saw a video on "rump" kernels awhile back. I also heard that Andrew Tanenbaum ported/is porting Minix to NetBSD. NetBSD has an "anykernel" approach which separates the kernel for the drivers. So you can impose your own flavour of kernel on a bunch of pre-written drivers.

This struck me as a potentially mind-blowing win for NetBSD. Why isn't every RTOS, embedded system OS, toy OS,experimental OS etc. based on NetBSD? I don't know the reason for this. Maybe it's part NIH, part open secret that nobody's heard about, and a large part to do with getting over the hump of integration.

yjftsjthsd-h 2021-08-19 01:43:35 +0000 UTC [ - ]

Yeah, rump kernel tech seems like it should be taking the world by storm - in particular, it looks to me like NetBSD should be a "universal donor" of drivers to other systems. So for instance, as I understand it, with minimal shims, you should be able to use NetBSD hardware drivers on Linux and Illumos and HURD and Redox and [your hobby project here]. It'd be worse than "native" drivers, but especially for smaller projects it'd save a ton of work.

> I also heard that Andrew Tanenbaum ported/is porting Minix to NetBSD

Kernel, or userspace? Last I paid attention, MINIX 3 used pkgsrc for packages and I think base/coreutils in userspace, but I hadn't heard anything about kernel space. Though, as I mentioned above, it does seem like the obvious way to get drivers for a lot of hardware cheaply, especially if you're already a microkernel.

rekado 2021-08-19 09:35:46 +0000 UTC [ - ]

> with minimal shims, you should be able to use NetBSD hardware drivers on [...] HURD

The Hurd is already using rumpkernel for some servers, e.g. for audio and work is underway for disks.

the_only_law 2021-08-19 08:19:23 +0000 UTC [ - ]

Not NetBSD, but iirc a lot of the network drivers in Haiku were taken from FreeBSD.

1vuio0pswjnm7 2021-08-19 06:51:21 +0000 UTC [ - ]

Public release of RUMP predated Docker by at least two years, maybe it was more. I just remember when all the Docker hype began I was thinking "WTF, this is not even half as good." But that's what's different about NetBSD. No hype. To answer the question of why it isn't more widely used, IMO, besides absence of hype, it's lack of hardware support, and comfort among those who use it with notions like DIY and minimalism. Often you have to put in some effort to get some hardware feature to work.1 With Linux, chances are someone else has done that work for you.

1 First time I ever tried NetBSD, the audio did not work on the laptop I was using. I added a couple of lines in a kernel header file, recompiled and voila, I had audio. That simplicity made me want to keep using it.

qwerty456127 2021-08-19 10:20:17 +0000 UTC [ - ]

> I added a couple of lines in a kernel header file, recompiled and voila, I had audio

How did you figure out what to add?

1vuio0pswjnm7 2021-08-19 11:08:55 +0000 UTC [ - ]

IIRC, dmesg. It was probably pure luck that it worked.

anthk 2021-08-19 11:20:32 +0000 UTC [ - ]

Close to my change to the BTTV drivers for a Conceptronic TV card.

Most of hardware use common devices and chipsets.

rjsw 2021-08-19 01:40:54 +0000 UTC [ - ]

> NetBSD has an "anykernel" approach which separates the kernel for the drivers. So you can impose your own flavour of kernel on a bunch of pre-written drivers.

As a NetBSD developer, I don't recognize what you mean by this.

mapgrep 2021-08-19 03:38:13 +0000 UTC [ - ]

Maybe read this whitepaper:

https://www.netbsd.org/gallery/presentations/justin/2015_Asi...

“ The rump kernel has been used as a way to supply device drivers in other new operating systems, which do not yet have a full set of device drivers. For example, Genode[4] is a framework for building microkernel operating sys- tems using the L4 family of microkernels. Genode uses the rump kernel to provide file system support, so that it does not have to develop its own file systems.”

Here’s a 362 page dissertation on rump kernels which has a netbsd focus:

http://lib.tkk.fi/Diss/2012/isbn9789526049175/isbn9789526049...

There’s also the Wikipedia entry.

https://en.m.wikipedia.org/wiki/Rump_kernel

rjsw 2021-08-19 05:05:24 +0000 UTC [ - ]

That isn't how device drivers are used in NetBSD though, it is a different way of compiling them for other targets.

mapgrep 2021-08-19 05:31:52 +0000 UTC [ - ]

From the white paper published on netbsd.org:

“ An implementation that does this ships with NetBSD, allowing the NetBSD drivers to be run in NetBSD userspace… The first major PCI driver developed was the In- tel Centrino 7260 driver developed for NetBSD and OpenBSD by Antti Kantee. The commit message said “This is probably the world’s first Canadian cross device driver: it was created for OpenBSD by writing and port- ing a NetBSD driver which was developed in a rump ker- nel in Linux userspace.”[13]

Further, just another example, from page 149 in the dissertation is an extended many page discussion of how the rump kernel was used to provide usb support in netbsd.

http://lib.tkk.fi/Diss/2012/isbn9789526049175/isbn9789526049...

“ We implemented a host controller called ugenhc. When the kernel’s device autocon- figuration subsystem calls the ugenhc driver to probe the device, the ugenhc driver tries to open /dev/ugen on the host. If the open is successful, the host kernel has attached a device to the respective ugen instance and ugenhc can return a successful match. Next, the ugenhc driver is attached in the rump kernel, along with a USB bus and a USB root hub. The root hub driver explores the bus to see which devices are connected to it, causing the probes to be delivered first to ugenhc and through /dev/ugen to the host kernel and finally to the actual hardware. Figure 3.24 con- tains a “dmesg” of a server with four ugenhc devices configured and one USB mass media attached.”

¯\_(ツ)_/¯

rjsw 2021-08-19 12:10:19 +0000 UTC [ - ]

> ¯\_(ツ)_/¯

UTSL.

The author used rump to develop the drivers, it isn't used to run them in a production NetBSD kernel.

floatboth 2021-08-19 12:17:14 +0000 UTC [ - ]

But running on other targets is exactly what people are excited about?

jschwartzi 2021-08-19 03:27:50 +0000 UTC [ - ]

QNX RTOS uses netbsd userspace applications, actually. And a lot of the drivers in QNX are from NetBSD. It’s more properly a “microkernel” which means the drivers run as userspace applications with a defined interface to the kernel for memory maps to underlying hardware.

unixhero 2021-08-19 09:41:26 +0000 UTC [ - ]

Are new versions of QNX available on X86?

detaro 2021-08-19 09:43:59 +0000 UTC [ - ]

yes. (newest one might just be x86_64, not 100% sure on that)

qwerty456127 2021-08-19 11:20:59 +0000 UTC [ - ]

> newest one might just be x86_64

This would be weird. I believe 32-bit x86 still is widely used by the target audience.

detaro 2021-08-19 12:51:24 +0000 UTC [ - ]

Some subset, but even there it's waning, especially for new designs. QNX is seems to be not mentioning it explicitly anymore, and I don't remember seeing it in the options last time I looked, but it's very possible that it is still available if necessary.

unixhero 2021-08-19 09:49:39 +0000 UTC [ - ]

That's cool, I can emulate 32 if necessary :)

How might one obtain it?

touisteur 2021-08-19 11:03:06 +0000 UTC [ - ]

I'm guessing, call blackberry and prepare to break your piggybank?

2021-08-19 12:53:08 +0000 UTC [ - ]

nix23 2021-08-19 13:34:49 +0000 UTC [ - ]

Go there:

http://www.qnx.com/download/group.html?programid=29178

Download:

QNX Software Center

Register a free Non-Commercial/Academic License:

http://www.qnx.com/download/feature.html?programid=51624

tomxor 2021-08-19 01:35:50 +0000 UTC [ - ]

> This struck me as a potentially mind-blowing win for NetBSD. Why isn't every RTOS, embedded system OS, toy OS,experimental OS etc. based on NetBSD?

I think it is used a lot as a starting point for porting other OS, but it doesn't necessarily persist.

Supposedly Apple started with NetBSD when porting OS X to x86, not that x86 is exactly esoteric, but NetBSD lends itself to being a starting point. From what I read nothing remains of NetBSD in OSX, the current BSD userland is from FreeBSD but is pretty old still.

wahern 2021-08-19 03:05:42 +0000 UTC [ - ]

Apple Base Station and related firmwares (e.g. Extreme) ran NetBSD.

BSD-based products are more common than believed, but because of the liberal licensing they seem to mostly fly under the radar, not unlike various proprietary options like VxWorks and TRON.

snowwindwaves 2021-08-19 05:54:48 +0000 UTC [ - ]

Just to be clear vxworks is not bsd based that I could tell from Wikipedia. I work with Schneider electric plcs and sometimes vxworks errors bubble up.

codetrotter 2021-08-19 11:53:11 +0000 UTC [ - ]

I think they meant to say that BSD-based stuff is common but unknown to most, and that the same goes for VxWorks and TRON, in that both open source BSD and proprietary solutions have licenses that make their inclusion in other software products not noticed by many people.

tomxor 2021-08-19 12:59:28 +0000 UTC [ - ]

Same for Minix3... until someone dug it out of IntelME no one knew it was one of the most ubiquitous deployed OS.

mapgrep 2021-08-19 01:21:05 +0000 UTC [ - ]

That is super interesting. I will say the package manager (pkgsrc) seems to be very portable as well. It’s default on netbsd, smartos/illumos, and minix, but also available for macOS, Linux, and other operating systems. I use it routinely on smartos and it’s a breeze.

II2II 2021-08-19 03:25:36 +0000 UTC [ - ]

There was a time when NetBSD's portability was impressive. A handful of open source operating systems supported a handful of architectures, then there was NetBSD (and OpenBSD). Then Linux started to look beyond the x86 and started gathering steam on other architectures. NetBSD couldn't really compete for developers and it began stagnating. It probably didn't help that a lot of the "Unix" userspace also became more tightly coupled to Linux.

Don't get me wrong: I was enormously enthusiastic about NetBSD in the mid-1990's and I still prefer the idea of a unified core OS. The thing is, it's a lot easier to deal with one operating system than multiple. If you're developing under Linux, it's going to be easier to develop code for an Arm based system under Linux because it defines your expectations.

danieldk 2021-08-19 07:48:20 +0000 UTC [ - ]

Linux probably supports more platforms these days. But it often requires vendor-specific kernel forks, specific distributions, etc. NetBSD is impressive because it can be (cross-)compiled for many systems using the stock distribution without much effort (build.sh script).

Disclaimer: I haven't used or looked at NetBSD since 2006-2007 or so, but I think this is still accurate.

anthk 2021-08-19 11:33:25 +0000 UTC [ - ]

This. Linux under ARM is a nightmare, NetBSD for ARM it's just a single distribution per subarch.

anthk 2021-08-19 11:32:40 +0000 UTC [ - ]

Linux doesn't even properly work on legacy non-x86 devices. NetBSD for m68k runs much better than GNU/Linux.

EDIT: Downvote me if you want, but the reality is that hard.

You have to use specific distros and hard patches to get things running well. For example under PPC32 there's no support for common distros.

Don't let me start on Mips, Sparc or Alpha, where NetBSD runs on it just fine.

nix23 2021-08-19 08:30:21 +0000 UTC [ - ]

Linux is just a Kernel NetBSD is a System.

swiley 2021-08-19 10:57:29 +0000 UTC [ - ]

IMO: NetBSD might be superior but the lack of GPL means less work on it is published. The net effect is that everyone puts up with Linux because it actually runs on everything.

anthk 2021-08-19 11:34:39 +0000 UTC [ - ]

>Linux because it actually runs on everything.

Good joke. Linux barely runs on some legacy arches, having to use really old kernels and making a lot of current software useless.

NetBSD just /runs/ new releases on older hardware such as m68k machines with no crazy tweaks.

>but the lack of GPL means less work on it is published.

You realize a lot of the components on the graphics substack on Linux are non-GPL, right? Not just X, but the backends on the kernel.

Also Linux is full of propietary drivers and blobs. Check Linux-Libre's changelog if you don't believe me.

jayp1418 2021-08-19 16:34:50 +0000 UTC [ - ]

Also if anyone interested in testing out new GPU code check this : https://www.unitedbsd.com/d/563-56-gpu-drivers-update

avmich 2021-08-19 02:35:35 +0000 UTC [ - ]

There are BSD clones for smallish (small memory or even no real memory management unit) systems - RetroBSD and LiteBSD: http://retrobsd.org/wiki/doku.php , https://github.com/sergev/LiteBSD/wiki .

forty 2021-08-19 05:33:29 +0000 UTC [ - ]

I always read about NetBSD fantastic portability. I wonder though, in practice, is there any hardware that NetBSD supports that Linux doesn't?

the_only_law 2021-08-19 08:20:43 +0000 UTC [ - ]

VAX

https://en.m.wikipedia.org/wiki/VAX

In fact I’m pretty certain NetBSD is the only modern OS that still has an active VaX port. OpenBSD used to I believe, but no longer. Not even newer OpenVMS runs on the platform.

forty 2021-08-19 11:45:22 +0000 UTC [ - ]

Indeed! Linux on VAX effort seems to only have traces on the internet until 2001 (which is apparently one year after VAX was discontinued by its maker).

I'm now curious to know where those 20+ year old computers can be found? I guess at least the NetBSD VAX port people must have some working hardware? Unless they work on emulators for hardware that doesn't exist anymore, just for the beauty of it? Are there still productions systems running it? If there are, I'm assuming they are not the kind of production system where you would update de OS anyway ^^

liveoneggs 2021-08-19 12:37:48 +0000 UTC [ - ]

they have real hardware and defend it

robertlagrant 2021-08-19 04:10:45 +0000 UTC [ - ]

Literally got bored of scanning through the hundreds of cookies to find the ones that have "legitimate interest" to individually turn off.

Hope the article was good!

fogihujy 2021-08-19 06:09:56 +0000 UTC [ - ]

Get an adblocker to block the consent modal. The Internet will be a much nicer place.

afiori 2021-08-19 06:40:40 +0000 UTC [ - ]

consent modals are important, you should get an adblocker to block tracking where the choice is not given

BoxOfRain 2021-08-19 11:10:46 +0000 UTC [ - ]

I strongly disagree, they're little more than pointless nagware designed as a fig leaf over the gaping privacy issues on the modern web. While I get the intention, it was clearly designed by people who didn't grasp the concept of alarm fatigue and they're usually full of truly obnoxious dark patterns which have nothing to do with informed consent.

I block them all and it massively improves the user experience of the web.

nextaccountic 2021-08-19 15:19:51 +0000 UTC [ - ]

I don't consent to tracking, like, ever. So the proper way to deal with this is to auto-deny and not show up the popup.

fogihujy 2021-08-19 07:38:54 +0000 UTC [ - ]

I block both.

Tracking isn't really legal without consent, though. If a page tracks visitors without explicit consent the site owner is breaking the GDPR.

throwawayswede 2021-08-19 10:46:59 +0000 UTC [ - ]

If you use an extension that auto-approves, it's on you. I'm not familiar with adblock that blocks consent dialog or auto uncheckes all possible and clicks "ok"

rhn_mk1 2021-08-19 11:00:57 +0000 UTC [ - ]

That's not true. There are multiple bases for data processing in the GDPR that are not dependent on consent: https://ico.org.uk/for-organisations/guide-to-data-protectio...

It's not clear to me that tracking is unconditionally illegal in any of them.

pjerem 2021-08-19 06:46:01 +0000 UTC [ - ]

Same. That was insulting. I managed to read it through Safari’ Reader mode.

simonjgreen 2021-08-19 07:22:44 +0000 UTC [ - ]

I have great memories sat in the labs at college with peculiar hardware just seeing what we could run netbsd on. Aside from education it had no practical utility to us at the time, but it was good fun :)

Brilliant project delivering some good free spirited light heartedness to the OS world.

LAC-Tech 2021-08-19 03:04:21 +0000 UTC [ - ]

It couldn't run on my "bring your own ISO" VPS provider. which did manage to run OpenBSD and FreeBSD.

(Very possible I made some noob mistake)

anthk 2021-08-19 01:31:16 +0000 UTC [ - ]

OpenBSD and Void user here. NetBSD was good under the 5.x/6.x era on the desktop, then the quality plummeted, a lot of ports segfaulted.

Now with 9.2 people is telling me is working really great as in the old days.

tomxor 2021-08-19 01:42:00 +0000 UTC [ - ]

I have some not great memories of trying to use it through 5.x back when there was no binary package manager. A lot of stuff wouldn't compile easily or segfaulted easily even on x86, but it was a long time ago and I was a noob at unix let alone fixing compilation issues, so I never really knew if it was my incompetence or NetBSD. Either way it was definitely harder back then without binary packages... I remember thinking at the time: what's the point on being able to run on old hardware if it takes a month to compile the stuff you need.

mlyle 2021-08-19 05:03:37 +0000 UTC [ - ]

Yah... I ran NetBSD-1.1 and then followed current for awhile from source on little machines-- first a 486, then a Pentium and a SPARC 1+. It was clean and wonderful.

I just dug the Pentium of my late childhood out of the closet and figured I'd play DOS games and install recent NetBSD. But GENERIC is too big even with the reasonable maximum 64MB of RAM (most Pentiums cannot cache more than 64MB) to do anything but crawl, and compiling a kernel takes about 15 hours on a Pentium 120... and sure, I could build on another machine, but is it even Unix anymore if it's not self-hosting?

anthk 2021-08-19 11:38:54 +0000 UTC [ - ]

Cross-compile the kernel, sets and pkgs on a newer machine. NetBSD makes it really easy to do so.

https://www.netbsd.org/docs/guide/en/chap-build.html

EDIT: Slim down the kernel as much as you can.

bruce343434 2021-08-19 08:02:04 +0000 UTC [ - ]

...and has gaping flaws in its ipv6 implementation

greyface- 2021-08-19 08:08:29 +0000 UTC [ - ]

https://www.netbsd.org/support/security/advisory.html

  NetBSD-SA2021-001 Predictable ID disclosures in IPv4 and IPv6
  NetBSD-SA2020-002 Specific ICMPv6 error message packet can crash the system
  NetBSD-SA2019-004 IPv6 neighbor cache leak on expiration
  NetBSD-SA2018-004 Remote Memory Corruption in IPv6
  NetBSD-SA2018-003 Remote DoS in IPsec (IPv6)
  NetBSD-SA2008-015 ICMPv6 Packet Too Big messages
  NetBSD-SA2008-013 IPv6 Neighbor Discovery Protocol
  NetBSD-SA2008-011 ICMPv6 MLD query
  NetBSD-SA2008-003 IPsec in IPv6 Denial of Service
  NetBSD-SA2007-005 IPv6 Type 0 Routing Header
  NetBSD-SA2006-016 IPv6 socket options can crash the system
  NetBSD-SA2004-002 Inconsistent IPv6 path MTU discovery handling

unixhero 2021-08-19 09:46:20 +0000 UTC [ - ]

That's important point, yes. Are you one of the few ipv6 users?

ggm 2021-08-19 10:35:02 +0000 UTC [ - ]

Few? World is on 27%. South Asia on 60%, North Americq is 47% , Europe on 43%

Check around. I don't call a quarter of the world "few"

hansel_der 2021-08-19 10:51:12 +0000 UTC [ - ]

mostly phones thou

ggm 2021-08-19 11:08:38 +0000 UTC [ - ]

Lotta phones. But a lotta fibre and hfc is dualstack. The aussie NBN, Vietnam FPT, Comcast, sky UK...

swiley 2021-08-19 11:17:49 +0000 UTC [ - ]

FIOS is one of the only decent ISPs in the US still on IPv4 only.