Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] Empty /etc/kernel/postinst.d
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
bracecomputerlab
n00b
n00b


Joined: 12 Oct 2020
Posts: 13

PostPosted: Mon Oct 12, 2020 4:32 am    Post subject: [SOLVED] Empty /etc/kernel/postinst.d Reply with quote

I hope I am posting this in the correct forum section.
I regularly work on drm-next based Linux kernel codebase as a DRM (Direct Rendering Manager) developer (i.e., OpenChrome).
Since Canonical phased out future 32-bit x86 support, I started to look into migrating to Gentoo Linux as my standard development platform.
I have not had issues compiling and installing drm-next based Linux kernel with Ubuntu (Xubuntu and Lubuntu), Debian, and OpenSUSE, but I am having issues with Gentoo Linux.
After not being able to generate an initramfs image for the custom compiled Linux kernel, I finally figured out that there are build scripts missing in /etc/kernel/postinst.d for "make install" to properly install an associated initramfs and setup GRUB properly.
Which Gentoo package do I need to install to get the proper build scripts installed in /etc/kernel/postinst.d?
I looked around for a solution for the past 4 days, but I still cannot figure it out what to do.
_________________
Kevin Brace
Brace Computer Laboratory blog
https://bracecomputerlab.com


Last edited by bracecomputerlab on Thu Oct 15, 2020 8:06 am; edited 1 time in total
Back to top
View user's profile Send private message
fedeliallalinea
Administrator
Administrator


Joined: 08 Mar 2003
Posts: 31443
Location: here

PostPosted: Mon Oct 12, 2020 5:39 am    Post subject: Reply with quote

I'm not sure but I think you should use sys-apps/debianutils with installkernel use flag enabled.
This package install the script /sbin/installkernel that run script in /etc/kernel/postinst.d
Code:
...
# If installing in the usual directory, run the same scripts that hook
# into kernel package installation.  Also make sure the PATH includes
# /usr/sbin and /sbin, just as dpkg would.
if [ "$dir" = "/boot" ]; then
  PATH="$PATH:/usr/sbin:/sbin" \
    run-parts --verbose --exit-on-error --arg="$ver" --arg="$dir/$img_dest-$ver" \
    /etc/kernel/postinst.d
fi
...

_________________
Questions are guaranteed in life; Answers aren't.
Back to top
View user's profile Send private message
mike155
Advocate
Advocate


Joined: 17 Sep 2010
Posts: 4438
Location: Frankfurt, Germany

PostPosted: Mon Oct 12, 2020 10:35 am    Post subject: Reply with quote

fedeliallalinea wrote:
I'm not sure but I think you should use sys-apps/debianutils with installkernel use flag enabled.
This package install the script /sbin/installkernel that run script in /etc/kernel/postinst.d

Yes, because
Code:
cd /usr/src/linux     # Linus's vanilla kernel
make
make install

calls
Code:
./arch/x86/boot/install.sh

and that script calls '/sbin/installkernel' (if it exists):
Code:
# User may have a custom install script

if [ -x ~/bin/${INSTALLKERNEL} ]; then exec ~/bin/${INSTALLKERNEL} "$@"; fi
if [ -x /sbin/${INSTALLKERNEL} ]; then exec /sbin/${INSTALLKERNEL} "$@"; fi

Gentoo doesn't install '/sbin/installkernel'. But sys-apps/debianutils[installkernel] does.
Back to top
View user's profile Send private message
bracecomputerlab
n00b
n00b


Joined: 12 Oct 2020
Posts: 13

PostPosted: Mon Oct 12, 2020 1:36 pm    Post subject: Reply with quote

I already have sys-apps/debianutils installed, and there is /sbin/installkernel already installed.
It appears that /sbin/installkernel script is being executed (I confirmed this by tinkering with the script to display some random messages.), but when I read the script, I see the following near the end of the script.

Quote:

