Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
A useful little script to help you modify your 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
sisob
Apprentice
Apprentice


Joined: 28 Jun 2002
Posts: 274
Location: Ireland

PostPosted: Tue Aug 27, 2002 8:40 pm    Post subject: A useful little script to help you modify your kernel Reply with quote

The following is /usr/src/linux/makekernel on my system.

It is a useful script that takes the pain out of adding one or two modules
or whatever to the kernel.

Code:

#!/bin/bash
cp .config /usr/src
make clean
make mrproper
cp /usr/src/.config ./.config
make menuconfig
clear
echo "I'm going to compile the kernel now! Press any key to continue"
read stuff
make dep && make clean bzImage modules modules_install
clear
echo "I'm going to install your kernel now..."
if [ -f /usr/bin/sudo ]
then
{
echo "... and you have sudo installed so I'm going to try to use it.
if you are running this as root it shouldn't matter anyway."
echo ""
echo "Press any key to continue"
read stuff
sudo mount /boot
sudo mv /boot/bzImage /boot/bzImage.backup
sudo cp /usr/src/linux/arch/i386/boot/bzImage /boot
sudo umount /boot
}
else
{
echo "... and you dont have sudo installed. If you are running this
script as a normal user you will likely have problems."
echo ""
echo "Press any key to continue"
read stuff
mount /boot
mv /boot/bzImage /boot/bzImage.backup
cp /usr/src/linux/arch/i386/boot/bzImage /boot
umount /boot
}
fi


<edit>This now has the ability to run as normal user
but I havent tested that as my kernel was previously
compiled as root and now i cant re-compile it as normal
user.

The script will also backup the kernel but it will override
the old backup and so only keep the latest backup. Make
sure you reboot between runing the script if you need
to run it twice, or you could end up with a backup as
broken as your kernel.<edit>
_________________
Mark Finlay - Gnome Hacker of Sorts
Come join me on the Gnome User's Forum


Last edited by sisob on Wed Aug 28, 2002 5:55 pm; edited 3 times in total
Back to top
View user's profile Send private message
Scandium
Retired Dev
Retired Dev


Joined: 22 Apr 2002
Posts: 340
Location: Germany

PostPosted: Tue Aug 27, 2002 9:18 pm    Post subject: Reply with quote

sounds nice
Back to top
View user's profile Send private message
rac
Bodhisattva
Bodhisattva


Joined: 30 May 2002
Posts: 6553
Location: Japanifornia

PostPosted: Tue Aug 27, 2002 10:20 pm    Post subject: Reply with quote

A few suggestions:
  • How about adding mounting /boot, for people with it on a different partition?
  • Could you use sudo to copy the kernel to /boot, so that the running of the script (and the configuration and compilation) could be done as a non-root user?

_________________
For every higher wall, there is a taller ladder
Back to top
View user's profile Send private message
sisob
Apprentice
Apprentice


Joined: 28 Jun 2002
Posts: 274
Location: Ireland

PostPosted: Wed Aug 28, 2002 6:56 am    Post subject: Re: A useful little script to help you modify your kernel Reply with quote

hmm ....
Code:

#!/bin/bash
cp .config /usr/src
make clean
make mrproper
cp /usr/src/.config ./.config
make menuconfig
clear
echo "I'm going to compile the kernel now! Press any key to continue"
read stuff
make dep && make clean bzImage modules modules_install &&
sudo mount /boot; sudo cp /usr/src/linux/arch/i386/boot/bzImage /boot


I also need to add a backup for the old kernel
As for the sudo - i added it but personally i just run the whole script with sudo
_________________
Mark Finlay - Gnome Hacker of Sorts
Come join me on the Gnome User's Forum
Back to top
View user's profile Send private message
rac
Bodhisattva
Bodhisattva


Joined: 30 May 2002
Posts: 6553
Location: Japanifornia

PostPosted: Wed Aug 28, 2002 7:17 am    Post subject: Re: A useful little script to help you modify your kernel Reply with quote

