LinuxQuestions.org
Review your favorite Linux distribution.
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 10-24-2011, 05:16 PM   #1
wootletootle
Member
 
Registered: Jul 2002
Location: New Zealand
Distribution: slackware
Posts: 81

Rep: Reputation: 15
Custom kernel install


I suspect this is an FAQ but...

I've got to this point:

(a) compiled the new kernel [N] and associated modules
(b) copied the kernel file [N] to the boot directory
(c) inserted a new stanza in lilo.conf pointing to the new kernel [N]
(d) run lilo

On reboot I'd like to be able to choose between the old kernel [O]
and the new kernel [N].

Q1: How to associate the module directory tree /lib/modules/[*]
with the appropriate kernel (*=N,O)?

Q2: Ditto for /boot/config and /boot/System.map

Up till now I've chosen to rename the relevant files and directories
prior to rebooting but this is not very convenient or practical.
Some people have mentioned the configuration option LOCAL_VERSION
but I'm not sure how to set this up.

Your comments please.

Last edited by wootletootle; 10-24-2011 at 11:54 PM.
 
Old 10-24-2011, 05:23 PM   #2
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233

Rep: Reputation: 406Reputation: 406Reputation: 406Reputation: 406Reputation: 406
well, actually you don't copy the kernel to /boot, you run 'make install' and perhaps 'make modules-install' (or something like that)
which will put the modules in /lib/modules/{kernel version} automatically (do that as root of course), this should also automatically add the line in lilo.conf and run lilo
 
Old 10-24-2011, 05:43 PM   #3
wootletootle
Member
 
Registered: Jul 2002
Location: New Zealand
Distribution: slackware
Posts: 81

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by frieza View Post
well, actually you don't copy the kernel to /boot, you run 'make install' and perhaps 'make modules-install' (or something like that) which will put the modules in /lib/modules/{kernel version} automatically (do that as root of course), this should also automatically add the line in lilo.conf and run lilo
Yes, but will this allow me to properly choose between the old and new kernels at boot time?
My experience has usually been "kernel panic". In principal I think there needs to
be old [O] and new [N] versions of: the kernel, the module tree, config and System.map.
In choosing the [O] or [N] kernel at boot time how can I associated with it the
[O] or {N] version of the module tree, config and System.map?
 
Old 10-24-2011, 05:45 PM   #4
kingbeowulf
Senior Member
 
Registered: Oct 2003
Location: WA
Distribution: Slackware
Posts: 1,266
Blog Entries: 11

Rep: Reputation: 744Reputation: 744Reputation: 744Reputation: 744Reputation: 744Reputation: 744Reputation: 744
Better yet, you could build kernel packages (see slackware source) and/or follow this guide: http://alien.slackbook.org/dokuwiki/...kernelbuilding

Personally, if ist good enough for AlienBOB, its good enough for me.
 
Old 10-24-2011, 05:57 PM   #5
qweasd
Member
 
Registered: May 2010
Posts: 621

Rep: Reputation: Disabled
Quote:
Originally Posted by wootletootle View Post
Q1: How to associate the module directory tree /lib/modules/[*]
with the appropriate kernel (*=N,O)?
Like you said, use Local version setting. If you make xconfig, it's the third setting in General setup. D-click it and put something there, like "-foo". Then make and install as usual. ls /lib/modules to make sure it worked.
 
Old 10-24-2011, 06:04 PM   #6
dive
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Slackware
Posts: 3,467

Rep: Reputation: Disabled
Quote:
Originally Posted by frieza View Post
well, actually you don't copy the kernel to /boot, you run 'make install' and perhaps 'make modules-install' (or something like that)
which will put the modules in /lib/modules/{kernel version} automatically (do that as root of course), this should also automatically add the line in lilo.conf and run lilo
Well, actually some of us prefer to copy the kernel to /boot with a -custom name or similar, this stops it overwriting the stock slackware kernel/link.

Nothing will be put in lilo.conf automatically; this must be added manually.
 
Old 10-24-2011, 08:26 PM   #7
ReaperX7
LQ Guru
 
Registered: Jul 2011
Location: California
Distribution: Slackware64-15.0 Multilib
Posts: 6,558
Blog Entries: 15

Rep: Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097
It's far easier to copy the kernel bzImage, system.map, and .config to /boot and then create symlinks and/or rename files as needed if you need to use multiple kernels.

The "install" option should only be used really on the modules as "make modules_install".
 
