You are not logged in.

#1 2004-04-25 19:23:56

wdemoss
Member
From: WV - USA
Registered: 2004-01-18
Posts: 222

Install kernel using "make install"

There has been some discussion of the proper way to compile a custom kernel for arch lately on the forums. I've been doing some research lately of options of doing this. Also, in the current wiki entry, it mentions not to use make install because it runs lilo. Following I'll outline a differnt way to do it. If others think it is of value, then i'll put it into the wiki.

add the following script into /sbin/installkernel

#!/bin/sh
#
# Arguments:
#   $1 - kernel version
#   $2 - kernel image file
#   $3 - kernel map file
#   $4 - default install path (blank if root directory)
#
 
#
# define input variables
#
# assume default install path is /boot
# install_path=$4
#
kver=$1
kimg=$2
kmap=$3
 
vmlinuz=/boot/vmlinuz-$kver
sysmap=/boot/System.map-$kver
kconfig=/boot/kconfig-$kver
 
 
#
# check for previous versions
#
if [ -f $vmlinuz ]; then cp $vmlinuz $vmlinuz.old; fi
if [ -f $sysmap ]; then cp $sysmap $sysmap.old; fi
if [ -f $kconfig ]; then cp $kconfig $kconfig.old; fi
 
 
#
# install the image and map files
#
cat $kimg > $vmlinuz
cp $kmap $sysmap
cp $(dirname "$kmap")/.config $kconfig
 
 
#
# Check for grub, then lilo
#
grub_menu=/boot/grub/menu.lst
grub_update_conf=/etc/grub-update.conf
 
if [ -f $grub_menu ] && [ -f $grub_update_conf ]; then
     
    source $grub_update_conf
 
    # don't update it if it already exists
    if [ 0 -eq $(grep -sc "vmlinuz-$kver" $grub_menu) ]; then
 
        cp $grub_menu $grub_menu.bck
 
        # off course we'll want the newly compiles one to be the default
        default=$(grep -sc "^title" $grub_menu)
        sed -i "s/^default *[0-9]/default   $default/" $grub_menu
 
        echo                                                >> $grub_menu
        echo "# Autogenerated by kernel $kver"              >> $grub_menu
        echo "title linux $kver"                            >> $grub_menu
        echo "root $grub_root_loc"                          >> $grub_menu
        echo "kernel $grub_boot_loc/vmlinuz-$kver $kopts"   >> $grub_menu
        echo                                                >> $grub_menu
 
    fi
 
elif [ -x /sbin/lilo ]; then
 
    /sbin/lilo -v
 
fi

Add the following to /etc/grub-update.conf if you use grub. Edit the options for your system.

 
# grub boot location
grub_boot_loc="(hd0,1)"
 
# grub root location
grub_root_loc="(hd0,3)"
 
# kernel startup options
kopts="root=/dev/discs/disc0/part4 ro vga=838"

1.) extract kernel source in directory that is not /usr/src.
2.) su - root
3.) mv /path/to/linux-2.6.x to /usr/src/linux-2.6.x-[custom] where custom is whatever you want to use as an extension, for example I use "-wfd".
4.) Edit Makefile in 2.6.x-custom. Change EXTRAVERSION= to EXTRAVERSION=[custom]
6.) optionally copy the /boot/kconfig26 to /usr/src/linux-2.6.x-custom/.config
7.) make xconfig
8.) make bzImage
9.) make modules && make modules_install
10.) make install

This will not alter any of the infrastructure for the current working kernel (unless you have a current 2.6.x-[custom] installed). That way if you screwed up the new kernel, you can boot into the previous one. Make install will call the /sbin/installkernel script if it exists, ant not the /path/to/source/linux-2.6.x-[custome]/arch/i386/boot/install.sh script. This script is what updates lilo even if your using grub. Also if you copied the /etc/grup-update.conf, the grub menu will be updated with an entry for your new kernel.