Thanks for responding. How about editing your original post in the thread if you make updates? That way people can be sure that the top post is reliable without having to read the whole thread.

sisob wrote:
As for the sudo - i added it but personally i just run the whole script with sudo

If it doesn't bother you, then that's fine. I guess it's a personal beef of mine - as a matter of fact, my #2 complaint about Gentoo is how much work needs to be done as root that seems unnecessary to me.

Case in point: if you compile as root, you open your system up to things like the recent OpenSSH makefile trojan. Compiling as a normal user, there's only so much damage you can do.

EDIT: changed thinko pointed out by sisob later in the thread
_________________
For every higher wall, there is a taller ladder


Last edited by rac on Wed Aug 28, 2002 7:07 pm; edited 1 time in total
Back to top
View user's profile Send private message
crevette
Guru
Guru


Joined: 21 May 2002
Posts: 543
Location: Chrooted in Nice, France

PostPosted: Wed Aug 28, 2002 3:39 pm    Post subject: A question Reply with quote

I'm sorry but what is sudo???

thanks
:? :? :? :? :? :? :?
_________________
http://www.mille-mathias.info
Back to top
View user's profile Send private message
sisob
Apprentice
Apprentice


Joined: 28 Jun 2002
Posts: 274
Location: Ireland

PostPosted: Wed Aug 28, 2002 5:42 pm    Post subject: Re: A useful little script to help you modify your kernel Reply with quote

rac wrote:
Case in point: if you compile as a non-root user, you open your system up to things like the recent OpenSSH makefile trojan. Compiling as a normal user, there's only so much damage you can do.


I assume that you ment it is bad to compile as a root user

oh and sudo is a command that lets you run programs as root
without a root password.
_________________
Mark Finlay - Gnome Hacker of Sorts
Come join me on the Gnome User's Forum
Back to top
View user's profile Send private message
Kream
n00b
n00b


Joined: 19 Apr 2002
Posts: 30
Location: New Delhi, India

PostPosted: Sat Aug 31, 2002 9:05 pm    Post subject: Re: A question Reply with quote

crevette wrote:
I'm sorry but what is sudo???

thanks
:? :? :? :? :? :? :?


sudo = do as superuser
Back to top
View user's profile Send private message
TheCoop
Veteran
Veteran


Joined: 15 Jun 2002
Posts: 1814
Location: Where you least expect it

PostPosted: Sat Sep 07, 2002 5:40 pm    Post subject: Reply with quote

i have updated the script to reinstall alsa & nvidia kernel modules if they were installed beforehand (as the script cleans out the modules), but i need some help with the programming cos im not exactly well versed in the intricacies of bash programming. atm ive got this:

Code:

