Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Minimal Kernels, for Virtualization
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
R0b0t1
Apprentice
Apprentice


Joined: 05 Jun 2008
Posts: 255

PostPosted: Sun Apr 30, 2017 3:45 am    Post subject: Minimal Kernels, for Virtualization Reply with quote

Hello,

I am aware of Papppy's kernel seeds but I do not remember finding any explanation of what is still left enabled. Ideally I want kernels to be run under QEMU and Hyper-V. The intent of the system is to be booted from network or have the root be shared, read-only media.

It's easy enough to find the virtualization drivers for either platform (granted VirtIO support is slightly fragmented). What is harder to know is what needs enabled starting from a `make defnoconfig`. I spent a few hours trying to get a kernel working one time, but I was never successful. Does anyone have any pointers?
Back to top
View user's profile Send private message
szatox
Veteran
Veteran


Joined: 27 Aug 2013
Posts: 1776

PostPosted: Sun Apr 30, 2017 11:34 am    Post subject: Reply with quote

Make defconfig builds almost everything as modules. Whether or not it's "minimal" kernel is debatable.
Anyway, stuff specific to virtualisation is the emulated hardware support. You should enable virtio drivers and perhaps stuff related to hyper v too.
vmWare and Cirrus graphic cards can sometimes come in handy too.

For netboot make sure to build network drivers in kernel statically. Modules _can_ work if you build your own initramfs, but it would also mean you have to keep several pieces in sync (for easier maintenance build everything you need in, leave the rest completely out. Not even as modules).

With network and hard drives controller driver compiled statically into kernel you should be able to boot and have a look around. From this point you can start incremental tuning (enable or disable a few features, recompile with --no-clean for faster build, check if nothing broke :) )
Back to top
View user's profile Send private message
Jaglover
Watchman
Watchman


Joined: 29 May 2005
Posts: 7328
Location: Saint Amant, Acadiana

PostPosted: Sun Apr 30, 2017 12:23 pm    Post subject: Reply with quote

To get leanest config use make allnoconfig, then you have to go thru menus at least three times because the options you need will even not show up at first. You will spend some time, but the result will be rewarding.
_________________
Please learn how to denote units correctly!
Back to top
View user's profile Send private message
roki942
Apprentice
Apprentice


Joined: 18 Apr 2005
Posts: 285
Location: Seattle

PostPosted: Mon May 01, 2017 6:44 pm    Post subject: Reply with quote

Total kvm noob question from someone only getting ready to try kvm.
Code:
make help
...............
kvmconfig       - Enable additional options for kvm guest kernel support

I'm guessing this only adds in the options for kvm. Is it something to run after/before one of the other options?
Back to top
View user's profile Send private message
R0b0t1
Apprentice
Apprentice


Joined: 05 Jun 2008
Posts: 255

PostPosted: Mon May 01, 2017 8:20 pm    Post subject: Reply with quote

szatox wrote:
Make defconfig builds almost everything as modules. Whether or not it's "minimal" kernel is debatable.
Anyway, stuff specific to virtualisation is the emulated hardware support. You should enable virtio drivers and perhaps stuff related to hyper v too.
vmWare and Cirrus graphic cards can sometimes come in handy too.

For netboot make sure to build network drivers in kernel statically. Modules _can_ work if you build your own initramfs, but it would also mean you have to keep several pieces in sync (for easier maintenance build everything you need in, leave the rest completely out. Not even as modules).

With network and hard drives controller driver compiled statically into kernel you should be able to boot and have a look around. From this point you can start incremental tuning (enable or disable a few features, recompile with --no-clean for faster build, check if nothing broke :) )


The defconfig or more properly the x86_64_defconfig does not seem to be minimal at all, and I found and am still finding sources that say it has a lot of generally useful things enabled. See the link after the next quote.

I was planning on building everything into the kernel statically if it's not already compiled in statically for the reasons you gave.

Jaglover wrote:
To get leanest config use make allnoconfig, then you have to go thru menus at least three times because the options you need will even not show up at first. You will spend some time, but the result will be rewarding.


Sorry, that's what I meant. The problem is when I last attempted to get a working system from "allnoconfig" I did not have much luck, even after enabling what I thought would provide necessary subsystems (disk, network, etc). Does anyone have a complete list of what is needed? I assumed a default configuration set would be available that was the "minimum working configuration" but it did not look like there was one.

After some more searching I just found http://mgalgs.github.io/2015/05/16/how-to-build-a-custom-linux-kernel-for-qemu-2015-edition.html. For some reason I find the answer I am after only once I have posted about it. I would still appreciate people chiming in if they have more information.

