Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
bash script: install-kernel-2.6 - emerge nvidia-kernel
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
jonaswidarsson
Apprentice
Apprentice


Joined: 16 Jan 2004
Posts: 273
Location: Göteborg, Sweden

PostPosted: Wed Apr 14, 2004 5:20 pm    Post subject: bash script: install-kernel-2.6 - emerge nvidia-kernel Reply with quote

I use a home made script for walking the steps of a 2.6 kernel install.
It can take a suffix to let you have multiple configurations of the same kernel sources installed.

I have an nvidia geforce graphics card in this setup, so the emerge nvidia-kernel step is included after the kernel installed.
Automated for me, and maybe for you. Tweak it if you don't like it. Feel free to post better solutions. I am not a bash guru.

Here's what it does:
* It asks you for a suffix to the installed kernel files.
* It asks you if you'd like to run make menuconfig
* It asks you if you'd like to mount /boot if it wasn't mounted.
* It asks you if you'd like to mount /proc if it wasn't mounted.
* It asks you if you'd like to compile the kernel and modules and install to boot.
* It prints the final kernel image filename so you can grab it with the mouse.
* It copies the kernel image into /boot, as well as the System.map and the config. All with the kernel version and your suffix in the filenames.
* It asks you if you'd like to nano -w /etc/lilo.conf (Paste the new kernel name with the mouse in there) and run /sbin/lilo after nano has quit.
* It unmounts the /boot and the /proc mounts.
* It runs emerge nvidia-kernel.
It does NOT reboot for you... Noone should be so lazy that they want that action in the script.

There is no make clean functionality included.

As root, create the file /sbin/install-kernel-2.6 and chmod +x it after you've pasted the following into it:
Code:
#!/bin/bash

#
# This script attempts to guide you through linux kernel 2.6 config, compile and install.
#

PWD=`pwd`
if [ "$PWD" != "/usr/src" ]; then 
   echo INFO: We are in $PWD. We should be in /usr/src.
      cd /usr/src
      echo Directory changed to /usr/src
fi

VERSION=`ls -l | grep -E "linux \-[\>]" | cut -b 75-`
if [ "$1" != "" ]; then
   SFX="-$1"
fi
if [ "$1" != "" ]; then
   SFX="-$1"
else
   echo Version name is: \'$VERSION\'
   echo There is no suffix specified for this kernel image.
   echo Enter a suffix now, or press [ENTER] for no suffix:
   read SFX
   if [ "$SFX" != "" ]; then
      SFX="-$SFX"
   fi
fi
VERSION="$VERSION$SFX"
echo Version name is: \'$VERSION\'



echo Do you want to execute \'make menuconfig\'?
read INP
INP=`echo "$INP" | cut -b 0-1`
 
if [ "$INP" == "y" ]; then 
   cd linux
   make menuconfig
   cd ..
fi

BOOTMOUNT=`mount | egrep ' /boot '`
if [ "$BOOTMOUNT" == "" ]; then
   echo \"/boot\" is not mounted. Do you want to mount /boot?
   read INP
   INP=`echo "$INP" | cut -b 0-1`
   if [ "$INP" == "y" ]; then
      mount /boot 
      MOUNTEDBOOT=1
   fi
fi

PROCMOUNT=`mount | egrep ' type proc '`
if [ "$PROCMOUNT" == "" ]; then
   echo \"/proc\" is not mounted. Do you want to mount /proc?
   read INP
   INP=`echo "$INP" | cut -b 0-1`
   if [ "$INP" == "y" ]; then
      mount -t proc none /proc 
   fi
fi





echo Do you want compile and install to boot?
read INP
INP=`echo "$INP" | cut -b 0-1`
if [ "$INP" == "y" ]; then 

cd linux
echo "make && make modules_install"
make && make modules_install

echo $'\a'
echo Version name is: \'$VERSION\'
echo cp -i linux/arch/i386/boot/bzImage /boot/kernel-$VERSION
   cp -i arch/i386/boot/bzImage /boot/kernel-$VERSION
echo cp -i linux/System.map /boot/System.map-$VERSION
   cp -i System.map /boot/System.map-$VERSION
echo cp -i linux/System.map /boot/System.map
   cp -i System.map /boot/System.map
echo cp -i linux/.config /boot/config-$VERSION
   cp -i .config /boot/config-$VERSION
cd ..
fi





echo Do you want to edit /etc/lilo.conf and run lilo afterwards?
read INP
INP=`echo "$INP" | cut -b 0-1`
if [ "$INP" == "y" ]; then 
   nano -w /etc/lilo.conf
   /sbin/lilo
fi

if [ "$MOUNTEDBOOT" == "1" ]; then
   umount /boot
fi
if [ "$MOUNTEDPROC" == "1" ]; then
   umount /proc
fi

###
### Skip the following if you don't use the nvidia graphics card kernel module.
###
echo Do you want to re emerge nvidia-kernel?
read INP
INP=`echo "$INP" | cut -b 0-1`
if [ "$INP" == "y" ]; then 
   emerge nvidia-kernel
fi

Make sure your symlink /usr/src/linux is pointing to the sources with full path and NOT ending with a slash, and it will work great:
Code:
bash-2.05b# ll /usr/src/
total 11
lrwxrwxrwx    1 root     root           27 Apr 14 09:39 linux -> /usr/src/linux-2.6.5-gentoo
drwxr-xr-x   16 root     root          808 Mar 28 23:15 linux-2.4.25-gentoo
drwxr-xr-x   19 root     root         1280 Apr 13 13:43 linux-2.6.3-gentoo-r1
drwxr-xr-x   19 root     root         1248 Apr 13 16:54 linux-2.6.4
drwxr-xr-x   19 root     root         1216 Mar 25 18:54 linux-2.6.4-ck1
drwxr-xr-x   19 root     root         1280 Apr  2 15:57 linux-2.6.4-gentoo-r1
drwxr-xr-x   19 root     root         1248 Mar 28 18:03 linux-2.6.4-rc1
drwxr-xr-x   19 root     root         1280 Apr 14 10:27 linux-2.6.5-gentoo
bash-2.05b#
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks 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