Jump to content

Kernel configuration: Difference between revisions

From postmarketOS Wiki
CONFIG_KERNEL_GZIP, CONFIG_KERNEL_XZ, CONFIG_KERNEL_LZO and CONFIG_KERNEL_LZMA: Add another patch, working with 4.4 kernels, when fixing an error with lzo.
Tags: mobile edit mobile web edit
Knuxify (talk | contribs)
use PrefixIndex for subpages
 
(46 intermediate revisions by 17 users not shown)
Line 1: Line 1:
= Changing the kernel configuration =
<!--


You can change the kernel configuration with pmbootstrap. On some devices the naming convention is simply linux-<vendor>-<device>, for the linux-sony-yuga package for example we run:
NOTE for editors:


<pre class="shell">pmbootstrap kconfig edit sony-yuga</pre>
This page is just an overview, please keep it lean and refer to other pages for details! Feel free to create more "Kernel configuration/ ..." pages as it makes sense.


Some devices do not follow this naming convention, in which case you can check what package provided the kernel by running:
-->
Kernel configurations determine which features of the Linux kernel are enabled for a particular build, such as filesystems, camera, WiFi related options and a lot more. This article gives an overview of how kernel configs are managed in postmarketOS and how one can change them.


<pre class="shell">apk info --who-owns /boot/vmlinuz-*</pre>
== Why do we have multiple kernel configs? ==
We would ideally run [[PostmarketOS_Trailblazer_(postmarketos-trailblazer)|mainline Linux without any patches]] on all devices and only have one kernel config per device architecture. But oftentimes we need to carry a few patches for our [[(Close to) Mainline]] kernels (used for devices in ''main'' and ''community'' [[Device_categorization|categories]]). Another reason is that in many cases want to be on a specific, known-working version before we upgrade to the next one. Furthermore devices in the ''testing'' category may just use the downstream kernel to get the device booting at all. Because of that, you will find ''a lot'' of Linux kernels when looking at the postmarketOS specific package build recipes in [[pmaports.git]].


On the pinephone by pine64 you would run:
== Keeping kernel configs consistent ==


<pre class="shell">pmbootstrap kconfig edit linux-postmarketos-allwinner-5.4.0_git20191204-r1</pre>
All kernel configs are stored inside pmaports (list them with <code>find device -name 'config-*'</code>). We ensure that they have [[Kernel configuration/Specific options|specific options]] enabled, disabled or set to a certain value with a CI script that essentially runs <code>pmbootstrap kconfig check</code>. This [[pmbootstrap]] command reads our requirements from <code>kconfigcheck.toml</code> in the currently checked out pmaports branch and verifies that all kernels pass the requirements. See [[Kernel configuration/Adjusting multiple kernels]] for more information.


This gives you a menu where you can select and deselect all kernel configuration options. Press the <code>/</code> key to get a search dialog. After finding something, type the number of the search result to quickly jump to it.
=== Future plans ===


[[File:KernelConfig.png|800px]]
At some point we would like to generate the kernel configs for ''main'' and ''community'' devices from fragments. Work on this has been started in {{issue|2492|pmaports}} (big thanks to Jenneron and everybody involved!). However this is quite the big undertaking and work has stalled. So we decided to improve and document the current process instead, which we will still need for devices in ''testing'' in any case.


If you don't like the terminal user interface, you can also use <code>pmbootstrap kconfig edit -x</code> or <code>pmbootstrap kconfig edit -g</code>. See <code>pmbootstrap kconfig edit -h</code> for details.
== Adjusting one kernel config ==


== Options aren't always visible! ==
It is recommended to change kernel config options not just for one kernel, but for all where it makes sense (typically all devices in the ''community'' or ''main'' category as explained [[Kernel configuration/Adjusting multiple kernels|here]]). However before you do that, you should first edit the one kernel you are currently using on your device to test if the change has the desired effect.
If you're looking for an option and you just can't find it, then it might not show up because it depends on other options that have been disabled. In that case, press <code>/</code> and search for the option in question. You will see the dependencies. Then use the search again to find these dependencies, and enable them until you can finally enable the option you wanted to change in the first place.


