LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 07-05-2020, 02:20 AM   #1
Lockywolf
Member
 
Registered: Jul 2007
Posts: 683

Rep: Reputation: 253Reputation: 253Reputation: 253
Question Does anyone have a debugging kernel SlackBuild? (or the experience of making one)


Hello, everyone.

I seem to be needing a few features of the debugging kernel (such a KPROBES).
I have built the kernel myself and had a few successful days of work, but the kernel keeps getting updated almost daily, so just through that I'd better make a script that rebuilds everything as soon as the kernel is updated.

So in order to avoid reinventing the wheel, I'm asking if anyone has had such a thing done before and can share their scripts?

Additionally, if I end up rebuilding the kernel anyway, suggestions on a good "debugging" kernel .config are welcome.
 
Old 07-05-2020, 05:07 AM   #2
gouttegd
Member
 
Registered: Nov 2019
Location: London, UK
Distribution: Slackware
Posts: 92

Rep: Reputation: 161Reputation: 161
Hi,

I do have such a script, pasted below.

Note that I made no particular effort to make the script “generic”, it is tailored for my needs and probably cannot (or should not) be directly re-used without some adjustments.

Note also that the script does not take care of configuring the kernel: it assumes the kernel source tree has already been configured (using make config or any similar configuration command).

Code:
#!/bin/bash

set -e

if [ ! -f Kbuild ]; then
    echo "This script should be run in a Linux source tree!"
    exit 1
fi

MACHINE=${MACHINE:-$(uname -n | cut -d. -f1)}
JOBS=${JOBS:-7}
OUT=${OUT:-/tmp}
PKG=${PKG:-$OUT/kernel}

KERNEL_RELEASE=$(make -s kernelrelease)
KERNEL_VERSION=$(make -s kernelversion)

# Extract the build number from CONFIG_LOCALVERSION
BUILD=$(echo ${KERNEL_RELEASE#*-} | tr a-z A-Z)
[ "$BUILD" != "$KERNEL_RELEASE" ] || BUILD=1GGD

# Build the kernel amd the modules
make -j $JOBS bzImage
make -j $JOBS modules

# Install modules in stage directory
make modules_install INSTALL_MOD_PATH=$PKG
rm $PKG/lib/modules/$KERNEL_RELEASE/{source,build}

# Delete module signing key
rm certs/signing_key.pem

# Install kernel and associated files in /boot
install -D -m 0644 arch/x86_64/boot/bzImage $PKG/boot/vmlinuz-$KERNEL_RELEASE
install    -m 0644 System.map               $PKG/boot/System.map-$KERNEL_RELEASE
install    -m 0644 .config                  $PKG/boot/config-$KERNEL_RELEASE

# Install the kernel in the EFI filesystem
install -D -m 0644 arch/x86_64/boot/bzImage $PKG/boot/efi/EFI/Slackware/vmlinuz-$KERNEL_RELEASE

# Post-install script:
# * Build the initrd and copy it to the EFI filesystem
# * Add an ELILO entry for the new kernel
mkdir -p $PKG/install
cat <<EOF >$PKG/install/doinst.sh
#!/bin/sh

mkinitrd -F -c -k $KERNEL_RELEASE -o boot/initrd-$KERNEL_RELEASE.gz -s tmp/initrd-$KERNEL_RELEASE-tree
rm -rf tmp/initrd-$KERNEL_RELEASE-tree
cp boot/initrd-$KERNEL_RELEASE.gz boot/efi/EFI/Slackware/initrd-$KERNEL_RELEASE.gz

cat <<EOG >> boot/efi/EFI/Slackware/elilo.conf

image=vmlinuz-$KERNEL_RELEASE
  label=linux-$MACHINE-$KERNEL_RELEASE
  initrd=initrd-$KERNEL_RELEASE.gz
  read-only
EOG

echo
echo Kernel installed. Do not forget to edit
echo /boot/efi/EFI/Slackware/elilo.conf to boot
echo on the new kernel by default.
echo

EOF
chmod 755 $PKG/install/doinst.sh

# Add package description
cat <<EOF >$PKG/install/slack-desc
kernel-$MACHINE: kernel-$MACHINE (custom-built Linux kernel)
kernel-$MACHINE: 
kernel-$MACHINE: This is a Linux kernel specifically built for $MACHINE.
kernel-$MACHINE: 
kernel-$MACHINE: 
kernel-$MACHINE: 
kernel-$MACHINE: 
kernel-$MACHINE: 
kernel-$MACHINE: 
kernel-$MACHINE: 
kernel-$MACHINE: 
EOF

# Package the whole thing
cd $PKG
mkdir -p $OUT
PACKAGING="
chown root:root . -R
/sbin/makepkg -l y -c n $OUT/kernel-$MACHINE-$KERNEL_VERSION-x86_64-$BUILD.txz
rm -rf $PKG
"
su -c "$PACKAGING"
 
1 members found this post helpful.
Old 07-05-2020, 01:03 PM   #3
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 8,792

Rep: Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656
A minor tweak you might like to prevent needing to edit your elilo.conf afterwards. Instead of using cat, use sed, which can add it to the top of the Linux stanzas rather than the bottom. This would prevent you from needing to edit the conf file after installation and the newest kernel would always be the default.

Looking at my elilo.conf, there is a # before the individual stanzas start, so if you search for that, you can add text right after it (you could also add text to search for, like "# Linux Stanzas" to prevent any issues if you add additional comments). This will redirect the output into an elilo.conf in your package, which will overwrite the one on your system when you install the package.

Code:
sed "/#/aimage=vmlinuz-$KERNEL_RELEASE\n  label=linux-$MACHINE-$KERNEL_RELEASE\n  initrd=initrd-$KERNEL_RELEASE.gz\n  read-only\n" /boot/efi/EFI/Slackware/elilo.conf > $PKG/boot/efi/EFI/Slackware/elilo.conf
 
Old 07-05-2020, 05:23 PM   #4
gus3
Member
 
Registered: Jun 2014
Distribution: Slackware
Posts: 490

Rep: Reputation: Disabled
Also, the Linux kernel configuration itself includes a debugging option. It's under:

Code:
-> Kernel hacking
  -> Compile-time checks and compiler options
    -> Compile the kernel with debug info
 
  


Reply

Tags
debug, kernel, rebuild, slackware, update



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference between kernel - debugging and application debugging topworld Linux - Software 2 03-30-2006 12:50 AM
Visual Debugging and Linux Kernel Debugging Igor007 Programming 0 09-30-2005 10:33 AM
Does any have experience with installing two linux and one FreeBSD on one Harddrive? babyboss Fedora 2 10-24-2004 03:13 AM
Does anyone here have experience with installing two linux systems and one FreeBSD? babyboss Slackware 2 10-23-2004 03:45 AM
Does anyone have experience installing lvm in debian Stanley56 Debian 4 02-17-2004 05:47 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 12:29 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration