Page 1 of 1

Custom kernel linux

Posted: Mon Sep 05, 2016 8:55 am
by hatsu
hello everybody,
I am coming here because I've many problems.

many months ago, with a friend, we started to program a kernel.
Finally, after exploring the basic kernel programming, we chose to use a basic kernel Linux to develop our own OS.

But when we boot this kernel there are too few commands and we need especially fdisk to create a new partition and install the kernel.
We would like to know how to edit a kernel Linux to implement some commands before compiling. (Example: fdisk, gcc, etc...).

Cordially,
Hatsu

Re: Custom kernel linux

Posted: Mon Sep 05, 2016 9:58 am
by Schol-R-LEA
None of those utilities are actually in the kernel itself, or strictly speaking the operating system at all. Nor are the shell interpreters, for that matter; if you are able to get a shell prompt, then you have already done everything you need vis a vis running a simple kernel, and you now need to install some applications - such as the GNU core utilities (fdisk, chmod, etc.), the binutils development toolchain (ld, gas. etc.), the Gnu Compiler Collection, and a simple editor such as nano.

While these are almost invariably bundled with the Linux operating system (that is, the kernel and set of drivers to let the kernel speak to the peripheral devices), that bundling is done by the distribution managers; those things aren't actually part of Linux, even if they are all needed to make Linux usable. The same is true of Windows and Mac OS, actually, but since they only are available as their manufacturers' bundled distribution, you would never normally see a Windows system without the desktop manager, for example (though the server versions can actually run without it). This is the main practical effect of Linux being FOSS for most users: they can get their toolchains a la carte, as it were, and pick the distro that sucks in the least painful way (every OS sucks, they just don't all suck the same ways).

I recommend reading through the OS-Dev Wiki, as you seem to have missed some important information. Also, you might want to look towards the Linux From Scratch project, since that's basically what you're doing even if you are modifying the kernel.

<boilerplate type="wiki links">
Getting Started
How To Ask Questions
FAQ

Required Knowledge
Beginner Mistakes (the "deadlines" section in particular)
What order should I make things in
Code Management

How kernel, compiler, and C library work together
Using Programming Languages other than C

Real Mode, especially the section on memory addressing, and Segmentation
Memory Map, Detecting Memory and A20 Line
BIOS, and Boot Sequence
Interrupts
Bootloader and Rolling Your Own Bootloader
FAT and SFS

While this is a lot of reading, it simply reflects the due diligence that any OS-devver needs to go through in order to get anywhere. OS development, even as a simple project, is not amenable to the Stack Overflow cut-and-paste model of software development; you really need to understand a fair amount of the concepts and principles before writing any code, and the examples given in tutorials and forum posts generally are exactly that. Copying an existing code snippet without at least a basic idea of what it is doing simply won't do. While learning itself is an iterative process - you learn one thing, try it out, see what worked and what didn't, read some more, etc. - in this case a basic foundation is needed at the start. Without a solid understanding of at least some of the core ideas before starting, you simply can't get very far in OS dev.
</boilerplate>

Re: Custom kernel linux

Posted: Mon Sep 05, 2016 11:38 pm
by Boris
Hi,
If you want to have simples commands available after your kernel has booted, I suggest you to use an Initial Ram Disk containing Busy box.
You should be able to get compiled binaries of it for many platforms..

Here is a tutorial that will help you.
http://jootamam.net/howto-initramfs-image.htm

Re: Custom kernel linux

Posted: Tue Sep 06, 2016 3:35 am
by FusT
You seem to be mixing some concepts, as Schol-R-LEA points out.
Linux is the actual kernel (the thing you've got booting now) and doesn't contain any of the software you're describing. It is an OS kernel that handles memory access, device access (through drivers), etc. and nothing more. (See the wikipedia article on kernels)

The software you want to use on top of the Linux kernel is mostly GNU-software

The combination of these two, "Linux" as many people know it, is actually the Linux kernel + GNU and is distributed in distributions (hah! what a surprise!) like Ubuntu, Mint, Mandriva, etc.

You could in fact use GNU software on top of another UNIX kernel (or any other POSIX-compatible kernel for that matter) like the one in Apple's OSx or Minix.

Re: Custom kernel linux

Posted: Tue Sep 06, 2016 6:44 am
by MichaelPetch
FusT wrote:The combination of these two, "Linux" as many people know it
However, the combination of those 2 things should be referred to as GNU/Linux.

Re: Custom kernel linux

Posted: Tue Sep 06, 2016 7:58 am
by jojo
Oh, hey, Stallman. I didn't know you posted here.

Re: Custom kernel linux

Posted: Wed Sep 07, 2016 6:31 am
by FusT
MichaelPetch wrote:
FusT wrote:The combination of these two, "Linux" as many people know it
However, the combination of those 2 things should be referred to as GNU/Linux.
That was indeed the point I was trying to make. Thank you for further clarifying it.