If you use grub, it is best, IMHO, to uninstall lilo. That way lilo doesn't accidently write over the boot sector if you screwed up the process by putting the installkernel script in the wrong place.

This process was "loosly" inspired by tools in some debian packages.

Please let me know what you think.
-wd


Hobbes : Shouldn't we read the instructions?
Calvin : Do I look like a sissy?

Offline

#2 2004-04-25 19:35:23

aCoder
Member
From: Medina, OH
Registered: 2004-03-07
Posts: 359
Website

Re: Install kernel using "make install"

I think it's a great idea.  Whenever I compile a kernel, I like to make menuconfig, then run everything else on one line, including rebooting, and have my desktop back when I return.  It's not lazy, not n00bish, it's just creative, and I think that's what I go for in a Linux distro.  However, this does present a problem to grub users.  It'd be a good wiki entry for those who must use it, but the easy way out, which I tend to take, is to use lilo.


If you develop an ear for sounds that are musical it is like developing an ego. You begin to refuse sounds that are not musical and that way cut yourself off from a good deal of experience.
  - John Cage

Offline

#3 2004-04-25 20:01:06

i3839
Member
Registered: 2004-02-04
Posts: 1,185

Re: Install kernel using "make install"

I don't see the problem with Grub. You don't have to change anything at all in the Grub menu if you use links. E.g. In the Grub menu you have two options, one to load the newest kernel (default option), and one to load the previous version. The newest kernel is a symlink named something like kernel-newest pointing to the just installed kernel, and the old one is a link named kernel-previous pointing to the previous one. Then when you install a new kernel you just drop it in the dir and update the links.

Offline

#4 2004-04-25 20:29:07

wdemoss
Member
From: WV - USA
Registered: 2004-01-18
Posts: 222

Re: Install kernel using "make install"

I'm alittle lazy (well, alot lazy). Would you be intersted if there was an above modifieid script to accomplish your way. Instead of updating the menu.lst, it did the magic of moving the symlinks around?


Hobbes : Shouldn't we read the instructions?
Calvin : Do I look like a sissy?

Offline

#5 2004-04-26 12:54:48

i3839
Member
Registered: 2004-02-04
Posts: 1,185

Re: Install kernel using "make install"

#!/bin/sh
#
# Arguments:
#   $1 - kernel version
#   $2 - kernel image file
#   $3 - kernel map file
#   $4 - default install path (blank if root directory)

# define input variables
#
# assume default install path is /boot

if [ -z $4 ]; then 
   install_path=$4;
else
   install_path=/boot;
fi

kver=$1
kimg=$2
kmap=$3
 
vmlinuz=$install_path/vmlinuz-$kver
sysmap=$install_path/System.map-$kver
kconfig=$install_path/kconfig-$kver
 
 
#
# check for previous versions
#
if [ -f $vmlinuz ]; then cp $vmlinuz $vmlinuz.old; fi
if [ -f $sysmap ]; then cp $sysmap $sysmap.old; fi
if [ -f $kconfig ]; then cp $kconfig $kconfig.old; fi
 
 
#
# install the image and map files
#
cat $kimg > $vmlinuz
cp $kmap $sysmap
cp $(dirname "$kmap")/.config $kconfig
 
 
#
# Check for grub, then lilo
#
# In the Grub menu you can use two menu entries, one pointing to
# kernel-newest and one to kernel-previous.
if [ -d $install_path/grub ]; then
     mv $install_path/kernel-newest $install_path/kernel-previous
     ln -s $vmlinuz $install_path/kernel-newest

elif [ -x /sbin/lilo ]; then
 
    /sbin/lilo -v
 
fi 

I didn't test it, but it should work. The move will fail if there is no link kernel-newest, but that doesn't really matter.

Offline

#6 2004-04-26 14:03:59

Moo-Crumpus
Member
From: Hessen / Germany
Registered: 2003-12-01
Posts: 1,441

Re: Install kernel using "make install"

:idea:


Frumpus addict
[mu'.krum.pus], [frum.pus]

Offline

Board footer

Powered by FluxBB