= Useful kernel configuration options =
You basically need to run <code>pmbootstrap kconfig edit</code> followed by the name of the kernel package, see [[Kernel configuration/Adjusting one kernel]] for details.


== Required to be enabled/disabled ==
== Subpages ==


Enable or disable the following options to get postmarketOS working. Use <code>pmbootstrap kconfig check</code> to check which options need to be modified.
{{Special:PrefixIndex/Kernel configuration/|hideredirects=yes}}


=== CONFIG_DEVTMPFS ===
[[Category: Technical Reference]]
 
'''About'''
 
''This adds support for the devtmpfs filesystem which should be mounted to /dev at startup. The kernel driver core creates device nodes for all registered devices in that filesystem. All device nodes are owned by root and have the default mode of 0600. Userspace can add and delete the nodes as needed.''
 
[https://cateee.net/lkddb/web-lkddb/DEVTMPFS.html Read more...]
 
'''Location in menu'''
 
<pre class="shell>
Device Drivers -->
  Generic Driver Options -->
    Maintain a devtmpfs filesystem to mount at /dev
</pre>
 
'''pmOS specific'''
 
This should always be set, otherwise you get this when you try SSH:
 
<pre>PTY allocation request failed on channel 0
-ash: a: unknown operand</pre>
 
=== CONFIG_TMPFS_POSIX_ACL ===
 
''' About'''
 
''Support POSIX Access Control Lists (ACLs) for tmpfs-based filesystems.''
 
[https://cateee.net/lkddb/web-lkddb/TMPFS_POSIX_ACL.html Read more...]
 
'''Location in menu'''
 
<pre class="shell>
File Systems -->
  Pseudo Filesystems -->
    Tmpfs virtual memory file system support (former shm fs) -->
      Tmpfs POSIX Access Control Lists
</pre>
 
 
'''pmOS specific'''
 
This is needed for some UIs (phosh) to be able to control bluetooth.
 
=== CONFIG_VT ===
 
'''About'''
 
''If you say Y here, you will get support for terminal devices with display and keyboard devices. These are called "virtual" because you can run several virtual terminals (also called virtual consoles) on one physical terminal. This is rather useful, for example one virtual terminal can collect system messages and warnings, another one can be used for a text-mode user session, and a third could run an X session, all in parallel. Switching between virtual terminals is done with certain key combinations, usually Alt-<function key>.''
 
[https://cateee.net/lkddb/web-lkddb/VT.html Read more...]
 
'''Location in menu'''
 
<pre class="shell>
Device Drivers -->
  Character Devices -->
    Enable TTY -->
      Virtual Terminal
</pre>
 
'''pmOS specific'''
 
This should always be set, otherwise you cannot get virtual terminal over USB.
 
=== CONFIG_DM_CRYPT ===
 
'''About'''
 
''This device-mapper target allows you to create a device that transparently encrypts the data on it.''
 
[https://cateee.net/lkddb/web-lkddb/DM_CRYPT.html Read more...]
 
'''Location in menu'''
 
<pre class="shell">
Device Drivers -->
  Multiple devices driver support (RAID and LVM) -->
    Device mapper support -->
      Crypt target support
</pre>
 
'''pmOS specific'''
 
This should always be set, required for full disk encyption.
 
=== CONFIG_EXT4_FS ===
 
'''About'''
 
''This is the next generation of the ext3 filesystem.''
 
[https://cateee.net/lkddb/web-lkddb/EXT4_FS.html Read more...]
 
'''Location in menu'''
 
<pre class="shell">
File systems -->
  The Extended 4 (ext4) filesystem
</pre>
 
'''pmOS specific'''
 
This should always be set since pmbootstrap creates an ext4 rootfs.
 
=== CONFIG_UEVENT_HELPER ===
 
'''About'''
 
''The uevent helper program is forked by the kernel for every uevent. Before the switch to the netlink-based uevent source, this was used to hook hotplug scripts into kernel device events. It usually pointed to a shell script at /sbin/hotplug. This should not be used today, because usual systems create many events at bootup or device discovery in a very short time frame. One forked process per event can create so many processes that it creates a high system load, or on smaller systems it is known to create out-of-memory situations during bootup.''
 
[https://cateee.net/lkddb/web-lkddb/UEVENT_HELPER.html Read more...]
 
'''Location in menu'''
 
<pre class="shell">
Device Drivers -->
  Generic Driver Options -->
    Support for uevent helper
</pre>
 
'''pmOS specific'''
 
This option should always be enabled on pmos kernels that are 3.16+, it's the config option that makes /proc/sys/kernel/hotplug appear.
 
=== CONFIG_KERNEL_GZIP, CONFIG_KERNEL_XZ, CONFIG_KERNEL_LZO and CONFIG_KERNEL_LZMA ===
 
'''About'''
 
;GZIP
:  ''The old and tried gzip compression. It provides a good balance between compression ratio and decompression speed.''
:  [https://cateee.net/lkddb/web-lkddb/KERNEL_GZIP.html Read more...]
;XZ
:  ''XZ uses the LZMA2 algorithm and instruction set specific BCJ filters which can improve compression ratio of executable code. The size of the kernel is about 30% smaller with XZ in comparison to gzip. The speed is about the same as with LZMA: The decompression speed of XZ is better than that of bzip2 but worse than gzip and LZO. Compression is slow.''
:  [https://cateee.net/lkddb/web-lkddb/KERNEL_XZ.html Read more...]
;LZO
:  ''Its compression ratio is the poorest among the choices. The kernel size is about 10% bigger than gzip; however its speed (both compression and decompression) is the fastest.''
:  [https://cateee.net/lkddb/web-lkddb/KERNEL_LZO.html Read more...]
;LZMA
:  ''This compression algorithm's ratio is best. Decompression speed is between gzip and bzip2. Compression is slowest. The kernel size is about 33% smaller with LZMA in comparison to gzip.''
:  [https://cateee.net/lkddb/web-lkddb/KERNEL_LZMA.html Read more...]
 
'''Location in menu'''
 
<pre class="shell>
General Setup -->
  Kernel compression mode -->
    Gzip
    LZMA
    XZ
    LZO
</pre>
 
'''pmOS specific'''
 
You should set one of these to Y.
* Gzip: Works without specifying anything else.
* LZMA: If kernel compilation fails with this compression type, read [[Troubleshooting:kernel#Kernel_compilation:_BusyBox_lzma_compression_fails]].
* XZ: Make sure to add <code>xz</code> to <code>makedepends</code> in the APKBUILD of your kernel package.
* LZO: If you get <code>lzop: high compression not compiled in</code> during compilation of the kernel you probably need [https://github.com/postmarketOS/pmbootstrap/blob/b4c9f93f0d7be1272f6a67de2128558ce58e1077/aports/linux-samsung-i9070/02_reduce_lzo_compression.patch this patch] or [https://gitlab.com/Max1Truc/pmaports/-/blob/master/device/testing/linux-klipad-rel/02_reduce_lzo_compression.patch this other patch].
 
=== CONFIG_ANDROID_PARANOID_NETWORK ===
 
'''About'''
 
''Android adds a "paranoid network" option to the Linux kernel, which restricts access to some networking features depending on the group of the calling process. The list of groups that are allowed access to networking features is in the kernel source file: /include/linux/android_aids.h
Setting this config will enable the paranoid network security feature''
 
[https://elinux.org/Android_Security#Paranoid_network-ing Read more...]
 
'''Location in menu'''
 
<pre class="shell">
Networking Support -->
  Networking Options -->
    Only allow certain groups to create sockets
</pre>
 
'''Android specific'''
 
This option should '''not''' be set in pmOS or any other OS not using Android security model.
 
 
=== CONFIG_PFT===
 
'''About'''
 
''This caused builds to fail with a modern GCC at least once, and while it originally was meant as security feature by Qualcomm, "it is unsupported by Qualcomm, and opens up to a wide range of potential attack surfaces that has not been audited by anyone." [http://www.merproject.org/logs/%23sailfishos-porters/%23sailfishos-porters.2016-08-26.log.html#t2016-08-26T17:43:06].''
 
'''Location in menu'''
 
<pre class="shell">
Device Drivers -->
  Qualcomm MSM specific device drivers -->
    Per-File-Tagger driver
</pre>
 
'''pmOS specific'''
 
Please disable it, so we have one less source for failing builds and enabling it has no benefit anyway.
 
 
=== CONFIG_SYSVIPC ===
 
'''Location in menu'''
 
<pre class="shell">
General Setup -->
  System V IPC
</pre>
 
'''pmOS specific'''
 
Please enable it for postmarketOS, so busybox' syslogd can log to a ringbuffer in the kernel (fixes {{github|808}}).
 
=== CONFIG_USE_VFB===
 
'''About'''
 
''Weston and Plasma Mobile might choose to draw on this virtual frame buffer, just like it happened for the samsung-jflte ({{issue|34|pmaports}}). Disabling the USE_VFB option fixed this, so let's make sure we don't have that option enabled for any kernel.''
 
'''Location in menu'''
 
<pre class="shell">
Device Drivers -->
  Graphics supports -->
    MSM Framebuffer support -->
      MSM Virtual Framebuffer support
</pre>
 
'''pmOS specific'''
 
Please disable it, so we have one less source of failure.
 
=== CONFIG_KINETO_GAN ===
 
'''About'''
 
''Related to a proprietary "T-Mobile's WiFi-Calling" feature. It should not affect normal calls, so it should be safe to disable it.''
 
'''Location in menu'''
 
<pre class="shell">
Device Drivers -->
  Network device support -->
    Kineto GAN virtual network interface
</pre>
 
'''pmOS specific'''
 
Causes <code>sudo</code>, <code>ip</code> and other commands to hang ({{issue|1513|pmbootstrap}}). Please disable it.
 
=== CONFIG_BLK_DEV_INITRD ===
 
'''About'''
 
''Initial RAM filesystem and RAM disk (initramfs/initrd) support''
 
'''Location in menu'''
 
<pre class="shell">
General setup -->
  Initial RAM filesystem and RAM disk (initramfs/initrd) support
</pre>
 
'''pmOS specific'''
 
Required. See {{issue|237|pmaports}} for notes about changing the initramfs compression.
 
=== CONFIG_CGROUPS ===
 
'''About'''
 
''This option adds support for grouping sets of processes together, for use with process control subsystems such as Cpusets, CFS, memory controls or device isolation.''
 
[https://cateee.net/lkddb/web-lkddb/CGROUPS.html Read more...]
 
'''Location in menu'''
 
<pre class="shell">
General setup -->
  Control Group support
</pre>
 
'''pmOS specific'''
 
Required for elogind, and therefore necessary to be able to run most desktop environments.
 
=== CONFIG_CRYPTO_XTS ===
 
'''About'''
 
''XTS: IEEE1619/D16 narrow block cipher''
 
[https://cateee.net/lkddb/web-lkddb/CRYPTO_XTS.html Read more...]
 
'''Location in menu'''
 
<pre class="shell">
Cryptographic API -->
  XTS support
</pre>
 
'''pmOS specific'''
 
Needed for the default cryptsetup cipher in pmbootstrap (<code>aes-xts-plain64</code>) ({{issue|1940}})
 
=== CONFIG_SAMSUNG_TUI ===
 
'''About'''
 
''Provide methods for TUI such as acquisition of buffer to be used as secure frame buffer in Secure World and synchronization of display and touch device between Normal World and Secure World.''
 
'''Location in menu'''
 
<pre class="shell">
Device Drivers -->
  Misc devices -->
    TUI HW Handler
</pre>
 
'''pmOS specific'''
 
Needs to be disabled. Prevents device from booting.
 
=== CONFIG_SEC_RESTRICT_ROOTING ===
 
'''About'''
 
''Restrict unauthorized executions with root permission.''
 
'''Location in menu'''
 
<pre class="shell">
Kernel hacking -->
  Samsung Rooting Restriction Feature
</pre>
 
'''pmOS specific'''
 
Needs to be disabled. Blocks user from gaining root permissions.
 
=== CONFIG_TZDEV ===
 
'''About'''
 
''Samsung TZ Based Secure OS interface driver''
 
'''Location in menu'''
 
<pre class="shell">
Device Drivers -->
  Misc devices -->
    Samsung TZ Based Secure OS Support
</pre>
 
'''pmOS specific'''
 
Needs to be disabled. Prevents device from booting.
 
== Optional ==
 
These kernel options are optional and for some devices required to fix some issues.
 
=== CONFIG_LBDAF ===
'''About'''
 
''Support for large (2TB+) block devices and files''
 
''The ext4 filesystem requires that this feature be enabled in order to support filesystems that have the huge_file feature enabled. Otherwise, it will refuse to mount in the read-write mode any filesystems that use the huge_file feature, which is enabled by default by mke2fs.ext4.''
 
'''Location in menu'''
 
<pre class="shell>
-*- Enable the block layer  --->
    [*]  Support for large (2TB+) block devices and files
</pre>
 
'''pmOS specific'''
 
This is recommended for all 32bit (armhf, armv7, x86) devices. The option is not present on 64bit (aarch64, x86_64) devices.
 
Without this option, it is not possible to mount ext4 partitions that have been created with the default settings. The postmarketOS SD card installation uses these default parameters. There doesn't seem to be a point in changing that to work around badly configured kernels: even if the postmarketOS installation did not require this option, you might come across an SD card with ext4, that does not work on your device.
 
=== CONFIG_USB_G_ANDROID ===
'''About'''
 
''The Android Composite Gadget supports multiple USB functions: adb, acm, mass storage, mtp, accessory and rndis.''
 
''Each function can be configured and enabled/disabled dynamically from userspace through a sysfs interface.''
 
'''Location in menu'''
 
<pre class="shell>
Device Drivers -->
  USB Support -->
    USB Gadget Support -->
      USB Gadget Drivers -->
        Android Composite Gadget
</pre>
 
'''pmOS specific'''
 
Enabling this option is needed for usb networking on some of the android kernels.
 
=== CONFIG_USB_ETH ===
'''About'''
 
''This driver implements Ethernet style communication, in one of several ways:
 
* ''The "Communication Device Class" (CDC) Ethernet Control Model. That protocol is often avoided with pure Ethernet adapters, in favor of simpler vendor-specific hardware, but is widely supported by firmware for smart network devices.''
* ''On hardware can't implement that protocol, a simple CDC subset is used, placing fewer demands on USB.''
* ''CDC Ethernet Emulation Model (EEM) is a newer standard that has a simpler interface that can be used by more USB hardware.''
 
''RNDIS support is an additional option, more demanding than than subset.''
 
[https://cateee.net/lkddb/web-lkddb/USB_ETH.html Read more...]
 
'''Location in menu'''
 
<pre class="shell>
Device Drivers -->
  USB Support -->
    USB Gadget Support -->
      USB Gadget Drivers -->
        Ethernet Gadget
</pre>
 
'''pmOS specific'''
 
Most devices do not need this to be set. If telnet/SSH does not work you can try and set this option to Y.
 
=== CONFIG_USB_ETH_RNDIS ===
'''About'''
 
''Microsoft Windows XP bundles the "Remote NDIS" (RNDIS) protocol, and Microsoft provides redistributable binary RNDIS drivers for older versions of Windows.''
 
''If you say "y" here, the Ethernet gadget driver will try to provide a second device configuration, supporting RNDIS to talk to such Microsoft USB hosts.''
 
[https://cateee.net/lkddb/web-lkddb/USB_ETH_RNDIS.html Read more...]
 
'''Location in menu'''
 
<pre class="shell>
Device Drivers -->
  USB Support -->
    USB Gadget Support -->
      USB Gadget Drivers -->
        RNDIS Support
</pre>
 
'''pmOS specific'''
 
Required if you set <code>CONFIG_USB_ETH</code> to 'Y'.
 
=== CONFIG_MSM_KGSL ===
'''About'''
 
''3D graphics driver. Required to use hardware accelerated OpenGL ES 2.0 and 1.1.''
 
[https://android.googlesource.com/kernel/msm/+/android-msm-mako-3.4-jb-mr1-kgsl/drivers/gpu/msm/Kconfig Read more...]
 
'''Location in menu'''
 
<pre class="shell>
Device Drivers -->
  Graphics Support -->
    MSM 3D graphics Driver
</pre>
 
'''pmOS specific'''
 
If framebuffer does not work set this to 'N'
 
=== CONFIG_CMDLINE ===
'''About'''
 
''Enter arguments here that should be compiled into the kernel image and used at boot time. If the boot loader provides a command line at boot time, it is appended to this string to form the full kernel command line, when the system boots.''
 
[https://cateee.net/lkddb/web-lkddb/CMDLINE.html Read more...]
 
'''Location in menu'''
 
<pre class="shell>
General Setup -->
  Boot options -->
    Default kernel command string
</pre>
 
'''pmOS specific'''
 
No
 
=== CONFIG_FHANDLE ===
 
'''About'''
 
''open by fhandle syscalls''
 
'''Location in menu'''
 
<pre class="shell">
General setup -->
  open by fhandle syscalls
</pre>
 
'''pmOS specific'''
 
If USB OTG isn't working for you, try enable this config.
 
=== CONFIG_BUILD_ARM_APPENDED_DTB_IMAGE ===
'''About'''
 
''Build a concatenated zImage/dtb by default''
 
''Enabling this option will cause a concatenated zImage and list of DTBs to be built by default (instead of a standalone zImage.)''
 
''The image will built in arch/arm/boot/zImage-dtb''
 
'''Location in menu'''
 
<pre class="shell>
General Setup -->
  Boot options -->
    appended device tree blob to zImage
</pre>
 
'''pmOS specific'''
 
Set this if your device needs an appended device tree. If you are unsure, use <code>extract-dtb</code> on an existing kernel image. Not to be confused with <code>CONFIG_ARM_APPENDED_DTB</code>!
 
=== CONFIG_FW_LOADER_USER_HELPER ===
'''About'''
 
''Enable the firmware sysfs fallback mechanism found in drivers/base/firmware_loader/Kconfig''
 
'''Location in menu'''
 
<pre class="shell>
Device Drivers -->
  Generic Driver Options -->
    Firmware loader -->
      Firmware loading facility (FW_LOADER [=y]) -->
        Enable the firmware sysfs fallback mechanism
</pre>
 
'''pmOS specific'''
 
Prior to kernel version 3.7, the kernel had no capability of finding firmware itself so it had to call out to userspace to find the firmware for it. This changed with kernel 3.7 where the kernel gained "direct loading support" and where the userspace helper was only called as a fallback. In kernel 3.9 this functionality was put behind the kconfig option FW_LOADER_USER_HELPER which is what this patch checks to be enabled.
 
Without this option, the udev rule present in postmarketos-base won't be notified that firmware needs to be loaded and as such can't call firmwareload.sh which loads firmware from /lib/firmware/postmarketos.
 
=== CONFIG_KEY_DH_OPERATIONS & CONFIG_CRYPTO_DH & CONFIG_CRYPTO_DES & CONFIG_CRYPTO_USER_API_SKCIPHER===
 
'''About'''
 
''These options enables ability to use iwd daemon (wpa_supplicant replacement)''
 
'''Location in menu'''
 
<pre class="shell>
Security Options --->
[*] Enable access key retention support
[*] Diffie-Hellman operations on retained keys
 
Cryptographic API  --->
[*] Diffie-Hellman algorithm
[*] DES and Triple DES EDE cipher algorithms
[*] User-space interface for symmetric key cipher algorithms</pre>
 
and these
<pre class="shell>
CONFIG_CRYPTO_USER_API_HASH
CONFIG_CRYPTO_ECB
CONFIG_CRYPTO_MD4
CONFIG_CRYPTO_MD5
CONFIG_CRYPTO_CBC
CONFIG_CRYPTO_SHA1
CONFIG_CRYPTO_SHA256
CONFIG_CRYPTO_SHA512
CONFIG_CRYPTO_AES
CONFIG_CRYPTO_DES
CONFIG_CRYPTO_CMAC
CONFIG_CRYPTO_HMAC
CONFIG_CRYPTO_ARC4
</pre>
'''pmOS specific'''
Enable only on recent mainline kernels. After enabling these options, you can use iwd daemon (better performance) instead of wpa_supplicant.
 
=== CONFIG_USER_NS ===
'''About'''
 
''User namespace''
 
''Required for BubbleWrap sandboxing used by The GNOME Web (Epiphany) and other software.''
 
'''pmOS specific'''
 
Phosh environment must have it enabled for Web browser (Epiphany) being functional.
 
'''Location in menu'''
 
<pre class="shell>
General setup --->
  Namespaces support --->
    [*] User namespace</pre>
 
=== SECCOMP ===
'''About'''
 
''Enable seccomp to safely compute untrusted bytecode''
 
''Required for BubbleWrap sandboxing used by The GNOME Web (Epiphany) and other software.''
 
'''pmOS specific'''
 
Phosh environment must have it enabled for Web browser (Epiphany) being functional.
 
== Anbox ==
 
To enable Anbox support, some options are required
 
=== CONFIG_SQUASHFS ===
 
'''About'''
 
''Squashfs is a highly compressed read-only filesystem for Linux.  It uses zlib, lzo or xz compression to compress both files, inodes and directories. squashfs is intended for general read-only filesystem use, for archival use (i.e. in cases where a .tar.gz file may be used), and in embedded systems where low overhead is needed.''
 
'''Anbox specific'''
 
Anbox uses a squashfs to store the Android rootfs.
 
=== CONFIG_SQUASHFS_XZ ===
 
'''About'''
 
''Squashfs support for reading squashfs file systems compressed with XZ compression.  XZ gives better compression than the default zlib compression, at the expense of greater CPU and memory overhead.''
 
'''Anbox specific'''
 
Anbox uses a ''xz-compressed'' squashfs.
 
=== CONFIG_SQUASHFS_XATTR ===
 
'''About'''
 
''Squashfs support for extended attributes (xattrs). Xattrs are name:value pairs associated with inodes by the kernel or by users (see the [https://www.systutorials.com/docs/linux/man/5-attr/ attr(5)] manual page).''
 
'''Anbox specific'''
 
For some reason, even if the squashfs is created with <code>-no-xattrs</code>,
Anbox seems to fail badly without.
 
=== CONFIG_ASHMEM ===
 
'''About'''
 
''The ashmem subsystem is a new shared memory allocator, similar to POSIX SHM but with different behavior and sporting a simpler file-based API.''
 
''It is, in theory, a good memory allocator for low-memory devices, because it can discard shared memory units when under memory pressure.''
 
'''Anbox specific'''
 
Android requires it, so you need it to run Anbox.
 
=== CONFIG_BINDER_IPC ===
 
'''About'''
 
''Binder is used in Android for both communication between processes and remote method invocation. This means one Android process can call a method/routine in another Android process, using Binder to identify, invoke and pass arguments between said processes.''
 
'''Anbox specific'''
 
Android uses it to communicate between process. It must be present for Anbox to work.
 
=== CONFIG_BINDERFS ===
 
'''About'''
 
''Binderfs is a pseudo-filesystem for the Android Binder IPC driver which can be mounted per-ipc namespace allowing to run multiple instances of Android. Each binderfs mount initially only contains a binder-control device. It can be used to dynamically allocate new binder IPC devices via ioctls.''
 
'''Anbox-on-postmarketOS specific'''
 
It should '''not''' be set, because binderfs support in Anbox is broken in postmarketOS. For now, we just use regular binder instead because we don't need several binders.
 
It could be an incompatibility with musl. In <code>sys/ioctl.h</code>, the ioctl function is prototyped as such: <code>int ioctl(int, int, ...);</code>, in accordance to POSIX. On the hand, in the linux programmer manual, ioctl is of type <code>int ioctl(int, unsigned long, ...);</code>. GCC warns about it: "Warning: overflow in conversion from 'long unsigned int' to 'int' change value from 3238552065 to -1056415231", but according to dalias on #musl it should be harmless.
 
=== CONFIG_ANDROID_BINDER_DEVICES ===
 
'''About'''
 
''Default value for the binder.devices parameter. The binder.devices parameter is a comma-separated list of strings that specifies the names of the binder device nodes that will be created. Each binder device has its own context manager, and is therefore logically separated from the other devices.''
 
'''Anbox specific'''
 
This must contain <code>binder</code>, as Anbox expects <code>/dev/binder</code>.
 
It should also contain <code>hwbinder</code> to be future-proof (as it will be required for Android 10).
 
=== CONFIG_TMPFS_XATTR ===
 
'''About'''
 
Xattr support for tmpfs.
 
'''Anbox specific'''
 
Android requires it because it sets xattr on files in /dev, which is a tmpfs. Otherwise you get errors such as this in <code>/var/lib/anbox/console.log</code> :
 
libc: fsetxattr failed to set context (u:object_r:dalvik_prop:s0) for "/dev/__properties__/u:object_r:dalvik_prop:s0"
libc: fsetxattr failed to set context (u:object_r:config_prop:s0) for "/dev/__properties__/u:object_r:config_prop:s0"
 
=== NETFILTER_XT_MATCH_COMMENT ===
 
'''About'''
 
It allows putting comments in iptables rules. It's a dummy module that ignore its <code>--comment=</code> argument.
 
depends on NETFILTER, NETFILTER_XTABLES and NETFILTER_ADVANCED.
 
'''pmOS specific'''
 
It is a requirement of anbox-bridge.sh, which we use in the openRC init script. Anbox won't start without that.
 
= See also =
 
* [https://cateee.net/lkddb/web-lkddb/ Linux Kernel Driver Database]
* [https://www.cnx-software.com/2013/05/23/how-to-find-configuration-options-quickly-in-make-menuconfig/ How to find configuration options quickly in make menuconfig]
 
[[Category:Technical Reference]]

Latest revision as of 12:29, 3 September 2024

Kernel configurations determine which features of the Linux kernel are enabled for a particular build, such as filesystems, camera, WiFi related options and a lot more. This article gives an overview of how kernel configs are managed in postmarketOS and how one can change them.

Why do we have multiple kernel configs?

We would ideally run mainline Linux without any patches on all devices and only have one kernel config per device architecture. But oftentimes we need to carry a few patches for our (Close to) Mainline kernels (used for devices in main and community categories). Another reason is that in many cases want to be on a specific, known-working version before we upgrade to the next one. Furthermore devices in the testing category may just use the downstream kernel to get the device booting at all. Because of that, you will find a lot of Linux kernels when looking at the postmarketOS specific package build recipes in pmaports.git.

Keeping kernel configs consistent

All kernel configs are stored inside pmaports (list them with find device -name 'config-*'). We ensure that they have specific options enabled, disabled or set to a certain value with a CI script that essentially runs pmbootstrap kconfig check. This pmbootstrap command reads our requirements from kconfigcheck.toml in the currently checked out pmaports branch and verifies that all kernels pass the requirements. See Kernel configuration/Adjusting multiple kernels for more information.

Future plans

At some point we would like to generate the kernel configs for main and community devices from fragments. Work on this has been started in pmaports#2492 (big thanks to Jenneron and everybody involved!). However this is quite the big undertaking and work has stalled. So we decided to improve and document the current process instead, which we will still need for devices in testing in any case.

Adjusting one kernel config

It is recommended to change kernel config options not just for one kernel, but for all where it makes sense (typically all devices in the community or main category as explained here). However before you do that, you should first edit the one kernel you are currently using on your device to test if the change has the desired effect.

You basically need to run pmbootstrap kconfig edit followed by the name of the kernel package, see Kernel configuration/Adjusting one kernel for details.

Subpages