# If installing in the usual directory, run the same scripts that hook
# into kernel package installation. Also make sure the PATH includes
# /usr/sbin and /sbin, just as dpkg would.
if [ "$dir" = "/boot" ]; then
PATH="$PATH:/usr/sbin:/sbin" \
run-parts --verbose --exit-on-error --arg="$ver" --arg="$dir/$img_dest-$ver" \
/etc/kernel/postinst.d
fi


Again, I do not see anything over at /etc/kernel/postinst.d.
At least in Ubuntu, there are scripts that will generate an initramfs image and update GRUB.
How do I perform the equivalent in Gentoo Linux?


mike155 wrote:
fedeliallalinea wrote:
I'm not sure but I think you should use sys-apps/debianutils with installkernel use flag enabled.
This package install the script /sbin/installkernel that run script in /etc/kernel/postinst.d

Yes, because
Code:
cd /usr/src/linux     # Linus's vanilla kernel
make
make install

calls
Code:
./arch/x86/boot/install.sh

and that script calls '/sbin/installkernel' (if it exists):
Code:
# User may have a custom install script

if [ -x ~/bin/${INSTALLKERNEL} ]; then exec ~/bin/${INSTALLKERNEL} "$@"; fi
if [ -x /sbin/${INSTALLKERNEL} ]; then exec /sbin/${INSTALLKERNEL} "$@"; fi

Gentoo doesn't install '/sbin/installkernel'. But sys-apps/debianutils[installkernel] does.

_________________
Kevin Brace
Brace Computer Laboratory blog
https://bracecomputerlab.com
Back to top
View user's profile Send private message
fedeliallalinea
Administrator
Administrator


Joined: 08 Mar 2003
Posts: 31443
Location: here

PostPosted: Mon Oct 12, 2020 2:01 pm    Post subject: Reply with quote

You can use genkernel if you want a automated tool for compile, install and create initramfs for the kernel.
_________________
Questions are guaranteed in life; Answers aren't.
Back to top
View user's profile Send private message
GDH-gentoo
Veteran
Veteran


Joined: 20 Jul 2019
Posts: 1802
Location: South America

PostPosted: Mon Oct 12, 2020 3:55 pm    Post subject: Reply with quote

To clarify:
bracecomputerlab wrote:
After not being able to generate an initramfs image for the custom compiled Linux kernel, I finally figured out that there are build scripts missing in /etc/kernel/postinst.d for "make install" to properly install an associated initramfs and setup GRUB properly.
Which Gentoo package do I need to install to get the proper build scripts installed in /etc/kernel/postinst.d?
In general, unlike other distributions, Gentoo does not do automagic initramfs generation and GRUB configuration update. They are the user's responsibility.

Some users run Gentoo without an initramfs, and some users don't use GRUB, they use other bootloaders, or plain EFI stub kernels.

The closest thing to that kind of automagic would be using Genkernel, as fedeliallalinea pointed out.
Back to top
View user's profile Send private message
bracecomputerlab
n00b
n00b


Joined: 12 Oct 2020
Posts: 13

PostPosted: Wed Oct 14, 2020 1:31 pm    Post subject: Reply with quote

Okay, I finally figured out how to generate an initramfs of my liking.

Quote:
# genkernel --kerneldir=./ --kernel-config=./.config initramfs


Adding --kerneldir option to genkernel did the trick.
Just to conclude this post, this is how I was able to successfully install and boot a custom compiled Linux kernel that is not distributed by Gentoo (i.e., drm-next based Linux kernel).

Quote:
# make modules_install
# make install
# genkernel --kerneldir=./ --kernel-config=./.config initramfs
# grub-mkconfig -o /boot/grub/grub.cfg


Thank you all for responding to my question, and the explanations I received did convince me to look around for something like --kerneldir option of genkernel.
_________________
Kevin Brace
Brace Computer Laboratory blog
https://bracecomputerlab.com
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