[HN Gopher] Easylkb: Easy Linux Kernel Builder
       ___________________________________________________________________
        
       Easylkb: Easy Linux Kernel Builder
        
       Author : sjuut
       Score  : 107 points
       Date   : 2023-11-21 12:42 UTC (10 hours ago)
        
 (HTM) web link (tmpout.sh)
 (TXT) w3m dump (tmpout.sh)
        
       | bheadmaster wrote:
       | I've wanted to do some Linux kernel development for a while now,
       | but I've never mustered the will to go through the process.
       | 
       | This script may just be what I needed to start.
        
         | ngcc_hk wrote:
         | I just want to learn. Unfortunately those days with simple
         | source commentary long gone. Hence whilst we have this good
         | tutorial about setup ... but how you start to learn more about.
        
           | Galanwe wrote:
           | Considering and size and complexity of the Linux kernel, I
           | don't think any amount of source code comments would help you
           | much, unless you already have a strong understanding of the
           | underlying subsystem you want to hack on.
           | 
           | "Understanding the Linux kernel", and "Linux device drivers"
           | are pretty good, pragmatic books IMHO to give you a solid
           | understanding of most useful subsystem.
           | 
           | As for this kernel building script, I guess it could be
           | handy, but unless you're hacking very frequently I never
           | found the actual build of the kernel to be the more
           | cumbersome part.
        
             | synergy20 wrote:
             | the kernel and device drivers are both a bit out of date
             | unfortunately, hope LF can found new revisions of them.
        
             | protomolecule wrote:
             | How relevant are these books today? They were both written
             | in 2005.
        
               | AlotOfReading wrote:
               | A bit out of date, but not to the point of being useless.
               | I still give them to juniors and interns that want to
               | learn more about kernel work. There's also a much more
               | recent (2022) book called _Linux Device Driver
               | Development_ published by packt. In general, these sorts
               | of books are mainly useful for  "what not to do", as
               | general architecture stuff is usually well documented by
               | source code examples and in-kernel docs.
        
             | bheadmaster wrote:
             | > unless you're hacking very frequently I never found the
             | actual build of the kernel to be the more cumbersome part
             | 
             | Doesn't kernel use incremental builds? All well-designed C
             | projects that I know of compile .c files into .o files and
             | link them, so a single file modification only requires a
             | single recompilation/relinking.
        
               | chlorion wrote:
               | It does use incremental builds so long as you don't reset
               | everything.
               | 
               | I'm not sure that a lot of people who don't work with
               | make realize that it's smart enough to only rebuild what
               | has changed, and that it's not just a command runner!
        
         | rubenbe wrote:
         | If you want to get a good introduction, I recommend the bootlin
         | kernel course. All course material is available on their
         | website.
         | 
         | https://bootlin.com/training/kernel/
        
           | j4hdufd8 wrote:
           | Thank you! This looks really good
           | 
           | The Linux Foundation has similar offerings but 3x more
           | expensive, less time, and online only
           | https://training.linuxfoundation.org/linux-kernel-
           | developmen...
        
       | eptcyka wrote:
       | I found the NixOS wiki[1] to have a fairly decent guide on how to
       | hack on a kernel. The process there isn't nearly as concise as it
       | is here though :)
       | 
       | [1]: https://nixos.wiki/wiki/Linux_kernel
        
         | Jhsto wrote:
         | I personally wen't this route last year and eventually got
         | things working (networking etc. OK with only the kernel). My
         | company then took a direction in which each compute node has
         | its custom kernel, so that we can control the initial stages of
         | boot better (initrd is dynamically downloaded from intranet,
         | given that the network drivers are baked-in) to manage
         | heterogeneous nodes with different "roles" (GPUs, add-on
         | devices, etc.).
         | 
         | Something I have been surprised about is how much functionality
         | exists in the Linux kernel and how much more reliable the
         | modules are compared to many user-space tools (e.g. race-
         | conditions).
        
       | gregfjohnson wrote:
       | Mind. Officially. Blown. Sometimes the coincidental timeliness of
       | things popping up on Hacker News is just weird. u ROCK
       | deepseagirl!
       | 
       | I've recently wanted to start building Linux kernels and play
       | with device drivers again. Wanted to build and then execute on
       | top of QEMU. Downloaded, configured, and built Linux kernel 6.6
       | following recipes from arch and a few other places. Doing a
       | reasonable .config was a painful process (picking what to include
       | etc.) The kernel build took several hours. The resulting image
       | refused to boot under Virtual Machine Manager, to say nothing of
       | using gdb etc. to interactively debug the kernel.
       | 
       | So, I figured I was looking at a solid weekend of googling,
       | stack-overflowing, swearing, reading kernel Documentation files
       | etc. and finally getting everything set up and working happily.
       | 
       | NOT! The easylkb script did the entire thing completely
       | automatically, culminating in a login prompt on a running virtual
       | machine!! The Linux kernel .config was one of the standard ones I
       | believe, but I hadn't yet found it. The complete kernel build
       | took on the order of several minutes instead of several hours.
       | 
       | There were a couple of minor issues I had with easylkb, which I
       | will share as comments on github.
        
         | iam-TJ wrote:
         | In the kernel source directory do:                   make help
         | | less
         | 
         | and the various config targets are listed; to use the default
         | configuration (for the current host architecture) do:
         | make defconfig
         | 
         | To edit it further use one of the edit options such as
         | menuconfig:                  make menuconfig
         | 
         | All of these create/operate on ./.config in the source-code
         | 'root' directory.
         | 
         | This and much more is covered in
         | 
         | https://kernelnewbies.org/KernelBuild
        
           | rwmj wrote:
           | Another useful tip is to grab an existing config, eg. the one
           | for your current system found under /boot, rename it .config
           | and then do 'make olddefconfig' (followed by building the
           | kernel in the usual way).
           | 
           | Distro kernels are normally quite "full fat" so this may tend
           | to build a lot, but it's a good way to get a kernel which
           | closely matches what you're typically running, both in terms
           | of device coverage and compilation options / hardening.
        
         | gregfjohnson wrote:
         | Greatly appreciate the suggestions and pointers! (Not sure how
         | HN orders "reply's", but this is in response to other replys to
         | my initial comment.)
        
       | klysm wrote:
       | I didn't have a very hard time kernels, but building the gnu
       | toolchain is an absolute disaster
        
       | rollcat wrote:
       | Ooooh this is very cute.
       | 
       | I'm toying with building a little OS using the Linux kernel and
       | an all-Go userspace, and one of the goals is to make the entire
       | system as easy to cross-compile (both host OS _and_ host /guest
       | CPU arch) as possible. Linux being non-trivial to compile (let
       | alone cross-compile) has been so far quite a nuissance, so I'll
       | definitely be having a closer look at this.
        
         | Piraty wrote:
         | cross compilation equally non-trivial. set CROSS_COMPILE= and
         | ARCH= and making the appropriate changes to .config (either set
         | ARCH and `make defconfig`, or modify the relevant parts in
         | `make menuconfig`). then build as usual
        
         | jsmith45 wrote:
         | The idea there sounds a lot like https://gokrazy.org/, which
         | builds a minimal go userland, wrapping one or more user
         | provided go applications, and bundles in a linux kernel.
         | 
         | Targets mostly at single board computers, and I think it
         | downloads pre-built kernels (and bootloaters if needed), rather
         | than trying to build them directly, since getting a working
         | cross compilation toolchain set up and plumbed into the kernel
         | compilation process is still a pain.
         | 
         | I've personally only used yocto/open-embedded for that which
         | does nicely handle building the cross-compilation toolchain,
         | kernel image, and modules. But it is kinda overkill for that
         | task, being designed to build a whole userland too.
        
           | fragmede wrote:
           | 2nding gokrazy as a very nice embedded target for pi's.
        
       | anthk wrote:
       | Debian had make-kpkg for a while.
        
       ___________________________________________________________________
       (page generated 2023-11-21 23:03 UTC)