View previous topic :: View next topic |
Author |
Message |
sisob Apprentice
Joined: 28 Jun 2002 Posts: 274 Location: Ireland
|
Posted: Tue Aug 27, 2002 8:40 pm Post subject: A useful little script to help you modify your kernel |
|
|
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 |
|
|
Scandium Retired Dev
Joined: 22 Apr 2002 Posts: 340 Location: Germany
|
Posted: Tue Aug 27, 2002 9:18 pm Post subject: |
|
|
sounds nice |
|
Back to top |
|
|
rac Bodhisattva
Joined: 30 May 2002 Posts: 6553 Location: Japanifornia
|
Posted: Tue Aug 27, 2002 10:20 pm Post subject: |
|
|
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 |
|
|
sisob Apprentice
Joined: 28 Jun 2002 Posts: 274 Location: Ireland
|
Posted: Wed Aug 28, 2002 6:56 am Post subject: Re: A useful little script to help you modify your kernel |
|
|
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 |
|
|
rac Bodhisattva
Joined: 30 May 2002 Posts: 6553 Location: Japanifornia
|
Posted: Wed Aug 28, 2002 7:17 am Post subject: Re: A useful little script to help you modify your kernel |
|
|
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 |
|
|
crevette Guru
Joined: 21 May 2002 Posts: 543 Location: Chrooted in Nice, France
|
|
Back to top |
|
|
sisob Apprentice
Joined: 28 Jun 2002 Posts: 274 Location: Ireland
|
Posted: Wed Aug 28, 2002 5:42 pm Post subject: Re: A useful little script to help you modify your kernel |
|
|
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 |
|
|
Kream n00b
Joined: 19 Apr 2002 Posts: 30 Location: New Delhi, India
|
Posted: Sat Aug 31, 2002 9:05 pm Post subject: Re: A question |
|
|
crevette wrote: | I'm sorry but what is sudo???
thanks
|
sudo = do as superuser |
|
Back to top |
|
|
TheCoop Veteran
Joined: 15 Jun 2002 Posts: 1814 Location: Where you least expect it
|
Posted: Sat Sep 07, 2002 5:40 pm Post subject: |
|
|
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 |
|
|
rac Bodhisattva
Joined: 30 May 2002 Posts: 6553 Location: Japanifornia
|
Posted: Mon Sep 09, 2002 2:55 am Post subject: |
|
|
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 |
|
|
hertog Tux's lil' helper
Joined: 28 Jun 2002 Posts: 138 Location: Enschede/The Netherlands/Europe
|
Posted: Tue Sep 10, 2002 3:57 pm Post subject: |
|
|
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 |
|
|
TheCoop Veteran
Joined: 15 Jun 2002 Posts: 1814 Location: Where you least expect it
|
Posted: Tue Sep 10, 2002 4:35 pm Post subject: |
|
|
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 |
|
|
kyron Apprentice
Joined: 26 Aug 2002 Posts: 198 Location: Montreal, Qc.
|
Posted: Tue Sep 10, 2002 6:01 pm Post subject: |
|
|
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 |
|
|
bps7j Tux's lil' helper
Joined: 20 Dec 2002 Posts: 83 Location: Charlottesville, VA, USA
|
Posted: Sun Feb 02, 2003 6:54 pm Post subject: |
|
|
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 |
|
|
sessionID Apprentice
Joined: 11 Nov 2002 Posts: 266 Location: hungary
|
Posted: Sun Feb 02, 2003 7:39 pm Post subject: |
|
|
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 |
|
|
|