剥离Linux 中的内核?

发布于 2024-09-26 15:36:21 字数 227 浏览 0 评论 0原文

我最近读了一篇文章(诚然已经有几年了),它是对快速数字处理程序的建议:

“使用像 Gentoo Linux 这样的带有 64 位处理器的东西,因为你可以在安装时本地编译它。这将允许你得到机器的最大冲孔量,因为您可以将内核直接剥离到您需要的部分。”

任何人都可以详细说明剥离内核的含义吗?另外,由于这篇文章已经发布了大约 6 年,当前哪个 Linux 版本最适合这个问题(以帮助我进行 google 搜索)?

I recently read a post (admittedly its a few years old) and it was advice for fast number-crunching program:

"Use something like Gentoo Linux with 64 bit processors as you can compile it natively as you install. This will allow you to get the maximum punch out of the machine as you can strip the kernel right down to only what you need."

can anyone elaborate on what they mean by stripping down the kernel? Also, as this post was about 6 years old, which current version of Linux would be best for this (to aid my google searches)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

半葬歌 2024-10-03 15:36:21

这句话有几分道理,也有几分无稽之谈。

您不会将资源花费在未运行的进程上。因此,作为第一个实例,我会尝试最小化正在运行的进程数量。为此,我们非常喜欢工作中的 Ubuntu 服务器 iso 映像 - 如果您从这些映像安装,登录并运行 pspstree,您会看到美丽的东西:六个或七个流程。而已。这很好

内核很大(就源代码大小或安装而言)本身并不重要。许多这样的大小源于您可能根本不使用的驱动程序。同样的规则再次适用:您不运行的内容不会竞争资源。

因此,考虑一下无头服务器,精简一下,而不是普通的桌面安装,其中包含多个进程,试图让桌面用户的生活更轻松。

There is some truth in the statement, as well as something somewhat nonsensical.

You do not spend resources on processes you are not running. So as a first instance I would try minimise the number of processes running. For that we quite enjoy Ubuntu server iso images at work -- if you install from those, log in and run ps or pstree you see a thing of beauty: six or seven processes. Nothing more. That is good.

That the kernel is big (in terms of source size or installation) does not matter per se. Many of this size stems from drivers you may not be using anyway. And the same rule applies again: what you do not run does not compete for resources.

So think about a headless server, stripped down -- rather than your average desktop installation with more than a screenful of processes trying to make the life of a desktop user easier.

夏花。依旧 2024-10-03 15:36:21

您可以为任何发行版创建自定义 Linux 内核。

首先访问 kernel.org 并下载最新的源代码。然后选择您的配置界面(现在您可以选择控制台文本、“config”、ncurses 样式“menuconfig”、KDE ​​样式“xconfig”和 GNOME 样式“gconfig”)并执行 ./makewhateverconfig。选择所有选项后,输入 make 创建内核。然后 make module 编译该内核的所有选定模块。然后,make install 将文件复制到 /boot 目录,make module_install 复制模块。接下来,转到 /boot 并使用 mkinitrd 创建正确启动所需的 ram 磁盘(如果需要)。然后,您将通过编辑 menu.lst 并复制最新条目并添加指向新内核版本的类似条目,将内核添加到 GRUB menu.lst 中。

当然,这是一个基本概述,您可能应该搜索“linux 内核编译”以查找更详细的信息。选择必要的内核模块和选项需要一些经验 - 如果您选择了错误的选项,内核可能无法启动,您将不得不重新开始,这很痛苦,因为选择选项和编译内核可能需要 15 个小时-30分钟。

最终,编译精简的自定义内核不会产生很大的影响,除非您给定的任务对性能非常非常敏感。不过,从内核中删除永远不会使用的东西是有意义的,例如 ISDN 支持。

顺便说一句,我不得不说这个问题更适合 SuperUser.com,因为它与编程无关。

You can create a custom linux kernel for any distribution.

Start by going to kernel.org and downloading the latest source. Then choose your configuration interface (you have the choice of console text, 'config', ncurses style 'menuconfig', KDE style 'xconfig' and GNOME style 'gconfig' these days) and execute ./make whateverconfig. After choosing all the options, type make to create your kernel. Then make modules to compile all the selected modules for this kernel. Then, make install will copy the files to your /boot directory, and make modules_install, copies the modules. Next, go to /boot and use mkinitrd to create the ram disk needed to boot properly, if needed. Then you'll add the kernel to your GRUB menu.lst, by editing menu.lst and copying the latest entry and adding a similar one pointing to the new kernel version.

Of course, that's a basic overview and you should probably search for 'linux kernel compile' to find more detailed info. Selecting the necessary kernel modules and options takes a bit of experience - if you choose the wrong options, the kernel might not be bootable and you'll have to start over, which is a pain because selecting the options and compiling the kernel can take 15-30 minutes.

Ultimately, it isn't going to make a large difference to compile a stripped-down custom kernel unless your given task is very, very performance sensitive. It makes sense to remove things you're never going to use from the kernel, though, like say ISDN support.

I'd have to say this question is more suited to SuperUser.com, by the way, as it's not quite about programming.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文