#!/bin/bash
if [ -f /lib/modules/*/kernel/sound/snd.o ]
then
{
export ALSA=installed
}
if [ -f /lib/modules/*/video/NVdriver ]
then
{
export NVIDIA=installed
}
cp .config /usr/src
make clean
make mrproper
...................
...................
mv /boot/bzImage /boot/bzImage.backup
cp /usr/src/linux/arch/i386/boot/bzImage /boot
umount /boot
}
if [ <need something to check if 'echo $ALSA' gives 'installed'> ]
{
echo "It looks like you have Alsa installed. The alsa modules will need to be
reinstalled. Make sure you are connected to the internet."
echo ""
echo "Press any key to continue"
read stuff
if [ -f /usr/bin/sudo ]
then
{
sudo emerge alsa-driver
}
else
{
emerge alsa-driver
}
}
clear
if [ <need same for $NVIDIA> ]
{
echo "It looks like you have the nvidia drivers installed....



are there any other ebuilds that install kernel modules?
_________________
95% of all computer errors occur between chair and keyboard (TM)

"One World, One web, One program" - Microsoft Promo ad.
"Ein Volk, Ein Reich, Ein Führer" - Adolf Hitler

Change the world - move a rock
Back to top
View user's profile Send private message
rac
Bodhisattva
Bodhisattva


Joined: 30 May 2002
Posts: 6553
Location: Japanifornia

PostPosted: Mon Sep 09, 2002 2:55 am    Post subject: Reply with quote

Recent nvidia-kernel ebuilds are immune to being cleared out by make modules_install. See this thread.
_________________
For every higher wall, there is a taller ladder
Back to top
View user's profile Send private message
hertog
Tux's lil' helper
Tux's lil' helper


Joined: 28 Jun 2002
Posts: 138
Location: Enschede/The Netherlands/Europe

PostPosted: Tue Sep 10, 2002 3:57 pm    Post subject: Reply with quote

One more package that depends on the current kernel:
lm-sensors.

Should/Could be added in the same way as the ALSA modules.

Any more of these sort of packages?
Back to top
View user's profile Send private message
TheCoop
Veteran
Veteran


Joined: 15 Jun 2002
Posts: 1814
Location: Where you least expect it

PostPosted: Tue Sep 10, 2002 4:35 pm    Post subject: Reply with quote

i need details on exactly which package installs the kernel modules and exactly where and what they put (exact names) before i can add it to the script
_________________
95% of all computer errors occur between chair and keyboard (TM)

"One World, One web, One program" - Microsoft Promo ad.
"Ein Volk, Ein Reich, Ein Führer" - Adolf Hitler

Change the world - move a rock
Back to top
View user's profile Send private message
kyron
Apprentice
Apprentice


Joined: 26 Aug 2002
Posts: 198
Location: Montreal, Qc.

PostPosted: Tue Sep 10, 2002 6:01 pm    Post subject: Reply with quote

TheCoop wrote:
i need details on exactly which package installs the kernel modules and exactly where and what they put (exact names) before i can add it to the script


Wouldn't it be much easyer for you to use the qpkg utility to query for the existance these "kernel dependant" packages on a given system? Granted that a list of these kernel sensitive packages would have to be made :-)
_________________
M$ Windows: When in doubt, REBOOT
Linux: When in doubt, RTFM ;-)
Back to top
View user's profile Send private message
bps7j
Tux's lil' helper
Tux's lil' helper


Joined: 20 Dec 2002
Posts: 83
Location: Charlottesville, VA, USA

PostPosted: Sun Feb 02, 2003 6:54 pm    Post subject: Reply with quote

pcmcia-cs modules are deleted when you do make modules_install
_________________
There are only 10 kinds of people:
those who understand binary and those who don't.
Back to top
View user's profile Send private message
sessionID
Apprentice
Apprentice


Joined: 11 Nov 2002
Posts: 266
Location: hungary

PostPosted: Sun Feb 02, 2003 7:39 pm    Post subject: Reply with quote

Here's what I use:
(Could be done a bit better, but it works, and makes backups too.)
Code:
#!/bin/bash
export NOW=`date +%F-%H-%M`
cd /usr/src/linux
cp /usr/src/linux/.config /root/kernel_woodoo/settings/.config_bak_$NOW
cp /usr/src/linux/.config /root/kernel_woodoo/settings/.config_recent
make mrproper
cp /root/kernel_woodoo/settings/.config_recent /usr/src/linux/.config
make menuconfig
time make dep && make clean bzImage modules modules_install | tee /root/kernel_woodoo/make_log_$NOW
echo -e \\a && sleep 0,1 && echo -e \\a && sleep 0,1 && echo -e \\a
echo ""
echo "The new kernel is ready."
echo "The old bzImage will be saved as /boot/bzImage_bak_$NOW"
echo ""
echo "press enter to continue"
read DUMMYNOTHING
mount /boot
mv /boot/bzImage /boot/bzImage_bak_$NOW
cp /usr/src/linux/arch/i386/boot/bzImage /boot/bzImage
mcedit /boot/grub/grub.conf
umount /boot
# this one takes too much time, have to see if the kernel works..
#env ALSA_CARDS="intelx80" emerge alsa-driver
#update-modules
echo "    We can reboot now... "
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