lainchan / Ω
How to compile a minimal custom kernel on arch Linux
The Fin · 2022-02-03 12:12
Hey guys, i was wodering the steps to this.
I heard modprobed-db and make localmodconfig are the commads but i fuarrrking don't know TO compile the kernel and how to use the modprobe to create the custom kernel
Tyrell Wellick · 2022-02-03 14:13
>>56624
Read the "Kernel" and "Arch Build System" articles on the wiki. Modifying the existing "linux" PKGBUILD to make it take modprobed-db into account would be the best way to go about this. Some alternative kernels in the AUR do use modprobed-db, you can take inspiration from their PKGBUILDs.
Tyrell Wellick · 2022-02-03 20:56
>>56624
Download the source of the version you want from kernel.org . Then run "make menuconfig" for the menu, where you can select what to include. When you're done, do "make -j[cores]", "make install", and "make modues_install". You are done with the kernel now. As for initramfs, this is optional. I dont use one and just built in everything required for booting (fs drivers and nvme drivers for me). If you want one, i think arch uses mkinitcpio, look into it first.
Tank · 2022-02-03 22:03
For security reasons, we do not recommend using Linux since it lacks many modern exploit mitigations and sandboxing. You should use Windows 11, MacOS, or ChromeOS instead.
Polite sage for off-topic.
Ivan Petrov · 2022-02-04 02:35
>>56626
WHY DOES EVERY NIGGER SAY READ THE WIKI
I READ THE fuarrrkIN WHICH IS WHY IM REPEATING MY QUESTION
Miho Iwakura · 2022-02-04 02:40
>>56646
https://wiki.archlinux.org/title/Kernel/Arch_Build_System
Pretty straight forward anon.
Lady Jessica · 2022-02-04 04:10
>>56647
seems like you can't build a kernel yourself
shut the fuarrrk up liar bloat fuarrrk
Neuromancer · 2022-02-04 04:44
Hey OP I've been there and it can be a pain. First time I did it it took me forever to get it even to boot.
First of all, check up on the hardware your computer uses. `lspci` and `lsusb` commands are good places to start with.
After you've downloaded the kernel source from i.e. kernel.org, and unpacked it, enter the dir. There's a few commands you can use. Start with `make help` and skim over it. Pipe it to less (`make help|less`) if you need to.
There's a few approaches you can take. Easiest is to just use the current config you're using, likely located in gziped form at /proc/config.gz. An easy and likely good approach can be as follows. I assume you know basic shell commands so I'm not going to baby you.
You can zcat that config to .config in the kernel dir. Its a good place to start. After that, make localmodconfg should help automatically clean it up a bit for you. make menuconfig opens a menu with a lot of options. Go through kinda slowly with the output of lspci and lsusb in another window and try to check that things you need are on, either as modules or buit in. Check on other things like filesystems.
There will be some drivers you can untick just en masse often, but generally fine to err on the side of caution. Eventually you'll be satisfied.
Now you can just run a good old make -jN and let it go. It will probably take a bit unless you have a good machine and a well pruned config. Eventually it will be done, and you'll have your vmlinuz bin or whatever its called and your modules. Run (as root of course) a make modules_install, and copy the vmlinuz over to your (properly mounted) boot partition, and update the bootloader. Should be good to go. Make sure you have a backup plan for if the machine doesnt boot.
If the boot fails, read the error messages. if its not obvious what broke, there's probably a dozen people on the internet who had the same problem and can help you nail it down. There's a lot of little problems like with the FS that can matter. This is a lot easier without a initramfs, or things like fde, and its probably good to whet your teeth on a more conventional system if you want to use things like that later.
Hope that helps man I'm pretty weird feeling and a mite dizzy now.
Roger Pollack · 2022-02-04 06:56
You ain't gonna save much doing this, install liquorix-zen kernel and be done with. Your computer is too old for modern software in general.
Frank Garza · 2022-02-04 11:36
>>56649
>seems like you can't build a kernel yourself
First of all, Install Gentoo. And yes, you can build the kernel yourself. Look at all those kernels at AUR, for example. Here is the relevant wiki page: https://wiki.archlinux.org/title/Kernel/Arch%20Build%20System
fsociety · 2022-02-05 14:40
For some reason all distros like to reinvent the wheel with their own overengineered build system. Ignore that, just follow >>56637 instructions. Works on any distro that provides a toolchain. Be sure to make a copy of your /boot/grub/grub.cfg in case your package manager screws it up in the future.
Also just set everything you need or think you could possibly use in the future to =y. Modules are stupid, introduce all kinds of vermagic problems and having to work out the dependencies for your ramfs all to POSSIBLY save just a few mb of ram. Modules are for closed source drivers and development, not for basic drivers everybody needs like every popular distro seems to think.
Pris · 2022-02-08 21:23
install gentoo. literally. and then if you dont want to compile packages just save a copy of the kernel and install arch. but thats kinda stupid. install gentoo.
Project 2501 · 2022-02-23 19:33
>>56806
or just do >>56637
SHODAN · 2022-04-18 09:16
>>56637
This is the generic way but it is not practical. Perhaps it is doable with the LTS version. Essentially, you need to download the source and:
lspci -v
lscpu
hwinfo
dmesg
cd /usr/src/linux
# first time configuration
# use hwinfo, dmesg, lspci, Gentoo wiki pages, etc. to select the config options.
# Pro Tip: it is recommended to select display drivers as modules.
# Pro Tip: press ? to get help on the highlighted config option.
# Pro Tip: press / to search for config options (You can use number keys to jump to a search result)
# Pro Tip: you don't have to enable NTFS write support in the kernel. you could use sys-fs/ntfs3g instead.
make menuconfig
# when you upgrade kernel version:
#cp /root/old_config /usr/src/linux/.config
#make oldconfig
# build and install the kernel and the modules:
make -j4
make modules_install
make install
# rebuild initramfs and update Grub
# Important: https://wiki.gentoo.org/wiki/Microcode
genkernel --microcode --install initramfs # you could also use dracut, etc.
grub-mkconfig -o /boot/grub/grub.cfg
>>56626
>>56647
>Read the "Kernel" and "Arch Build System"
this if using Arch or a distro that's based on Arch.
>>56664
>>56806
>install Gentoo
This to be honest. Also, remember to: USE="symlink initramfs" emerge sys-kernel/gentoo-sources sys-kernel/linux-firmware sys-kernel/genkernel
Anonymous · 2022-04-25 14:32
Not OP, posting this here, in case other Arch Linux lains want to learn too.
First, you would want to have the modprobed-db system service running for awhile. Use every piece of hardware with/in your system, and run it manually, make sure not to miss anything.
Now, run (in a preferably new, clean directory) asp export linux
this will get you a directory with a nice PKGBUILD file. You would want to modify the file. Modify it according to the Arch wiki article Kernel/Arch_Build_System, don't compile docs and rename it. When changing prepare(), remove the make olddefconfig, and replace it with the two lines:
make LSMOD=$HOME/.config/modprobed.db localmodconfig
make menuconfig This will show you a terminal menu for configuring the kernel during build, I suggest you do it along this video: https://www.youtube.com/watch?v=NVWVHiLx1sU
It's on gentoo, but most of the video he is in that same make menuconfig menu, and he goes over many and explains relevant options for desktop users. The kernel in the video is a little older too, but still relevant.
If you have trouble with gpg keys, check out this: https://bbs.archlinux.org/viewtopic.php?id=268750
One last thing: in /etc/makepkg.conf edit the CFLAGS variables -march and -mtune to "native", here is a relevant part in the GCC docs: https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html
I'm adding my own modified PKGBUILD, Lain, I want you to run it with diff against the default one, see what I changed and understand it.
This is my method, I'm new to custom kernels and if any other Lain has tips, or suggestions for improvements please tell me. Newbie lains, feel free to ask questions too. I guess this is custom kernel general now.
Eldon Tyrell · 2022-05-20 08:57
if you gotta ask then you have no reason to do this
stay behind the filter, you'll be happier there
fyi, why would you people use an OS where you need to be spoonfed everything? just to be different or
a thread died for this, obviously not the only half channer in this thread either
gross