roki942 wrote:
Total kvm noob question from someone only getting ready to try kvm.
Code:
make help
...............
kvmconfig       - Enable additional options for kvm guest kernel support

I'm guessing this only adds in the options for kvm. Is it something to run after/before one of the other options?


Unless I'm mistaken kvmconfig is built on top of defconfig - what would be the point of having VirtIO (or other) disk and network drivers if you had no disk or networking support?
Back to top
View user's profile Send private message
szatox
Veteran
Veteran


Joined: 27 Aug 2013
Posts: 1776

PostPosted: Mon May 01, 2017 8:48 pm    Post subject: Reply with quote

Yes, allnoconfig is not very user friendly, most likely won't even boot. If you knew all that is needed to start with it, you wouldn't start this topic.
Anyway, defconfig tags most of the important stuff as builtin, and everything else as modules. So you can tag things you _know_ are important to be built in (network and hard drives) and then completely disable all other _modules_. I did exactly this recently: made network and some filesystems static, and then netbooted a machine into RAM (diskless). The machine behaves properly, even though I haven't installed modules into the target image. Well, almost properly, it does not recognize keyboard, because - you guessed that - it's a module by default. I can still control it with SSH which is going to do fine for a week or two until I have to actually clean up the mess.

You can even use the default kernel to check what modules get loaded and are used for hardware support, and then remove everything else. This way of doing things will likely produce slightly more bloated kernel than allnoconfig, but starting with a _working_ kernel and striping it down is much easier than starting with nothing and trying to get it right in a single shot.
I've never tried kvmconfig. Generic kernels do work (at least in compatibility mode) and enabling virtio wasn't all that hard.
Back to top
View user's profile Send private message
R0b0t1
Apprentice
Apprentice


Joined: 05 Jun 2008
Posts: 255

PostPosted: Mon May 01, 2017 8:58 pm    Post subject: Reply with quote

szatox wrote:
Yes, allnoconfig is not very user friendly, most likely won't even boot. If you knew all that is needed to start with it, you wouldn't start this topic.


szatox wrote:
You can even use the default kernel to check what modules get loaded and are used for hardware support, and then remove everything else. This way of doing things will likely produce slightly more bloated kernel than allnoconfig, but starting with a _working_ kernel and striping it down is much easier than starting with nothing and trying to get it right in a single shot.
I've never tried kvmconfig. Generic kernels do work (at least in compatibility mode) and enabling virtio wasn't all that hard.


I suppose I will try again expecting success but based on my last attempts I think the issue I was having is that there were things I did not know to enable that I could not find. E.g. if you want to enable wireless networking you need to enable one of the networking subsystems which may seem completely unrelated if you didn't know any better. I am certain I have the knowledge to understand why various things need to be enabled, but finding them without a priori knowledge in the configuration menu is next to impossible.

Unfortunately, because I don't know what needed to be enabled I can't ask about it. The kernel just wasn't booting.

Things in the configuration menu do seem to be periodically reorganized, so maybe I may have more luck.
Back to top
View user's profile Send private message
Jaglover
Watchman
Watchman


Joined: 29 May 2005
Posts: 7328
Location: Saint Amant, Acadiana

PostPosted: Mon May 01, 2017 9:04 pm    Post subject: Reply with quote

In make nconfig you can hit F4 to see all options, F2 to see what is required to enable desired option.
_________________
Please learn how to denote units correctly!
Back to top
View user's profile Send private message
szatox
Veteran
Veteran


Joined: 27 Aug 2013
Posts: 1776

PostPosted: Mon May 01, 2017 9:10 pm    Post subject: Reply with quote

Protip 1: press "Z" to show all options, including those not available due to unmet dependencies
Protip 2: press "/" to search for options you are interested in. Search will return your option together with a bunch of handy information like option's status, its dependencies, and dependencies' requested statuses. (Y/m/N)
Quote:
I am certain I have the knowledge to understand why various things need to be enabled
That's the point, as you already noticed "various" things are not enough to get a bootable kernel.
Anyway, better luck this time, you're now armed with a map :)
Back to top
View user's profile Send private message
R0b0t1
Apprentice
Apprentice


Joined: 05 Jun 2008
Posts: 255

PostPosted: Mon May 01, 2017 9:33 pm    Post subject: Reply with quote

Thanks, wasn't aware of those. Hopefully there's not too many things with very bland descriptions (e.g. name only, little to no reference to what it does).
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum