Really small kernel

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Really small kernel

MR ZenWiz
Is it possible to build the ubuntu 18.04 kernel such that it will run
effectively with 64MB or less?

While I personally have no need for this, someone asked on Quora and
I'm curious now.

I don't think this is feasible, but....

Thanks.

Mark

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: Really small kernel

Liam Proven
On Mon, 28 Oct 2019 at 19:06, MR ZenWiz <[hidden email]> wrote:

> Is it possible to build the ubuntu 18.04 kernel such that it will run
> effectively with 64MB or less?

Kernel, yes.

Desktop, no.

But a bare install of Ubuntu Server or JeOS would probably work.

> While I personally have no need for this, someone asked on Quora and
> I'm curious now.

Oh? Where's that? Can't find it.

--
Liam Proven - Profile: https://about.me/liamproven
Email: [hidden email] - Google Mail/Hangouts/Plus: [hidden email]
Twitter/Facebook/Flickr: lproven - Skype/LinkedIn: liamproven
UK: +44 7939-087884 - ČR (+ WhatsApp/Telegram/Signal): +420 702 829 053

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: Really small kernel

MR ZenWiz
On Mon, Oct 28, 2019 at 2:52 PM Liam Proven <[hidden email]> wrote:

>
> On Mon, 28 Oct 2019 at 19:06, MR ZenWiz <[hidden email]> wrote:
>
> > Is it possible to build the ubuntu 18.04 kernel such that it will run
> > effectively with 64MB or less?
>
> Kernel, yes.
>
> Desktop, no.
>
> But a bare install of Ubuntu Server or JeOS would probably work.
>
> > While I personally have no need for this, someone asked on Quora and
> > I'm curious now.
>
> Oh? Where's that? Can't find it.
>
https://www.quora.com/Is-there-any-way-to-reduce-the-size-of-a-kernel-so-it-can-run-on-64MB-RAM-easily-Ubuntu-18-04-LTS

Feel free to give a better answer than mine.  I don't think this
fellow really understood his own question.

Mark

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: Really small kernel

ubuntu-users mailing list
In reply to this post by MR ZenWiz
28 October 2019  at 16:29, MR ZenWiz wrote:
Re: Really small kernel (at least in part)

>On Mon, Oct 28, 2019 at 2:52 PM Liam Proven <[hidden email]> wrote:
>>
>> On Mon, 28 Oct 2019 at 19:06, MR ZenWiz <[hidden email]> wrote:
>>
>> > Is it possible to build the ubuntu 18.04 kernel such that it will run
>> > effectively with 64MB or less?
>>
>> Kernel, yes.
>>
>> Desktop, no.
>>
>> But a bare install of Ubuntu Server or JeOS would probably work.
>>
>> > While I personally have no need for this, someone asked on Quora and
>> > I'm curious now.
>>
>> Oh? Where's that? Can't find it.
>>
>https://www.quora.com/Is-there-any-way-to-reduce-the-size-of-a-kernel-so-it-can-run-on-64MB-RAM-easily-Ubuntu-18-04-LTS
>
>Feel free to give a better answer than mine.  I don't think this
>fellow really understood his own question.

I thinj that Quora ran out of any good questions a long while ago, they all
"seem" to be from teens who want to justify their own position re behaviour
;-<)

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: Really small kernel

ubuntu-users mailing list
Hi,

a starting point is localmodconfig.

"B. Generated configuration
Tip: Plug in all devices that you expect to use on the system if using
this method.

Since kernel 2.6.32, the localmodconfig command will create a .config
file for the custom kernel by disabling any and all options not
currently in use by the running kernel at the time. In other words, it
will only enable the options currently being used.

While this minimalist approach will result in a highly streamlined and
efficient configuration tailored specifically for your system, there
are drawbacks, such as the potential inability of the kernel to support
newer hardware, peripherals, or other features. Note: Again, ensure
that all devices you expect to use have been connected to (and detected
by) your system before running the following command

$ make localmodconfig" -
https://wiki.archlinux.org/index.php/Kernel/Traditional_compilation#B._Generated_configuration

You probably want to fine tune the generated config. Do you want a slim
kernel that is still compatible with Ubuntu defaults? If yes, you
probably want to care that apparmor is enabled, if not you probably
want to disable audit, which results in apparmor disabled, too. There
might be other important config settings, too and perhaps even relevant
Ubuntu specific patches.

Assuming the kernel should just work with Ubuntu installs, but needs
not to support something such as apparmor (e.g. keep "snappy" in mind
before you decide if it's needed or not), you still should think about
to add one or the other hardware support manually to the config.

In short, it is possible to build very slim kernels, but you need to
read up on what is required for the infrastructure of the distro you
are using, if it still should be full compatible, OTOH you might not
need compatibility to the full infrastructure of the distro.

You also won't run "make olddefconfig" if you upgrade your kernel,
                            ^^^
using the tailored config, instead you perhaps could run
"make oldconfig" and to reply to each question manually.
        ^^
Even running "make oldconfig" might be suboptimal, since it still would
add some new features with upstream defaults.

To stay close to the original Ubuntu kernel configs, you could copy
such a config and run "make menuconfig", to disable everything you
don't need manually, but to stay with defaults, such as maybe some
selected Hz, PREEMPT or mitigation or what ever else settings. Note
Ubuntu provides different kernels by official repositories, the most
likely default all to the same mitigation settings, all most likely
support apparmor, but some might come with different Hz and PREEMPT
settings. The Ubuntu lowlatency kernel for example automatically boots
with "threadirqs".

Also take a look at
https://www.kernel.org/doc/html/latest/kbuild/kconfig.html and other
relevant kernel.org information.

You have got to do some homework, I doubt somebody will do it for you.

Regards,
Ralf


--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: Really small kernel

ubuntu-users mailing list
In reply to this post by Liam Proven
On Mon, 28 Oct 2019 22:49:06 +0100, Liam Proven wrote:
>On Mon, 28 Oct 2019 at 19:06, MR ZenWiz <[hidden email]> wrote:
>> Is it possible to build the ubuntu 18.04 kernel such that it will run
>> effectively with 64MB or less?  
>
>Kernel, yes.
>
>Desktop, no.

Indeed, probably parts of a base install could be kept very small,
especially when removing translations, header files, licenses, man
pages and maybe by reducing the amount of icons and fonts, maybe no
wallpaper at all, searching for the smallest possible init system,
installing only some libs of e.g. gcc or gtk. There's a big difference
between firefox and qutebrowser, fltk and gtk2 and while a Windows XP
alike environment such as jwm also has a very slim dependency chain,
the chain already is relatively bloated. Small solutions such as
busybox probably can't be used to replace dependencies of a graphical
environment. An example for installing sizes without a complete base
infrastructure and without all needed dependencies, but with headers,
translations and one or the other file that could be removed, followed
by the dependency tree of jwm:

(it doesn't matter what distro is used, the example is listed for Arch,
since it's closer to upstream, by not splitting packages in a way it's
done by Ubuntu, so it's easier to get an overview of complete sizes of
upstream projects, but the dependencies are still missing, too)

[rocketmouse@archlinux ~]$ pacman -Qi jwm firefox qutebrowser gnome-icon-theme gnu-free-fonts xf86-video-vesa xorg-server-common xorg-server busybox systemd systemd-libs gcc-libs glibc fltk gtk2 | grep -eName -eSize
Name            : jwm
Installed Size  : 323.00 KiB
Name            : firefox
Installed Size  : 190.04 MiB
Name            : qutebrowser
Installed Size  : 7.49 MiB
Name            : gnome-icon-theme
Installed Size  : 10.04 MiB
Name            : gnu-free-fonts
Installed Size  : 6.65 MiB
Name            : xf86-video-vesa
Installed Size  : 74.00 KiB
Name            : xorg-server-common
Installed Size  : 127.21 KiB
Name            : xorg-server
Installed Size  : 3.50 MiB
Name            : busybox
Installed Size  : 1440.00 KiB
Name            : systemd
Installed Size  : 21.38 MiB
Name            : systemd-libs
Installed Size  : 1824.00 KiB
Name            : gcc-libs
Installed Size  : 116.71 MiB
Name            : glibc
Installed Size  : 46.01 MiB
Name            : fltk
Installed Size  : 8.24 MiB
Name            : gtk2
Installed Size  : 34.18 MiB
[rocketmouse@archlinux ~]$ pactree jwm
jwm
├─libx11
│ ├─libxcb
│ │ ├─xcb-proto provides xcb-proto>=1.12
│ │ ├─libxdmcp
│ │ │ ├─xorgproto provides xproto
│ │ │ └─glibc
│ │ │   ├─linux-api-headers provides linux-api-headers>=4.10
│ │ │   ├─tzdata
│ │ │   └─filesystem
│ │ │     └─iana-etc
│ │ └─libxau
│ │   ├─glibc
│ │   └─xorgproto provides xproto
│ ├─xorgproto provides xproto
│ └─xorgproto provides kbproto
├─libxft
│ ├─fontconfig
│ │ ├─expat
│ │ │ └─glibc
│ │ └─freetype2
│ │   ├─zlib
│ │   │ └─glibc
│ │   ├─bzip2
│ │   │ ├─glibc
│ │   │ └─bash provides sh
│ │   │   ├─readline provides readline>=7.0
│ │   │   │ ├─glibc
│ │   │   │ ├─ncurses
│ │   │   │ │ ├─glibc
│ │   │   │ │ └─gcc-libs
│ │   │   │ │   └─glibc provides glibc>=2.27
│ │   │   │ └─ncurses provides libncursesw.so=6-64
│ │   │   ├─glibc
│ │   │   └─ncurses
│ │   ├─bash provides sh
│ │   ├─libpng
│ │   │ ├─zlib
│ │   │ └─bash provides sh
│ │   └─harfbuzz
│ │     ├─glib2
│ │     │ ├─pcre
│ │     │ │ ├─gcc-libs
│ │     │ │ ├─readline
│ │     │ │ ├─zlib
│ │     │ │ ├─bzip2
│ │     │ │ └─bash
│ │     │ ├─libffi
│ │     │ │ └─glibc
│ │     │ ├─libutil-linux
│ │     │ └─zlib
│ │     ├─freetype2
│ │     └─graphite
│ │       └─gcc-libs
│ └─libxrender
│   ├─libx11 provides libx11>=1.3.4
│   └─xorgproto provides renderproto
├─libjpeg-turbo provides libjpeg>=7
├─libxpm
│ ├─libxt
│ │ ├─libsm
│ │ │ ├─libice
│ │ │ │ ├─glibc
│ │ │ │ └─xorgproto provides xproto
│ │ │ └─libutil-linux
│ │ └─libx11
│ └─libxext
│   ├─libx11
│   └─xorgproto provides xextproto
├─libxinerama
│ ├─libxext
│ └─xorgproto provides xineramaproto
├─libpng
├─cairo
│ ├─libpng
│ ├─libxrender
│ ├─libxext
│ ├─fontconfig
│ ├─pixman
│ │ └─glibc
│ ├─glib2
│ └─lzo
│   └─glibc
└─librsvg
  ├─gdk-pixbuf2
  │ ├─glib2
  │ ├─libpng
  │ ├─libtiff
  │ │ ├─libjpeg-turbo provides libjpeg
  │ │ ├─zlib
  │ │ ├─xz
  │ │ │ └─bash provides sh
  │ │ └─zstd
  │ │   ├─zlib
  │ │   ├─xz
  │ │   └─lz4
  │ │     └─glibc
  │ ├─libjpeg-turbo provides libjpeg
  │ ├─libx11
  │ ├─jasper
  │ │ └─libjpeg-turbo provides libjpeg
  │ └─shared-mime-info
  │   ├─libxml2
  │   │ ├─zlib
  │   │ ├─readline
  │   │ ├─ncurses
  │   │ ├─xz
  │   │ └─icu
  │   │   ├─gcc-libs
  │   │   └─bash provides sh
  │   └─glib2
  ├─pango
  │ ├─libthai
  │ │ └─libdatrie
  │ │   └─glibc
  │ ├─cairo
  │ ├─libxft
  │ ├─harfbuzz
  │ └─fribidi
  │   └─glibc
  └─libcroco
    ├─glib2
    └─libxml2


--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: Really small kernel

Liam Proven
In reply to this post by MR ZenWiz
On Tue, 29 Oct 2019 at 00:33, MR ZenWiz <[hidden email]> wrote:
>
> Feel free to give a better answer than mine.  I don't think this
> fellow really understood his own question.

Thanks! I just merged it with another question about modern distros
for a PC with 64MB.

I tried TinyCoreLinux and it boots to the GUI no problem in a VM with
64MB of RAM.

--
Liam Proven - Profile: https://about.me/liamproven
Email: [hidden email] - Google Mail/Hangouts/Plus: [hidden email]
Twitter/Facebook/Flickr: lproven - Skype/LinkedIn: liamproven
UK: +44 7939-087884 - ČR (+ WhatsApp/Telegram/Signal): +420 702 829 053

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: Really small kernel

ubuntu-users mailing list
On Tue, 29 Oct 2019 16:51:03 +0100, Liam Proven wrote:
>I tried TinyCoreLinux and it boots to the GUI no problem in a VM with
>64MB of RAM.

So my guess (without doing any research) regarding busybox is wrong (
https://lists.ubuntu.com/archives/ubuntu-users/2019-October/298515.html
), see https://en.wikipedia.org/wiki/Tiny_Core_Linux and
https://en.wikipedia.org/wiki/Light-weight_Linux_distribution#Comparison
.


--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: Really small kernel

Oliver Grawert
In reply to this post by MR ZenWiz
hi,
Am Montag, den 28.10.2019, 11:02 -0700 schrieb MR ZenWiz:
> Is it possible to build the ubuntu 18.04 kernel such that it will run
> effectively with 64MB or less?
>
> While I personally have no need for this, someone asked on Quora and
> I'm curious now.
>
> I don't think this is feasible, but....

it definitely is ... even without recompiling the ubuntu kernel you
should be able to boot it in 64MB RAM ... the problem here isnt the
kernel but userspace bits required during boot. 

most modern linux installs use an initramfs, this means you load a
small ramdisk into memory alongside the kernel before switching to your
root filesystem.

originally this was designed to be able to load all controller user
space bits (raid tools, controller modules etc) to find your disk. back
then even an initramfs could still fit into 64MB RAM along your
kernel... 

ubuntu is designed to be generic and to run on as many hardware
combinations as possible in a stable way, so you need to ship a lot
more drivers and user space tools alongside the kernel itself than a
system tailored for a single purpose on just one hardware setup would
ever need.

over time new features showed up. people want to encrypt their disks so
you need to add (usb) keyboard support, key maps, some basic language
support and all the bells and whistles to enable them to type in a pass
phrase... someone wants to net boot the rootfs from a remote server. so
you need a networking stack and all the possible NIC drivers included
... then there are boot-splashes to make your screen for pass phrase
typing prettier, show a progress bar during boot etc etc

i guess nowadays the initramfs itself is even bigger than a complete
server install was 15y ago but if you are able to adjust the initrd to
be exactly tailored for your hardware to only do the very simple task
of just mounting your rootfs on this one machine you should be able to
get through the boot to a running rootfs even on 64MB.

later in the boot process the system will also load modules and
firmware into ram, here you have again a lot of generic stuff ... say
your system has USB support, the kernel might load some generic bits
into ram for potential use cases (i.e. usb-storage support in case you
want to plug in an usb stick eventually) all these bits will eat up
your ram right *after* the boot, so you need to tailor the
configuration on the rootfs to avoid this.

each tty login prompt that idles on your system eats ram, so you want
to disable them ... bash uses up ~5MB of ram when running, you want to
make your login shell dash, ash or busybox which were designed for low
ram usage. turn off all non-existential services that could occupy ram.

now ... even if you got to a login prompt and can log in the one
question remains: what exactly do you want to run on this system that
has only enough ram to barely boot it, can you even find software for
the task you plan for this system that is small enough to fit into the
remaining ram ?

with the snap based Ubuntu Core (very often used for single purpose
tasks (Wifi APs, routers, IoT gateways, digital signage displays) on
dedicated hardware) which is very cut down but still ships some bits
for the generic parts described above i can easily boot in 128MB (i
guess even 96MB would work), but after boot just the idling processes
of the OS itself use up ~48MB. that leaves very low space for running
any additional software.

so yes, i guess booting in 64MB RAM is still possible, but requires
jumping through a lot of hoops and that you have a lot of basic
knowledge about what you are doing when modifying it.

ciao
        oli
--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users

signature.asc (188 bytes) Download Attachment