How to build an OS from Linux Kernel?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
vishwadeep86
Posts: 1
Joined: Fri Aug 21, 2015 3:21 am
Libera.chat IRC: vishwadeep86

How to build an OS from Linux Kernel?

Post by vishwadeep86 »

i have seen lot of questions on this topic, but i am just starting in this field as an interest and a basic project. I am familiar with Linux, Shell Scripting, C, C++, Perl, Tcl.

I am just looking to learn to build an OS.

Question 1 :Can i build a basic OS using Linux kernel? It definitely must be possible, but where to start in a simple way? How much work it will take? Motto is just to build a simple OS which should boot and hold text files and rename/copy/move/edit is allowed with no directory structure. Is this the minimum i can think to start a small project?

Question 2 : I have one Desktop, i will create a partition to that system (suppose for 20-30GB) and start working on it for writing OS. This plan looks Ok in context of not putting rest of the data on risk?

Question 3 : What if i want to alter kernel only (just to learn) and want to use already built distro to make new distro? Is it possible? Yes i think this should also be possible, but where to start? Is it simpler than the other way around as in Question 1?

Question 4 : How can i play more with Linux/Unix? You all might be having more cool ideas?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: How to build an OS from Linux Kernel?

Post by Combuster »

1: You can build off the Linux kernel. The process is called Linux From Scratch, you should search that term.
2: Mistakes are human, and forever remain human.
3: You probably need a very good plan of what you want before you edit the kernel itself. It's a huge thing of its own.
4: Installing Gentoo (in a VM, perhaps, considering point 2) is a pretty good training excursion for those who want to be better than a desktop simpleton.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
FusT
Member
Member
Posts: 91
Joined: Wed Sep 19, 2012 3:43 am
Location: The Netherlands

Re: How to build an OS from Linux Kernel?

Post by FusT »

Question 1 :Can i build a basic OS using Linux kernel? It definitely must be possible, but where to start in a simple way? How much work it will take? Motto is just to build a simple OS which should boot and hold text files and rename/copy/move/edit is allowed with no directory structure. Is this the minimum i can think to start a small project?
The linux kernel is an OS, you would be building your own Linux distro.
Question 2 : I have one Desktop, i will create a partition to that system (suppose for 20-30GB) and start working on it for writing OS. This plan looks Ok in context of not putting rest of the data on risk?
Not sure what you want to do here
Question 3 : What if i want to alter kernel only (just to learn) and want to use already built distro to make new distro? Is it possible? Yes i think this should also be possible, but where to start? Is it simpler than the other way around as in Question 1?
See the first answer.
Question 4 : How can i play more with Linux/Unix? You all might be having more cool ideas?
Depends on what you mean by "play". Since Linux is open-source you could pretty much do anything from writing your own TCP/IP or USB stack to writing a window manager (like X).
but then again, why would you? Just to learn, sure. But there are better ways to do so (write your own text editor/web browser/etc.)
User avatar
bace
Member
Member
Posts: 34
Joined: Fri Jan 16, 2015 10:41 am
Location: United Kingdom

Re: How to build an OS from Linux Kernel?

Post by bace »

FusT wrote:
Question 1 :Can i build a basic OS using Linux kernel? It definitely must be possible, but where to start in a simple way? How much work it will take? Motto is just to build a simple OS which should boot and hold text files and rename/copy/move/edit is allowed with no directory structure. Is this the minimum i can think to start a small project?
The linux kernel is an OS, you would be building your own Linux distro.
Actually, the Linux kernel is just a kernel. Only when you pair it with something like GNU you get an OS.
"for example, turning off the system’s power through the movement of a large red switch" - the Advanced Configuration and Power Interface Specification
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: How to build an OS from Linux Kernel?

Post by iansjack »

FusT wrote:The linux kernel is an OS, you would be building your own Linux distro.
A kernel is rarely an operating system all by itself. For example, a micro-kernel relies on several user programs as well as the kernel itself. Even the Linux kernel relies strongly on modules which are added on to the kernel. And any reasonable interpretation of the term "operating system" would include at least those basic utilities necessary to get the system running and communicate with the outside world.
User avatar
Schol-R-LEA
Member
Member
Posts: 1925
Joined: Fri Oct 27, 2006 9:42 am
Location: Athens, GA, USA

Re: How to build an OS from Linux Kernel?

Post by Schol-R-LEA »

I am not entirely certain if your goal is to write an operating system that uses the Linux kernel as its kernel but with a different user interface, file system, et. al., or if you are looking to develop a different OS from the ground up using Linux as your development platform. In the absence of more information, I will assume you mean the former.

To start with, I would recommend starting by reading the Beginner's Information pages in the OSdev wiki, especially Introduction, Required Knowledge, Beginner's Mistakes, and How to Ask Questions. That will give your the foundation needed to understand the scope of an OS project, if nothing else.

From question 4, it sounds like you don't have Linux installed yet, and presumably you are using an existing Windows installation as your base system. Given that, I would say your best bet is to get a virtualizer (I recommend VirtualBox) and create a virtual disk installation of the Linux distribution of your choice (you might try asking for advice on this if you don't have one in mind, but expect to get dozens of different opinions on the subject; I use Gentoo, with XFCE on one machine and Enlightenment on another, but YMMV). This will let you avoid re-partitioning your drive, and will make it easy to have several different installations in place.

If you are starting from a bare disk, I would recommend installing a hypervisor such as Xen instead, which will let you work with Windows and Linux on an equal footing.

I can't really give any more advice past this, not without more information from you at least. I hope this gives you a starting point, though.
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.
FusT
Member
Member
Posts: 91
Joined: Wed Sep 19, 2012 3:43 am
Location: The Netherlands

Re: How to build an OS from Linux Kernel?

Post by FusT »

A kernel is rarely an operating system all by itself. For example, a micro-kernel relies on several user programs as well as the kernel itself. Even the Linux kernel relies strongly on modules which are added on to the kernel. And any reasonable interpretation of the term "operating system" would include at least those basic utilities necessary to get the system running and communicate with the outside world.
I stand corrected, excellent explanation.
Post Reply