Linux/Tipps/Gentoo/Kernel

Aus VivaLV
< Linux‎ | Tipps‎ | Gentoo
Zur Navigation springen Zur Suche springen

Kernel erstellen

Wenn der Kernel in einer chroot Umgebung erstellt wird, muss auch /proc gemountet werden.

Vorbereitung

emerge module-rebuild
module-rebuild populate

Wenn genkernel verwendet wird:

emerge genkernel

Kernel neu erstellen

genkernel erstellt einen Kernel, der auf möglichst viele Hardware-Konfigurationen passt und dementsprechend groß ist. Bei einem per Hand erstellten Kernel muss man dafür genau wissen, welche Hardware man hat und entsprechend die Optionen einstellen.

Download

emerge gentoo-sources

Evtl. /usr/src/linux symlink auf die neue Sourcen setzen.

Mit genkernel

Auf Basis der Config des laufenden Kernels:

genkernel --microcode --kernel-config=.config --no-clean --makeopts=-j5 all

Mit völlig neuer generischer Config:

genkernel --microcode --kernel-config=/usr/share/genkernel/x86/kernel-config-2.6 --makeopts=-j5 all

Ohne genkernel

make menuconfig
make
make install

Kernel modifizieren

Mit genkernel

Die .config in /usr/src/linux mit eine der folgenden Möglichkeiten modifizieren:

  • per Hand/Editor oder "make menuconfig" und anschließend "genkernel --no-clean all"

oder

  • genkernel --kernel-config=.config --no-clean --menuconfig all

Wenn ein Splashscreen verwendet wird, muss auch noch "--splash=<THEME>" und optional "--splash-res=1024x768" angegeben werden.

Ohne genkernel

make menuconfig
make
make modules_install

Optional:

make install

Externe Module

module-rebuild rebuild
update-modules force

Kernel upgraden

Download

emerge gentoo-sources

Evtl. /usr/src/linux symlink auf die neue Sourcen setzen.

Compilieren

Mit genkernel

make oldconfig
genkernel --kernel-config=.config --no-clean all

Mir 4 CPUs:

genkernel --kernel-config=.config --no-clean --makeopts=-j5 all

Wenn ein Splashscreen verwendet wird, muss auch noch "--splash=<THEME>" und optional "--splash-res=1024x768" angegeben werden.

Ohne genkernel

make oldconfig
make
make modules_install

Der Kernel befindet sich dann hier:

/usr/src/linux/arch/i386/boot/bzImage

Installieren:

make install

Externe Module

module-rebuild rebuild
update-modules force

Bootmenü

Dann /boot/grub/menu.lst erweitern und neu booten.

Module automatisch laden

Seit Baselayout2/OpenRC wird das in /etc/conf.d/modules eingestellt:

modules_2_6="${modules_2_6} lirc_serial"
module_lirc_serial_args_2_6=""

modules_2_6="${modules_2_6} powernow_k8"
module_powernow_k8_args_2_6=""

modules_2_6="${modules_2_6} vboxdrv"
module_vboxdrv_args_2_6=""

modules_2_6="${modules_2_6} vboxnetflt"
module_vboxnetflt_args_2_6=""

Migration auf Kernel 3.x

Um Module automatisch zu laden muss 3_0 statt 2_6 in /etc/conf.d/modules verwendet werden.

Wichtige Kernel-Optionen

Wenn man genkernel die Kernel-Config erzeugen lässt, dann sind die meisten Optionen schon aktiviert.

Prozessor-Typ

Man sollte den Prozessor-Typ einstellen.

Unter Processor type and features -> Processor family die richtige Prozessor-Familie wählen.

Prozessorhersteller

Der richtige Prozessorhersteller muss aktiviert sein (weitere schaden nicht), sonst bootet der Kernel evtl. nicht oder stürzt beim Initialisieren ab!

  • CONFIG_PROCESSOR_SELECT: Processor type and features -> Supported processor vendors = y
  • CONFIG_CPU_SUP_INTEL: Processor type and features -> Supported processor vendors -> Support Intel processors = y
  • CONFIG_CPU_SUP_AMD: Processor type and features -> Supported processor vendors -> Support AMD processors = y

Allgemeine Optionen

Siehe http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=1&chap=7.

Audio (ALSA)

Allgemeines siehe http://www.gentoo.org/doc/en/alsa-guide.xml#doc_chap2_pre3.

