Curious: How is a Linux created?

Hey guys, out of curiosity because I want to learn:

What is the process of creating a new Linux OS from the base up? What I’d do so far is to build a new OS following Linux from Scratch and once that is done, create an ISO from the existing system. Is this a good/common approach?
I don’t want to actually make a new OS, I’m just playing around while trying to learn.
Thanks :smile:

1 Like

LFS is definitely best place to learn full experience…
I bet none of us have courage to try it though :rofl:

6 Likes

Very top level basic instructions for Archlinux ARM

With a script, first we partition and format a storage device. We use a loop device

Then we use pacstrap that will read from a text list what packages we want to install on the storage device. Including the kernel, kernel headers, and every thing needed to create a rootfs.

Then the script chroots into the rootfs image and does configuration, etc,

Finally the completed loop device image is compressed into an xz image.

Then the user downloads the xz image and runs a script to install the image on a uSD, eMMC, or USB SSD.

Connect the uSD, eMMC, or USB SSD to the ARM device and boot it up.

As stated earlier, very short and basic overview.

If interested, here is the github url

Basically the build-configs folder, the configs folder, the eos-arm-build script, and the eos-arm-chroot script are used. The rest are deprecated and need to be moved to an archive repository.

Pudge

2 Likes

80% alcohol. 50% community 50% sheer determination to make something that didn’t exist and 75% of all after dark hours globally.

11 Likes

Thank you! This is, however, assuming that there exists a base operating system (Arch in this case), right?

Correct. Not many would try to create a totally new distribution by themselves.

Pudge

Since you said Linux Operating System … at it’s simplest you need to build a kernel with the required drivers compiled in, no modules, build a file system, image and boot the kernel and tell it to use the file system as root.

You need to decide which programs you want in your base filesystem image. Think small. Simple setup would just be serial or PC virtual console, single user, no login, not networking, no graphical UI, minimal tools, just 1 file system, find an alternate /etc/init which is very basic. Just the base setup of tools to boot up the operating system and look around a file system, so a shell, ls, cp, mv, ps maybe, doesn’t have to be much for a proof of concept. You just install the file system heirarchy into a file system, and boot the kernel telling it to use that file system, for which you have already compiled the driver into the kernel.

Or you could look at one of the existing initrds as a initial minimal file systems, and just boot a kernel with that. Still some integration work, as you would have to stop it trying to setup and mount a normal root file system, but if you hardware the kernel cmdline break or rd.break options on, depending on the initrd, then you will have a kernel running a file system.

After you have a base system booting, then it is all about defining what you want, and deciding how to go about it, and that is where it gets complicated. LFS has all the parts, you just need to decide how to put them together and maintain them in an ongoing manner.

You might want to try building and understanding minix, it used to be a small linux/unix like system, although I haven’t used it since the days of 1.2/1.44MB floppies.

Or you might like to start by building your own linux kernel image, and get an idea of the complexity your will need to handle if you hope to build it up to an equivalent of todays linux kernels and linux operating systems.

2 Likes

I’m no dev or programmer, but I can provide the alcohol

There’s no way you could afford it. You’d have to be a Pharaoh, King, top 10 CEO or something absurd where money is no object. And even then I’m sure they could drink you broke in short order.

Bro I live in the Philippines. Good rum is dirt cheap :rofl: bottomless rum on me! :clinking_glasses:

Yes, that is exactly how you should do it. Pretty much every non-derived Linux distro began like that. LFS is just a tutorial that guides you through the process step by step.

If you are patient and have the time, by successfully completing LFS, you’ll end up with a functional Linux-based OS. It won’t be a distribution, though: it won’t have any package management. In order to make it a Linux distribution, you’ll have to come up with some sort of a package management system. The simplest one would be something like what Gentoo does.

2 Likes

The EvolveOS or now solus … he started first with debian as base solus 1 solus 2 started never came, years later, he started with LFS and revivided older packagemanager… for me is kinda pumped up :stuck_out_tongue: i pretty noob… most do LFS + pacman but yes free to do what you can do :slight_smile:

1 Like

Really helpful answer, thank you. This gave me lots of keywords to google and stuff to learn. Also a really nice overview. Appreciated :smiley:

And thanks to @Kresimir @ringo as well

1 Like

If you want an example of a current, but small installation, OpenWRT builds a linux router os, and can install on, IIRC, 16MB flash and 64MB RAM. I run it on a couple of old Netgear WNDR3800s, which is a non-intel processor. I also run it on an X86_64 processor as my main firewall/router, and I think that install is 128MB with lots of free space. OpenWRT is very capable and very flexible, and looks superficially like a normal install, but the details are focused on the router side. Again, you can build a kernel, and and install image, and have then both cut down very much so more understandable, but the different focus is both good and bad for someone just starting to understand, and sticking to a desktop focus is probably better, but remember that linux runs from very very small microcontrollers up to the biggest supercomputers and maintframes, and all sorts of quirks in between. I have a USB card reader than when plugged into power boots OpenWRT and serves up the microSD over SMB/http/https over Wifi, that wasn’t the original intent of the manufacturer but someone hacked OpenWRT onto it. There are lots of interesting small systems in the embedded space, things like amazon kindle, or android are all linux on the inside.

1 Like

Thanks :slight_smile:

I’ve done LFS twice in my lifetime, both times successfully. While that is something noteworthy, the amount of girls I can impress with that is sadly lacking.

I can say however that the experience is more akin to following a cooking recipe to the letter. The amount of knowledge gained is low, I think. Take a training about linux, it will tell you much more about the system, the boot process, the file structure than LFS will.

3 Likes

Sir, you’re an absolute superhero! :rofl:
Why on earth you did it twice?!

I’m doing at the moment and have to say, yes, if you simply follow the instructions like a recipe you learn pretty much nothing. Instead I try to understand why I need to do what I’m copying and how it changes the system. I have to say, I’m just compiling modules right now (takes a while in a slow VM while I keep using the PC) so it’s getting a bit repetitive atm.

I had to realize that that’s the case with most computer nerd things I do. Gotta find yourself an equally nerdy girl :smiley:

1 Like

You learn much more by hacking things and breaking them and fixing them. The key is limiting the scope so you can concentrate on a few things, and not get buried in all the other details. I learnt a whole lot about grub last week, it had broken very strangely, and I will remember that, and the weird modules I tried to graft into it to get it to work. I still don’t know exactly what was the issue, but it works now, and I’ll post later my observations, and guesses, and see if anyone has any better ideas.

What??? No way! I thought those fellows over at the Arch forum are drowning in Anime girls!