
Build yourself a Linux - AlexeyBrin
https://github.com/MichielDerhaeg/build-linux
======
Sir_Cmpwn
Building a Linux distro from scratch has been one of the most tasking projects
I've attempted. There are two phases: the frustration phase, and the tedious
phase. Bootstrapping it is an incredibly frustrating process - I restarted
from scratch 5 times before any attempt ever got to the tedious phase. The
tedious phase never ends. You have to make hundreds of packages to get to a
usable desktop system. I've made 407 packages and I still don't have a desktop
to show for it (I'm hoping to get sway working tomorrow, I think I have about
30 packages left).

Still, I've finally gotten to a somewhat practical self-hosting system. My
laptop runs it on the metal and all of the infrastructure (website, bugzilla,
git hosting, mirrors) is on a server running my distro too. It's taken almost
a year of frustration, but it's very rewarding.

~~~
albertzeyer
I'm just curious: In what way is it rewarding? Just for educational purpose?
Or anything else? Or is it just a hobby? I mean, you are probably investing a
lot of time into this. This time you could spend on other things instead.

I see the educational purpose. Although you probably get similar
experience/understanding/education if you use something like Gentoo and you
would have to invest much less time because all the nasty corner cases are
already taken care of.

~~~
Sir_Cmpwn
It's rewarding because I finally have a Linux distro that's designed the way I
want. I started making this because I wasn't satisfied with anyone else's
offerings.

~~~
albertzeyer
Can you say what is different in your distro than in any other distro? And you
think that no other distro could have been extended/fixed to get what you
want? Do you consider that this is useful for anyone else? In that case, you
really should publish your work and write about it.