Erweiterte procfs Einstellungen:

  • CONFIG_SND_VERBOSE_PROCFS: Device Drivers -> Sound card support -> Advanced Linux Sound Architecture -> Verbose procfs contents = y

Optimierung für Desktop

Quelle: http://netslaughters.de/index.php/?p=52

  • CONFIG_PREEMPT: Processor type and features -> Preemption Model -> Preemptible Kernel (Low-Latency Desktop) = y
  • CONFIG_PREEMPT_BKL: Processor type and features -> Preempt The Big Kernel Lock = y

Dadurch kommen interaktive Prozesse öfter zum Zug, wenn im Hintergrund ein Prozess mit hoher Last läuft.

WLAN (ipw2200)

  • CONFIG_WLAN_80211: Device Drivers -> Network device support -> Wireless LAN -> Wireless LAN (IEEE 802.11) = y
  • CONFIG_IPW2200: Device Drivers -> Network device support -> Wireless LAN -> Intel PRO/Wireless 2200BG and 2915ABG Network Connection = m

lm_sensors

Quelle: http://de.gentoo-wiki.com/LM-Sensors

  • CONFIG_HWMON: Device-Drivers -> Hardware Monitoring support = y
  • Unter Device-Drivers -> Hardware Monitoring support die notwendigen Sensoren als Modul auswählen
  • CONFIG_I2C: Device-Drivers -> I2C support = m
  • CONFIG_I2C_CHARDEV: Device-Drivers -> I2C support -> I2C device interface = m
  • Unter Device-Drivers -> I2C support -> I2C Hardware Bus support die benötigten Chipsatz-Module als Modul auswählen

Verschlüsselung

  • CONFIG_DM_CRYPT: Device drivers -> Multiple devices driver support (RAID and LVM) -> Crypt target support = m

autofs

  • CONFIG_AUTOFS4_FS: File systems -> Kernel automounter version 4 support = y

Splashscreen

  • CONFIG_FB: Device Drivers -> Graphics support -> Support for frame buffer devices = y
  • CONFIG_FB_VESA: Device Drivers -> Graphics support -> VESA VGA graphics support = y
  • CONFIG_FRAMEBUFFER_CONSOLE: Device Drivers -> Graphics support -> Console display driver support -> Framebuffer Console support = y
  • CONFIG_FB_CON_DECOR: Device Drivers -> Graphics support -> Console display driver support -> Support for the Framebuffer Console Decorations = y

Joystick

Allgemein:

  • CONFIG_INPUT_JOYDEV: Device Drivers -> Input device support -> Joystick interface = m

An USB:

  • CONFIG_HID_SUPPORT: Device Drivers -> HID Devices = y
  • CONFIG_USB_HID: Device Drivers -> HID Devices -> USB Human Interface Device (full HID) support = y

Am Gameport (ungetestet):

  • CONFIG_INPUT_JOYSTICK: Device Drivers -> Input device support -> Joysticks/Gamepads = y
  • CONFIG_JOYSTICK_ANALOG: Device Drivers -> Input device support -> Joysticks/Gamepads -> Classic PC analog joysticks and gamepads = y
  • CONFIG_GAMEPORT: Device Drivers -> Input device support -> Hardware I/O ports -> Gameport support = y

Bluetooth

Siehe hier.

PXE

  • CONFIG_INET: Networking -> Networking options -> TCP/IP networking = y
  • CONFIG_IP_PNP: Networking -> Networking options -> IP: kernel level autoconfiguration = y
  • CONFIG_IP_PNP_DHCP: Networking -> Networking options -> IP: DHCP support = y
  • CONFIG_IP_PNP_BOOTP: Networking -> Networking options -> IP: BOOTP support = y
  • CONFIG_NFS_FS: File systems -> Network File Systems -> NFS file system support = y
  • CONFIG_NFS_V3: File systems -> Network File Systems -> Provide NFSv3 client support = y
  • CONFIG_ROOT_NFS: File systems -> Network File Systems -> Root file system on NFS = y

Und unter Device Drivers -> Network device support den Treiber für die verwendete Netzwerkkarte aktivieren (y).

AMD PowerNow!

  • CPU_FREQ_DEFAULT_GOV_USERSPACE: Power management options -> CPU Frequency scaling -> Default CPUFreq governor -> userspace = y
  • X86_POWERNOW_K8: Power management options -> CPU Frequency scaling -> AMD Opteron/Athlon64 PowerNow! = m