Old 10-24-2011, 08:54 PM   #8
wootletootle
Member
 
Registered: Jul 2002
Location: New Zealand
Distribution: slackware
Posts: 81

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by ReaperX7 View Post
It's far easier to copy the kernel bzImage, system.map, and .config to /boot and then create symlinks and/or rename files as needed if you need to use multiple kernels.
Yes, that's more or less what I have been doing. So here I am with modules, config, System map all configured
for kernel [N]. I reboot, select [N] in the boot loader and get "kernel panic". How do I then go about resetting
symlinks so that I can boot to the old kernel [O]? Only way I know of is to boot to the Slackware CD, chroot, and do it from
there. I was/am hoping for another method whereby if [N] doesn't work ("kernel panic") I can reboot and select [O]
and so return to my old kernel...

Thanks everyone for comments, I am still digesting them

Last edited by wootletootle; 10-24-2011 at 08:59 PM.
 
Old 10-24-2011, 09:20 PM   #9
colorpurple21859
LQ Veteran
 
Registered: Jan 2008
Location: florida panhandle
Distribution: Slackware Debian, Fedora, others
Posts: 7,346

Rep: Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589
If the new kernel version number is the same as the old kernel, then when you do a make modules-install the the old kernel modules will be replaced with the new kernel modules. If you don't have all the needed modules installed then booting problems result. It is best to do as qweasd says and to add a version extension to the end of the kernel version number so as not to overwrite the old kernel modules. To add the new kernel version to lilo will need to edit /etc/lilo.conf and add the new kernel version entry and then run lilo at the command prompt. If your upgrading to a newer kernel version number then this isn't usually a problem since the old kernel version number and the new kernel version number will be different.
 
Old 10-24-2011, 09:47 PM   #10
wootletootle
Member
 
Registered: Jul 2002
Location: New Zealand
Distribution: slackware
Posts: 81

Original Poster
Rep: Reputation: 15
Thanks colorpurple. There's clearly something I have not understood. I selected LOCAL_VERSION
in menuconfig with ext=25.10.11 (todays date). After make; make modules; make modules_install;
there is a module tree /lib/modules/2.6.29.6-smp-25.10.11. The kernel binary is bzImage and I assume
that the local version extension is coded into it. I copied this [N] to /boot. The old kernel [O]
is vmlinuz (symlink). I didn't bother about changing config or System.map in /boot at this stage.
The lilo entries are

# Linux bootable partition config begins
image = /boot/vmlinuz
root = /dev/sda5
label = Slack
read-only # Partitions should be mounted read-only for checking
# Linux bootable partition config ends
#
# Linux bootable partition config begins
image = /boot/bzImage
root = /dev/sda5
label = Slack32
read-only # Partitions should be mounted read-only for checking
#

When I select Slack32 in the loader the boot process terminates with
"No filesystem could mount root, tried: romfs
Kernel panic"

Is the kernel panic because of some error in my compile/install procedure
(something to do with initrd?) or is it something else?
 
Old 10-24-2011, 10:00 PM   #11
colorpurple21859
LQ Veteran
 
Registered: Jan 2008
Location: florida panhandle
Distribution: Slackware Debian, Fedora, others
Posts: 7,346

Rep: Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589
it is best to copy the bzImage with the version number as such; /boot/bzImage-2.6.29.6-smp-25.10.11 and will also need to copy System.map to /boot/System.map-2.6.29.6-smp-25.10.11 also. this helps prevents confusion. If you don't have the file system and driver modules needed for your disk hardware compiled into the kernel you will need to make an initrd for that kernel in order for it to boot correctly. If you have all the items needed to boot compiled into the kernel instead of as modules then you won't need an /boot/initd.

edit: if your using an initrd will need to add a initrd line to your lilo.conf file

Last edited by colorpurple21859; 10-24-2011 at 10:17 PM.
 
Old 10-24-2011, 10:27 PM   #12
wootletootle
Member
 
Registered: Jul 2002
Location: New Zealand
Distribution: slackware
Posts: 81

Original Poster
Rep: Reputation: 15
Good information, colorpurple. The problem almost certainly is with
the initrd, anyway I'll proceed under that assumption. So it appears
that it's not a simple matter to boot alternative kernels contained
in the same partition: kernel, module tree, config, System.map
and initrd-tree all have to be defined and then symlinked. It would
be neat to find a way to do it without the hand configuration.
There's a real need for it, I would say, especially when building
and testing a custom kernel...
 
