4

I'm using Raspbian with raspberry pi 2 ... But i want to customize it and remove some features that i don't really need , to take advantages on the performance and also to understand the procedure of OS installation , so how can i do that:

  1. I found that i must compile the kernel from scratch but this would take me a long time to understand the whole process
  2. How to start building Raspbian but with more configuration options ...
  3. I'm just newbie to embedded linux ...

Any help will be appreciated :)

4
  • 2
    Have you seen this cl.cam.ac.uk/projects/raspberrypi/tutorials/os. note that this may not work on a Pi 2. it predates its release. Also, no matter how much you tune it you will not make this into a high performance computer; in the same way you can't turn your daily driver into a supercar - no matter how much you tune it - you are ultimately limited by the underlying hardware. Commented Dec 4, 2015 at 14:20
  • @Steve Robillard but i still can re-tune it to what i need ... maybe by making the OS more real time ?
    – The Beast
    Commented Dec 4, 2015 at 21:16
  • 1
    First, removing things is not how to make a realtime OS. Second, you want to build your own OS, but "compiling the kernel from scratch would take a long time." As part of building an OS is compiling how long do you expect learning to create your own OS to take? Perhaps this google search might help google.com/… Commented Dec 4, 2015 at 21:31
  • yes that is another way to do so by usning an RTOS but i want to use something based on debian ... that means by reconfiguring raspbian to my needs .... for example the camera library that i have found to attach it to the raspberry work only in debian based distribution ... so i don't want to have to make the library my own again for another distribution ... have you undertand what i mean or am i wrong !!!
    – The Beast
    Commented Dec 5, 2015 at 2:04

3 Answers 3

8

to take advantages on the performance

This begs the question that the people who put "an existing OS" together were not concerned about performance, or that you understand it better than them (in which case you would not be asking this kind of question -- I'm not trying to belittle you, just stating the obvious). If people approached their cars the way they sometimes approach computers, we'd see a lot of stuff left up on blocks in the driveway and more blue smoke on the highways.

If you want to learn stuff, great. If you want to pretend you are going to supe up your Chevy the day you buy your first wrench, stop now. It is not a good mindset for trying to understand how something works. IMO.

I found that i must compile the kernel from scratch but this would take me a long time to understand the whole process

You don't have to unless you have a particular reason to. Configuring and compiling the kernel is pretty tedious stuff. I'm glad I know how to do it from time to time, but there's not a lot to learn coming at it that way. In fact I'd call it a complete waste of time in terms of educational value. None-the-less:

Configuring, compiling and installing a custom Linux kernel

Kernel .config necessary options

Install Custom Kernel

But instead, my advice if you are interested in how the operating system works (you will need to understand stuff like that before you set out creating one) is to learn about the init system. On current versions of Raspbian that is systemd. After you read those two things, you are ready to get a little more in depth; have a look at the Fedora wiki, since they were the ones who introduced it, and, since they provide the best documentation of any linux distro, the Arch wiki.

Debian, which Raspbian is a variant of, also produce some good documentation. This page is a decent explanation of what "init" is and an introduction to systemd "service files". Note pi OS's don't use an initramfs (they could, but there would not be much of a point since they require a custom kernel anyway,1 see #4 in the answer to that "Configuring, compiling, and installing..." question).

Beware there is a lot of stuff around about SysV init and the raspberry pi. This refers to /etc/init.d and scripts that run from there, and commands like update-rc.d (we have a lot of that here). While systemd supports this for backward compatibility, skip learning about it. It is history, and it is not coming back. You will see these two things distinguished in most of the above articles (in fact the fedora one is sort of for people who've got to know SysV -- this applies now to Raspbian, since it just switched over).

Also beware of falling into the trap of constantly including "raspberry pi" in your searches. A lot of people seem to believe linux and debian were invented yesterday for the raspberry pi, and/or that the raspberry pi represents some significant proportion of contemporary linux systems, and/or that there is something special about the Raspbian OS. All three of these things are very, very false. What's worse, some of these people have written atrocious blogs trying to explain things that have already been explained better elsewhere. I believe some of them do this literally because they figure recontextualing it in terms of the "raspberry pi" will help get them in google, since otherwise it would just be redundant, often poor quality, regurgitation.

There are also some very good pi pages around; it's up to you to decide between them (that's the internet). When in doubt, ask about it here. Questions such as "I read [this] [here] about the Pi. Does that mean _______?" are usually totally appropriate here, or on U&L.

The major hassle about learning how init works is it will require a lot of rebooting -- but then, so does compiling the kernel, and it is usually much more inscrutable when it does not work. The pi is sort of handy this way since you can easily sit with a laptop or whatever at the same time. Init systems are complex and may take a long time to understand, but if you want to start seriously customizing things, you can't pass go without it.


1. Although getting one to work to use to switch between operating systems, as I suggested here, would be a great educational project. Just be warned that starting from scratch, if you study this stuff full time, it will take you months to work out properly.

12
  • 1
    Beware the XY problem! Particularly here, as there are rabbit holes you could fall into for a long time before realizing you kinda wasted it. This is why I mentioned the performance chimera. A misconception people commonly have is that "all this software is slowing my system down" or "it occupies the memory". The last one is more complicated than the first one, but short story: if you aren't using it, it isn't doing anything (it often is on a smartphone, but not the pi).
    – goldilocks
    Commented Dec 4, 2015 at 21:47
  • 1
    You certainly won't turn it into a real time system by pulling out user software; since the OS is multitasking, most of the things that may interrupt for a few milliseconds are actually kernel things. Kernels are insanely complex and have to juggle a lot just to provide us with a platform where all the other stuff can play nice. Anyway, my point about XY is if you are doing something specific and feel there is a performance or time granularity issue, ask about it specifically. There may or may not be anything you can do.
    – goldilocks
    Commented Dec 4, 2015 at 21:47
  • 1
    I'm not saying they are perfect. That article is ok as far as demonstrating some basic things go, but it is not going to measurably improve the performance of anything. The stuff about chkconfig and inetd was outdated years ago, which is a bad sign since the article is dated 2015 -- anyway, it very much focuses on init services. WRT the GUI, this is a great example of what I meant by the XY problem. If you want to disable it from starting by default (you don't need to actually remove it), then ask how to disable it from starting (it's an init service/profile again).
    – goldilocks
    Commented Dec 5, 2015 at 3:17
  • 1
    It's not a configuration file. Init's a program started by the kernel (the only program ever started by the kernel) and it is always running (you cannot really stop it). I think on jessie you should be able to turn the GUI off with sudo systemctl set-default multi-user.target, presuming Raspbian hasn't done something screwy. On wheezy I think it is a little more complicated but try update.rc-d lightdm disable S 2 3 4 5 and see if that works.
    – goldilocks
    Commented Dec 7, 2015 at 12:58
  • 1
    You do need to read those first couple links (the "init system" wikipedia article and the "systemd" one from the next sentence) if you want to have any hope of customizing the system beyond just copy pasting from potentially very wrong/inappropriate articles on the web...
    – goldilocks
    Commented Dec 7, 2015 at 12:58
3

You could consider using the Raspbian NetInstaller to install a minimal system and build your system up from there.

6
  • what do you mean by minimal system ? : so after installing it i must install all things that i'm gonna need
    – The Beast
    Commented Dec 4, 2015 at 21:35
  • Correct. It only contains the bare essentials to have a running system and an SSH server so you can login remotely. It doesn't contain X or any graphical tools/programs/etc. If you want them, you have to install them yourself. By using configuration files you can install additional packages during the (initial) install. See github.com/debian-pi/… for details. Commented Dec 4, 2015 at 21:55
  • i must know what the packages i need and their dependencies first ... it seems interesting i will try it and compare the result
    – The Beast
    Commented Dec 5, 2015 at 1:47
  • 1
    You only need to figure out the packages you want/need. APT (apt-get/aptitude) will figure out the dependencies and install them for you. Commented Dec 5, 2015 at 2:08
  • so for example for networking how to know what package i need !!! any hints
    – The Beast
    Commented Jan 11, 2016 at 3:27
2

I recently wrote a post on how to compile a kernel for the Pi using ELLCC. http://ellcc.org/blog/?p=26435 Although that blog post explains building for the Raspberry Pi B+ specifically, I've subsequently build a kernel for the Raspberry Pi 2 using the same technique. I'm putting together a 0.1.24 release of ELLCC that will make the process even easier.

13
  • i never heard of ELLCC but i will try it and let you know ... thanks
    – The Beast
    Commented Jan 11, 2016 at 3:29
  • @Frankenstein: I have an updated blog post that has some more information: ellcc.org/blog/?p=26595 Commented Jan 11, 2016 at 5:02
  • please can i use your method to choose wish module to keep or to remove in the installation process ?
    – The Beast
    Commented Jan 14, 2016 at 2:02
  • Yes, check out ellcc.org/blog/?p=26628 You can specify what userland stuff to include by editing the 'build' file. It you want to control what kernel modules to include, you need to do a 'make menuconfig' in e.g. the arm-linux-engeabihf/bcm2709/ directory. Commented Jan 14, 2016 at 2:59
  • 1
    Easy. After you do an initial build which gets the Linux source downloaded, cd to the arm-linux-engeabihf/bcm2709 directory where the Linux kernel source is (Or something similar, I'm not at my system right now). You can do a "make menuconfig" in that directory to configure the kernel. Commented Jan 15, 2016 at 20:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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