Cardreader mit mehreren Laufwerken

  • CONFIG_SCSI_MULTI_LUN: Device Drivers -> SCSI device support -> Probe all LUNs on each SCSI device = y

DVB

Generell

  • CONFIG_DVB_CORE: Device Drivers -> Multimedia devices -> DVB for Linux = y
  • CONFIG_VIDEO_HELPER_CHIPS_AUTO: Device Drivers -> Multimedia devices -> Video capture adapters -> Autoselect pertinent encoders/decoders and other helper chips = n

Budget-Karten

  • CONFIG_DVB_BUDGET: Device Drivers -> Multimedia devices -> DVB for Linux -> DVB/ATSC adapters -> Budget cards = m

Budget-Karten mit CI

  • CONFIG_DVB_BUDGET_CI: Device Drivers -> Multimedia devices -> DVB for Linux -> DVB/ATSC adapters -> Budget cards with onboard CI connector = m

Hauppauge Nova-S Plus

Quelle: http://de.gentoo-wiki.com/Hauppauge_WinTV_Nova-S-Plus)

  • CONFIG_VIDEO_CX88: Device Drivers -> Multimedia devices -> Video capture adapters -> Conexant 2388x (bt878 successor) support = m
  • CONFIG_VIDEO_CX88_ALSA: Device Drivers -> Multimedia devices -> Video capture adapters -> Conexant 2388x DMA audio support = m
  • CONFIG_VIDEO_CX88_BLACKBIRD: Device Drivers -> Multimedia devices -> Video capture adapters -> Blackbird MPEG encoder support (cx2388x + cx23416) = m
  • CONFIG_VIDEO_CX88_DVB: Device Drivers -> Multimedia devices -> Video capture adapters -> DVB/ATSC Support for cx2388x based TV cards = m
  • CONFIG_DVB_CX24123: Device Drivers -> Multimedia devices -> DVB/ATSC adapters -> Customise DVB Frontends -> Conexant CX24123 based = m
  • CONFIG_DVB_ISL6421: Device Drivers -> Multimedia devices -> DVB/ATSC adapters -> Customise DVB Frontends -> ISL6421 SEC controller = m

RealTimeClock (RTC/HPET)

In neueren Kernel-Versionen gibt es nur noch den Nachfolger des alten RTC, genannt HPET. HPET kann aber RTC emulieren und ein entsprechendes Device /dev/rtc zur Verfügung stellen.

  • CONFIG_HPET: Device Drivers -> Character devices -> HPET - High Precision Event Timer = y
  • CONFIG_HPET_MMAP: Device Drivers -> Character devices -> Allow mmap of HPET = y
  • CONFIG_RTC_CLASS: Device Drivers -> Real Time Clock = y
  • CONFIG_RTC_LIB: y (wird von menuconfig automatisch gesetzt)
  • CONFIG_RTC_HCTOSYS: Device Drivers -> Real Time Clock -> Set system time from RTC on startup and resume = y
  • CONFIG_RTC_HCTOSYS_DEVICE: Device Drivers -> Real Time Clock -> RTC used to set the system time = rtc0
  • CONFIG_RTC_DRV_CMOS: Device Drivers -> Real Time Clock -> PC-style 'CMOS' = y
  • CONFIG_HPET_EMULATE_RTC: y (wird von menuconfig automatisch gesetzt)

Weitere Infos: http://wiki.debianforum.de/KernelTimer

Filesystem in Userspace (FUSE)

  • CONFIG_BLK_DEV_LOOP: Device Drivers -> Block devices -> Loopback device support = y
  • CONFIG_MD: Device Drivers -> Multiple devices driver support (RAID and LVM) = y
  • CONFIG_BLK_DEV_DM: Device Drivers -> Multiple devices driver support (RAID and LVM) -> Device mapper support = m
  • CONFIG_DM_CRYPT: Device Drivers -> Multiple devices driver support (RAID and LVM) -> Crypt target support = m
  • CONFIG_FUSE_FS: File systems -> FUSE (Filesystem in Userspace) support = y