~~~
Sir_Cmpwn
Blog post: [https://drewdevault.com/2017/05/05/Building-a-real-Linux-
dis...](https://drewdevault.com/2017/05/05/Building-a-real-Linux-distro.html)

HN:
[https://news.ycombinator.com/item?id=14274352](https://news.ycombinator.com/item?id=14274352)

------
erikb
I really wondered what's so special about this project that aims to achieve
what probably more projects aimed to achieved than there are lines of code in
the kernel.

It's not the goal, it's not the OS. But the documentation is a sight to
behold! Very clear, detailed, interesting writing style, and it puts together
quite a few frustrating topics in a simple, structured matter. Wow and kudos!
Keep on writing docs, please!

~~~
michielderhaeg
Your kind words are much appreciated. Many people seem to indeed be missing
the point. I wasn't trying to create a new distro, I'm just trying to teach
people in a way so that it would just take a few hours of your time.

------
digi_owl
Both this and LFS reminds me that Linux makes sense until you get the DEs
involved. At that point shit just sprawls all over the place as there are no
longer any notion of layers.

~~~
djsumdog
Back in 2002 I ran LFS for a semester and a half. Then I got tired of saving
all my ./configure flags and switch to Redhat and gained a respect for package
management. :-P Eventually I started using Gentoo.

Still, I'm really glad I built and ran an LFS for nearly a year. It helped me
build a really in-dept knowledge of Linux that's helped me as I later moved
into embedded development.

Today I still use Gentoo (which feels like LFS with package management) and
Void and would recommend either for Linux devs.

~~~
vbezhenar
I did exactly the same in 2005. I even wrote my own init scripts, so I really
understood a lot what's going on at startup time. Linux was quite simple at
that time. I could write my own init, if I wanted. Unfortunately now this
knowledge is obsolete. Systemd is a complex beast which uses a lot of arcane
techniques, I'm hardly understanding it. chroot was a really simple concept,
but nowadays people use containers, and they are much more complex than
chroot. Logging is complicated. In the past I could try to load and then mount
partition from livecd or another OS and read logs, now I don't know how to do
it. Init scripts were simple bash scripts. They were verbose, may be buggy,
but after all they were just bash scripts and every Linux user knows bash, so
every Linux user could write or modify init script. Now systemd uses its own
format, I'm spending hours every time I need to write new service or timer for
RedHat. SELinux is just so complex. I know about UNIX permissions. They are so
simple and elegant. I'm using them everywhere, when I need security. I could
explain them in 2 minutes. SELinux has books. I have those books in bookmarks,
may be I'll read them sometimes. But until then, I just use copy-pasta from
internets to solve my tasks, like allow ssh to listen at non-standard port. I
don't think that it's good, that I have to run some random strings on my
computer from root without fully understanding what they are doing. SELinux
has binary compiled configurations and some encrypted logs for tools to
decipher them, what a mess! Sometimes I just disable it to get things done.

Don't get me wrong. I think that Linux looks more professional, more robust,
especially for system administrators, who can devote their lives to learn
about those systems. But for hobbyists, who doesn't have a lot of time, Linux
became much less transparent.

May be if I didn't have that prior knowledge, it would be easier to learn
those things from scratch. But I doubt it.

~~~
djsumdog
I've had to learn apparmour, which isn't too bad and a lot easier than SELinux
(maybe not as powerful).

Systemd is a religious argument at this point, but if you want simplicity
check out Void. It uses runit and I love it. It's incredibly simple. Startup
files are often less than 4 lines. I don't really like systemd either, but I
will admit, as a package maintainer, it does make packaging a lot
easier/universal. It'd be nice if there were drop in replacements for systemd
that uses the target files for services and trashed everything else. UselessD
was a cool project that attempted it, but it became to difficult to maintain.
:(

I currently work at a docker shop and I will say, containers are pretty nice.
They're better isolated chroots with a lot of cool versioning support. There
are pluses and minuses, but overall, I think docker is a nice evolution from
chroots. Now all the eco-systems around docker: kubernets, DC/OS/marathon,
nomad .. all totally different, proprietary and over-complicated.

~~~
JdeBP
The nosh toolset can of course import systemd socket, service, and target
units into its native daemontools-encore-superset form; which can then be used
on a BSD, on things like UbuntuBSD or Debian kFreeBSD, or (in theory) on
Debian Hurd; as well as on Linux operating systems.

* [http://jdebp.eu./Softwares/nosh/worked-example.html](http://jdebp.eu./Softwares/nosh/worked-example.html)

------
thom_nic
A similar process is building a custom kernel and rootfs for an ARM device
such as the beaglebone. Olimex actually has a good tutorial for their device:
[https://www.olimex.com/wiki/AM335x](https://www.olimex.com/wiki/AM335x)

This is only slightly more complicated due to the need to cross-build but I
found it fairly easy with qemu-static-arm and prebuilt cross toolchain
packages for Ubuntu/ Debian.

The benefit is that you can develop for a target device that is not your PC,
so no worry about messing up the bootloader and leaving your PC in a state
where you need a recovery CD to fix it and boot. Just get a USB-serial cable
:)

You can also try buildroot or yocto, although I had no interest in building
_every_ package manually versus relying on Debian's repos.

------
asciimo
This is almost as complicated as building a Javascript web application.

~~~
duncan_bayne
Except that the recommended tools don't change every few months ;)

~~~
qb45
Yeah, pmount, hal, ivman, udisks, consolekit, consolekit2, policykit, upstart,
systemd, oss, alsa, pulseaudio, xfree, xorg, wayland, mir, kms, gtk, gtk2,
gtk3, qt9, motif, unity, loadlin, lilo, grub, grub2, ghtml, webkit, qtwebkit,
webkitgtk, webkitgtk2...

I guess you're right, they change only every few years :)

~~~
duncan_bayne
He did say _almost_ as complicated ;)

(Also: QuickBASIC 4.5 forever! Assuming that's the meaning of your nick).

~~~
qb45
Yep, that's what got me started on programming as a kid. And it still has
better strings and arrays than C.

------
fizixer
Have you even looked at the LFS project[1]? And what does your guide provide
that LFS doesn't?

[1] [http://www.linuxfromscratch.org/](http://www.linuxfromscratch.org/)

~~~
accurrent
Actually LFS teaches you about the whole GNU Userland, getting a kernel up and
running with busybox is much easier. This project does just that - teaching
you the bare minimum.

~~~
jbit
The embedded version of CLFS (Cross-Compiled Linux From Scratch) covers
building a musl + busybox system: [http://clfs.org/view/clfs-
embedded/x86/](http://clfs.org/view/clfs-embedded/x86/) But the more resources
available on this kind of thing the better IMHO, there's not really a one size
fits all :)

------
lanna
If you are interested in building your own Linux, the LFS project has a lot of
detailed information:
[http://linuxfromscratch.org](http://linuxfromscratch.org)

~~~
btgeekboy
I see this project as the next logical step beyond LFS. LFS will help you get
one up and running from start to finish, but once you do that, you might want
to try it a bit more free-form. That's where this project seems to fit in.

~~~
cmrx64
Certainly you mean the other way around? This project gets you busybox and a
kernel, which barely qualifies as "up and running from start to finish",
whereas following this doesn't even get you a compiler in the target system.

------
jonathanstrange
I have a question related to this article, though not directly. If building
completely from scratch turns out too cumbersome and time-consuming, what
would be the easiest way of building a minimal, fast starting distro with
graphical user interface and networking whose only purpose is to run one
application on x86 hardware in kiosk mode?

Is there a distro builder for dummies?

~~~
slezyr
[https://susestudio.com/](https://susestudio.com/) (NOT REALY WHAT YOU WANT)

You can pick packages and build a distro from browser.

NixOS - You can make one config file to specify how your system should look
like. It's easy to make GUI for it.

------
throw2016
Following this guide will get you something very close to a base Alpine
Linuxwith busybox. Alpine is fairly minimal out of the box and even eschews
grub for syslinux.

The upside with Alpine is if you need features and packages they are an
install away. But if the purpose is to learn about compiling the kernel and
how the system initalizes this is a decent start.

------
thu
This sounds like Aboriginal Linux:
[http://landley.net/aboriginal/about.html](http://landley.net/aboriginal/about.html)

------
marenkay
Huge fang on Linux From Scratch myself, after reading this I wonder if someone
has tried the same with FreeBSD! Or the Darwin sources released for OSX (..
not talking about dormant PureDarwin project)

------
blanket_the_cat
This is awesome. I've been building almost the exact same project, along
almost the same timeline (based on the commit history). Mostly an excuse to
learn more advanced Bash, and Linux Internals/Features I've never had a good
excuse to explore. Gonna release next week. Hope I get as warm a reception.
Kudos on an awesome project!

------
rijoja
I am following this guide to build a kernel. But it seems like that instead of
getting the headers from the kernel source they are using a github repository
which only contains the headers to save downloading time. All fine and dandy
if the latest commit to this repo wasn't from 3 years ago!!

------
peterwwillis
I remember when HOWTOs were actually maintained over time so their
instructions were up to date. Blogs killed HOWTOs.

------
agumonkey
Let's branch to add : sysvinit/BSD, init, OpenRC, upstart, systemd, SMF,
launchd, Epoch, finit ..

[https://wiki.gentoo.org/wiki/Comparison_of_init_systems](https://wiki.gentoo.org/wiki/Comparison_of_init_systems)

------
felixsanz
Awesome! Good job. This also helps understand what the distro installer does.

------
colemickens
Seem neat to learn, but for something maintainable, LinuxKit seems
interesting.

------
ausjke
This is an awesome write-up. did not know losetup can do what kpartx does now
with the option -P, I did similar things in the past but this is a good update
for me.

------
Jaruzel
I've crashed and burned a couple of times trying to complete LinuxFromScratch,
so I may give this a go - It seems a bit clearer on the core steps.

------
apeacox
Well, I'd use [http://linuxfromscratch.org/](http://linuxfromscratch.org/) for
that matter...

~~~
agumonkey
LFS is infinitely more involved and am not sure for good reasons. I don't like
to say it because it's someone else project but I feel important parts are
missing, format is wrong, and without BLFS the goal is only half realized.

------
Siecje
Has anyone used Tinycore Linux?
[http://tinycorelinux.net/](http://tinycorelinux.net/)

------
akavel
Would be cool to port this to Nix package manager machinery (i.e. make this
kinda an alternative to NixOS).

------
Ericson2314
I feel like just reading Nixpkgs is probably just as edifying, tbh.

------
faragon
Beautiful.

------
airswimmer
I don't think this is much useful. You should check out the
linuxfromscratch.org

