1. 34
  1.  

  2. 3

    So here’s the list of parts we need to build a working, useful Unix system:

    • init
    • a supervisor
    • a login program
    • a shell
    • a C library

    Isn’t really more needed when it comes to Linux? Using only that, you will have an empty /dev, as mknod isn’t part of the shell (not even talking about udev), and I think you get a kernel panic in such case.

    On a side note, I’ve been working on a self-bootstrapping distro for quite a while, and I was stunned by the amount of programs needed to reach this goal (think gcc, yacc, perl, python, etc…)

    1. 1

      defvs entries aren’t populated from the userspace for a while now, and udev isn’t a requirement unless you handle hotplug.

      1. 1

        defvs entries aren’t populated from the userspace for a while now

        I thought systemd/udev populated /dev on modern systems

        1. 3

          Indeed, devfs has been marked obsolete in 2003 in favor of udev:

          https://lwn.net/Articles/44731/

          Of course, you could just pre-create the device nodes, as was done before udev and devfs ;).

          1. 2

            Slip of the pen, it’s devtmpfs.

            https://lwn.net/Articles/330985/

          2. 2

            See my sibling reply. Neither udev nor systemd are requirements for a usable system, Linux predates both by many years.

          3. 1

            Who creates them then? The kernel itself? Take /dev/console for example. Wouldn’t it prevent the kernel to boot if it is not present? AFAIK, udev does more than hotplugging, as it replaces what devfs used to do.

            1. 4

              When a device driver registers new device, the kernel creates a node in devtmpfs. There is no need to manage it with udev in static configurations. Many embedded Linux systems never run udev. There’s been no practical hard requirement for mknod since 2.6.

              1. 2

                Take /dev/console for example. Wouldn’t it prevent the kernel to boot if it is not present?

                The kernel does not write to the console (or any other device) by opening a device node in the filesystem. The device driver already lives inside the kernel, there’s no need to go via the filesystem (it writes to the console well before the root filesystem is mounted). So no, it wouldn’t prevent the kernel from booting if /dev/console wasn’t present. (It might create a problem for early userspace, though IIRC even init will have handles to the console set up directly by the kernel).

                1. 1

                  This makes sense indeed, thanks for the reply!

                  I wonder to what extent a system would be usable with an empty /dev. Would a shell actually start without a TTY? I was playing with containers the other day, and running mksh inside it required that I create a few nodes in $chroot/dev/ before being able to start it. Maybe other shells can work around that?

                  1. 1

                    Containers share a kernel, which is already aware of the devices, on an isolated file system and process space where there is limited kernel introspection in this regard. Thus the rules are a little different.

                    1. 1

                      I don’t know the specific details of various shells, but in theory I think it should be possible to have a shell that doesn’t try to open any devices. (It’s a pretty onerous restriction though; there’s not much you’ll be able to do in a system with no device nodes).

                    2. 1

                      Though the fork children could always inherit standard output et al.

                      1. 1

                        That’s what I was implying trying to imply, yes.

              2. 2

                gosh, to do this on a BSD is essentially: clone the repo, change whatever you want and then type make world.

                1. 1

                  “Wanna write a Linux userland” scans better, I think

                  1. 0

                    ‘Wanna’ isn’t a word.