Staging-Treiber von lirc aktivieren ab Kernel 2.6.36

  • CONFIG_MEDIA_SUPPORT: Device Drivers -> Multimedia support = y
  • CONFIG_RC_CORE: Device Drivers -> Multimedia support -> Remote Controller adapters = y
  • CONFIG_STAGING: Device Drivers -> Staging drivers = y
  • CONFIG_STAGING_MEDIA: Device Drivers -> Staging drivers -> Media staging drivers = y
  • CONFIG_LIRC_STAGING: Device Drivers -> Staging drivers -> Media staging drivers -> Linux Infrared Remote Control = y
  • CONFIG_LIRC_SERIAL: Device Drivers -> Staging drivers -> Media staging drivers -> Linux Infrared Remote Control -> Homebrew Serial Port Receiver = m

Suspend-To-RAM und Hibernate

  • CONFIG_SUSPEND: Power management and ACPI options -> Suspend to RAM and standby = y
  • CONFIG_HIBERNATION: Power management and ACPI options -> Hibernation (aka 'suspend to disk') = y

Für Hibernate muss eine Swap-Partition existieren, die mindestens so groß wie das RAM ist. Verwendet wird die erste gefundene. Für Resume muss diese bei den Kernel-Optionen in der Grub-Config angegeben werden, z.B.:

resume=/dev/sdb1

Falls der PC nach Hibernate manchmal oder immer nicht ausgeschaltet wird muss evtl. bei jedem Booten diese Zeile ausgeführt werden (z.B. in /etc/local.d/baselayout1.start):

echo shutdown > /sys/power/disk

Firmware-Patch für RTL8111/8168B Netzwerkchip

emerge sys-kernel/linux-firmware
  • CONFIG_EXTRA_FIRMWARE: Device Drivers -> Generic Driver Options -> External firmware blobs to build into the kernel binary = rtl_nic/rtl8168e-3.fw
  • CONFIG_EXTRA_FIRMWARE_DIR: Device Drivers -> Generic Driver Options -> Firmware blobs root directory = /lib/firmware

Logitech Unifying Receiver

  • CONFIG_USB_HIDDEV: Device Drivers -> HID Devices -> /dev/hiddev raw HID device support = y

oder

  • CONFIG_HIDRAW: Device Drivers -> HID Devices -> /dev/hidraw raw HID device support = y

Außerdem:

  • CONFIG_HID_LOGITECH: Device Drivers -> HID Devices -> Special HID drivers -> Logitech devices = y
  • CONFIG_HID_LOGITECH: Device Drivers -> HID Devices -> Special HID drivers -> Logitech Unifying receivers full support = m

PAE (Physical Address Extension)

  • CONFIG_HIGHMEM64G: Processor type and features -> High Memory Support 64GB = y
  • CONFIG_X86_PAE: Processor type and features -> PAE (Physical Address Extension) Support = y

Namespaces (benötigt für die Sandbox von Chrome/Chromium)

  • CONFIG_NAMESPACES: General setup -> Namespaces support = y
  • PID_NS: General setup -> Namespaces support -> PID Namespaces = y
  • NET_NS: General setup -> Namespaces support -> Network namespace = y

High Resolution Timer

  • CONFIG_HIGH_RES_TIMERS: General setup -> Timers subsystem -> High Resolution Timer Support = y

Crypto XTS support

  • CRYPTO_XTS: Cryptographic API -> XTS support = y

Microcode patches for Spectre

See also https://wiki.gentoo.org/wiki/Project:Security/Vulnerabilities/Meltdown_and_Spectre and https://wiki.gentoo.org/wiki/Intel_microcode and https://www.heise.de/security/meldung/Spectre-Luecke-Intels-Microcode-Updates-fuer-Linux-und-Windows-3994347.html.

Check processor and microcode version (before and after changes):

dmesg | grep microcode

Install microcode and tool:

emerge --ask --noreplace sys-firmware/intel-microcode sys-apps/iucode_tool

Generate microcode for kernel (do after each update of intel-microcode):

iucode_tool -S --overwrite --write-earlyfw=/boot/early_ucode.cpio /lib/firmware/intel-ucode/*

Enable kernel options:

  • CONFIG_BLK_DEV_INITRD: General setup -> Initial RAM filesystem and RAM disk (initramfs/initrd) support = y
  • CONFIG_MICROCODE: Processor type and features -> CPU microcode loading support = y
  • CONFIG_MICROCODE_INTEL: Processor type and features -> Intel microcode loading support = y

Need newer genkernel for --microcode option, so have to add this to /etc/portage/package.keywords:

=sys-kernel/genkernel-3.5.1.1

Install newer genkernel:

emerge --ask genkernel

Create new kernel with microcode update:

genkernel --microcode --kernel-config=.config --no-clean --makeopts=-j5 all