Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am doing Under Graduation in CS Major, have medium level knowledge in C, C++, and Java and also learned some operating system concepts (as they are in my course syllabus). I have heard that we can customize Linux (say Ubuntu) as we wish by changing its source code and can make whole new OS. I have downloaded source code of linux kernel from www.kernel.org website. But by seeing it.... I am not able to understand anything, there is so many directories, ... files within files (as I think there would be one single large programme). I want to do this as college project also and I want to contribute to linux by making necessary change in it. But after asking this question on some of the site... they said that linux source code is very huge. You may try minix. Now I am very much confused.

Please give me suggestions with detail that how should i start this journey (of changing source code to customize linux) with necessary steps, along with some beginner level books.

I am sorry if I have done any mistake and thanks in advance.

share|improve this question
    
What is your goal? How would you like to contribute? –  Spidey Jun 25 '12 at 14:03
    
To make my own custom O.S. by changing its(linux) source code...and to learn how O.S. works and for fun also –  dubex Jun 25 '12 at 14:16

4 Answers 4

I think the first thing you need to define is "what are the changes you wish to bring to the OS". Until you decide this, you won't really get anywhere. There is no "one path" of learning.

Furthermore, I think you should define better what you mean by OS. A big part (a major part) of the Ubuntu source code is outside of Linux. Linux is only the kernel, (it is sometimes referred to as Operating System, especially in academic circles, hence the confusion), and therefore it has the "simple" job of:

  • managing resources.
  • communicating with the hardware.

Any other change would happen on a different level, whether it's the core userland utilities (often referred to as utils), the GUI, the basic apps of a distro, etc.

If however, you're still set on learning how to hack on the kernel, you should maybe start with this question, the highest voted question on this site ;)

share|improve this answer
    
sorry for not so specific in asking question...but in reality i have no idea about all this in detail. Actually i want some type of animation (with sound) on screen when linux(say ubuntu) is booting...please give me idea about exploring all this fields and how to move further in any specific field( say gui with communiting with the hardware)... –  dubex Jun 25 '12 at 14:36

Welcome to unix.stackexchange.com!

There's no easy answer to your question, and far better people than me have written entire books on the subject of the Linux kernel and operating systems in general.

About the scope of the project: writing an operating system is not a simple task! Even a purposefully minimal OS like Minix is a pretty complex thing! To give you an idea about Linux, think about the C programs you've written so far. The average university coursework tends to be a few thousand lines of C at most. I think my final year project was around 30–35,000 lines of C++. The Linux kernel is roughly 13,000,000 lines of C code.

Why is it all in separate files? Sizeable projects are stored in separate files for logistical and practical reasons. Just considering loading a 13,000,000 line file into an editor! Before tackling a huge project like Linux, you should definitely hone your C skills to the point where the ‘why multiple files’ question answers itself. You should also be able to read C code, not just write it. (harder than it seems at first)

You should definitely be very proficient in C. The kernel is maintained by thousands of people, and you'll be called to understand the personal C idioms of each of them (granted, within the fairly rigid kernel coding standards, but still — everyone has their own problem-solving style).

After you get your C fu, make sure you understand operating systems. This will help you understand the code. Not all of Linux is essential. The kernel proper is pretty small! What bloats it is:

  • Thousands of hardware drivers for various devices.
  • Abstraction layers for various device classes to simplify APIs and driver writing. E.g., we have the VFS for filesystems, the Event layer for input devices, et cetera.
  • Shocking amounts of conditionally compiled code and files catering to the various architectures that run Linux (not every Linux machine is an Intel PC, and some are incredibly different from what you might expect). The kernel has to deal with these differences, and that means more code.

One problem you'll find immediately is that these components aren't so easy to unplug, change and plug back together again. There are numerous interrelations. In short, changing bits of the kernel is tricky.

The reason people suggested Minix to you is simple: it's a full operating system, but it's not burdened by the needs of a system as complex as Linux. The code is small, but still provides full functionality. After all, the first versions of Linux were inspired by Minix.

Sure, Minix has less hardware support these days. So what? That's a boon! Modern computers virtualise very well. Use that to your advantage: a VM to run Minix is so light, it'll make development a dawdle.

If your project is to build an operating system, you could do worse than to start by studying Minix. You may also want to buy and read the book Minix was written to accompany, ‘Andrew Tanenbaum's Modern Operating Systems’.

You should also set your targets and define your terms precisely. If your own definition of an OS is Microsoft's (an OS with a GUI and a full software suite), you may be in for a very long project! Hundreds of thousands of people have worked since the 1960s to bring us where we are now, after all.

Finally, remember the Computer Scientist's battle cry: ‘never reinvent the wheel!’ (we like to make exceptions when learning, of course. And for fun :) )

share|improve this answer
1  
would [link](www.linuxfromscratch.org) full fill my dream...thanks for showing interest my question –  dubex Jun 25 '12 at 15:15
    
LFS is fantastic for learning how the userspace of a POSIX system works. As far as I know it's Linux-specific, so it doesn't deal with modifying the kernel in an unusual direction (as you would when making your own kernel). But it's besides the point, because once your kernel moves away from POSIX, the userspace will be incompatible and will have to be ported or reimplemented. –  Alexios Jun 25 '12 at 16:48
    
Sorry for misunderstanding...But i did't mean that i will make my own kernel(as i am not much talented :)). I want to make change in source code that it can look different from others and looks like that is my own creativity. For example: I would want some type of animation with sound(that i have made), on screen when linux(say ubuntu) is booting with some voice recognization software installed in it. Once again thanks. –  dubex Jun 25 '12 at 18:37
    
In that case, you're making your own distribution of Linux, and not a different operating system. LFS is the right tool for that. Good luck! –  Alexios Jun 25 '12 at 18:59
1  
@Alexios, very good and descriptive answer, thanks. –  0xAF Jun 25 '12 at 21:09

Check Linux From Scratch project. As the name suggests it contains all the details needed to build your own Linux distribution

share|improve this answer

This might be a bit beside the point, but if you wish the learn about the Linux kernel and start to develop it you should really look into kernel newbies. It's a site that gives you insight into the kernel mechanics (like Alexios did in an excellent way), but also let's you pick a small task to handle (being a so called kernel janitor). It's a great way to learn, and I highly recommend it!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.