Old 10-24-2011, 10:48 PM   #13
qweasd
Member
 
Registered: May 2010
Posts: 621

Rep: Reputation: Disabled
Since I build kernel whenever bored, I tried to streamline the install process as much as possible. Like the OP, I tried to make all the names (and module locations) distinct for each build, even for the same kernel version. Here's what I do whenever I have an itch to update:

Code:
git pull
make oldconfig
make xconfig # tweak settings, change local version
make
kinstall mainline
# copy and paste the output into lilo.conf, change labels as needed.
lilo
where kinstall is just a more fail-safe way to name everything correctly (review and edit variables in the front before use):

Code:
#!/bin/bash
LINUX_SOURCE_PATH=/usr/src/linux
IMAGE_PATH=arch/x86_64/boot/bzImage # relative OK
INSTALL_PATH=/boot
LILO_ROOT=/dev/sdb1 # partition where image is located
LILO_LABEL=Slackware

# Exit on most errors.
set -e
# Customize the name of the installed image.
b=$( for w in $1 ; do echo $w ; break ; done )
if [ -n "$b" ] && [ "$b" = "$1" ] ; then
    BRANCH_NAME=$1
else
    echo "Supply a one-word image name, like mainline or stable." >&2
    exit 1
fi

cd $LINUX_SOURCE_PATH

# Extract kernel version.
KERNEL_RELEASE=$(cat include/config/kernel.release)

# Install modules and the image, build initrd.
make modules_install
cp -v $IMAGE_PATH $INSTALL_PATH/vmlinuz-$BRANCH_NAME-"$KERNEL_RELEASE"
cp -v System.map $INSTALL_PATH/System.map-"$KERNEL_RELEASE"
cd $INSTALL_PATH
mkinitrd -o initrd-$BRANCH_NAME-"$KERNEL_RELEASE" -k "$KERNEL_RELEASE"

# Report
echo "Your shiny new kernel:"
echo '# Linux bootable partition config begins'
echo 'image = '$INSTALL_PATH/vmlinuz-$BRANCH_NAME-"$KERNEL_RELEASE"
echo '  initrd = '$INSTALL_PATH/initrd-$BRANCH_NAME-"$KERNEL_RELEASE"
echo '  root = '$LILO_ROOT
echo '  label = '$LILO_LABEL
echo '  read-only # Partitions should be mounted read-only for checking'
echo '# Linux bootable partition config ends'
You can still get a panic if your initrd can't recognize your filesystem. My solution was to compile ext? into the kernel. I really see no point doing otherwise.
 
1 members found this post helpful.
Old 10-24-2011, 11:20 PM   #14
wootletootle
Member
 
Registered: Jul 2002
Location: New Zealand
Distribution: slackware
Posts: 81

Original Poster
Rep: Reputation: 15
Smile

Very nice, qweasd
 
Old 10-24-2011, 11:45 PM   #15
ReaperX7
LQ Guru
 
Registered: Jul 2011
Location: California
Distribution: Slackware64-15.0 Multilib
Posts: 6,558
Blog Entries: 15

Rep: Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097
If you work from the /usr/src/linux directory you can fairly use these commands to move things into your system:

make prepare
make xconfig (I prefer xconfig as you can scan for settings from the console prompt that may have changed and need reseting)
make bzImage modules
make modules_install
cp arch/x86/boot/bzImage /boot/vmlinuz-custom-3.0.7
cp System.map /boot/System.map-custom-3.0.7
cp .config /boot/config-custom-3.0.7
cd /boot
rm System.map
ln -s System.map-custom-3.0.7 System.map
ln -s vmlinuz-custom-3.0.7 vmlinuz

Afterwards you simply execute "lilo" from any command prompt and then reboot.

Last edited by ReaperX7; 10-24-2011 at 11:48 PM.
 
  


Reply



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
how do you install a custom kernel in debian baronobeefdip Debian 9 08-21-2011 02:37 AM
Custom Install Kernel? ericbobbitt SUSE / openSUSE 2 04-06-2006 10:28 AM
How can I Install Modules for Custom Kernel dauphinfay Linux - General 3 03-19-2006 09:48 AM
Custom kernel for Fedora 3 install godhugh Fedora - Installation 0 01-13-2005 02:32 PM
Custom install with newer kernel bones996 Red Hat 3 11-12-2003 04:06 AM

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

All times are GMT -5. The time now is 09:07 AM.

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