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 :)

The Beast
  • 373
  • 1
  • 7
  • 20
  • 2
    Have you seen this http://www.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. – Steve Robillard Dec 04 '15 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 Dec 04 '15 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 https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8&client=ubuntu#q=realtime+OS+for+raspberry+pi – Steve Robillard Dec 04 '15 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 Dec 05 '15 at 02:04

3 Answers3

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.

goldilocks
  • 58,859
  • 17
  • 112
  • 227
  • thanks @goldilocks ... it will take for me a lot of time to understand this ... what i mean by the performance it to make the OS more real time so for example disabling some running stuff : applications and services that i will not need like using msconfig command in windows .... So building from scratch will take a lot of time and it's not worth it ... , In the other hand i have found the BUILDROOT tool to customize my image using cross-compilation : that seems interesting ... what do you think ? – The Beast Dec 04 '15 at 21:31
  • 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 Dec 04 '15 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 Dec 04 '15 at 21:47
  • so you are telling me that the raspbian or any other other distribution that can be used with the raspberry is already effective and efficient and i can not done anything else to improve it or re-tune it ? for the performance issue maybe i haven't been good to describe the problem but i was thinking about turning off unwanted services like shown here [link] (http://www.tecmint.com/remove-unwanted-services-from-linux/) ... i know that some softwares have nothing to do with memory usage but some others does ... – The Beast Dec 05 '15 at 01:55
  • what i really need is to reduce the cpu consumption for example by removing the graphical interface for exp ... – The Beast Dec 05 '15 at 02:00
  • 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 Dec 05 '15 at 03:17
  • by using the configuration file .... where can i find it ? – The Beast Dec 07 '15 at 12:46
  • 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 Dec 07 '15 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 Dec 07 '15 at 12:58
  • ok now i have read them the init is the first and the latest task launched in linux and it launch the others task too , for the suystemd is an alternative to systemV (that uses init) but it's very recent i don't know if i'm gonna use it – The Beast Dec 07 '15 at 13:26
  • 1
    It's been around longer than the pi has, it is just that Debian didn't start using it until this year -- and while you sort of have a choice at this point (primarily by sticking with wheezy and not upgrading, ever) -- it will get harder and harder to stick with. Anyway, currently the update.rc-d lightdm... might work regardless of which one is being used, – goldilocks Dec 07 '15 at 14:55
  • 1
    Note that systemd and sysv are both implementations of an init system, so "init" is abstract in that sense. There is not an init program used by both of them; they are different versions of an init program. You can use almost anything in place of them, although what will happen will not be desirable in most cases ;) E.g., you could use bash (the shell) for init, in which case you just boot to a single shell prompt and there is nothing else. – goldilocks Dec 07 '15 at 14:56
3

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

Diederik de Haas
  • 809
  • 8
  • 12
  • what do you mean by minimal system ? : so after installing it i must install all things that i'm gonna need – The Beast Dec 04 '15 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 https://github.com/debian-pi/raspbian-ua-netinst#installer-customization for details.
    – Diederik de Haas Dec 04 '15 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 Dec 05 '15 at 01: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. – Diederik de Haas Dec 05 '15 at 02:08
  • so for example for networking how to know what package i need !!! any hints – The Beast Jan 11 '16 at 03:27
  • Have you even read the README? In https://github.com/debian-pi/raspbian-ua-netinst#intro you can see that the server preset (=default) gives you an SSH server and NTP and those are pretty useless without networking. In that same section of the documentation you can also read that only the 'base' preset doesn't have networking (and thus no ssh server or ntp). But if you change the preset option, it is expected that you know what you're doing and thus figure out which packages you need if you want 'base' with networking. – Diederik de Haas Jan 12 '16 at 10:23
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.