Page 1 of 1

automaticly link /usr/src/linux to last kernel emerged

Posted: Fri Feb 20, 2004 2:54 am
by ewan.paton
i realise it is important to know how to link the correct source to /usr/src/linux but i was just wondering if it were possible/a good idea to automaticly link the last emerged source to linux i cant see any problems but what do i know

Posted: Fri Feb 20, 2004 5:28 am
by Fitzsimmons
You want /usr/src/linux to point to the kernel currently in use, which may or may not be the one you just merged. Having it changed automatically could cause a lot of frustration. I can already see myself completely forgetting that portage automatcially changes my /usr/src/linux link and wondering why the hell my programs/custom modules/etc. weren't compiling/working. Changing it manually ensures user awareness. I could understand where you were coming from if it were a long and difficult proccess, but it isn't. Two commands max.

Posted: Fri Feb 20, 2004 6:03 am
by ewan.paton
partialy lazyness and partialy remembering when i was a newbie trying to figure out how to do it before good documentation and also i switch kernels sometimes and forget to relink

i thought about writing a startup script along these lines but dont know the code,just the logic.

1 get exact kernel version (uname -r)
2 if symlink points to a dir with the same name exit
3 if not test if a dir does exist, if not exit
4 remove old link make new one and exit

anyone got an idea what to do now?

Posted: Fri Feb 20, 2004 7:19 am
by Athas
I would absolutely hate it if my machine started moving around files by itself. I don't really see the big problem, I mean, you only have to type

Code: Select all

ln -sf linux version linux
If people can't do that, then there's no way they're going to be able to run Gentoo GNU/Linux anyway.

Posted: Fri Feb 20, 2004 8:39 am
by NiklasH
I have had this for a long time in my /etc/conf.d/local.start:

Code: Select all

ln -sf /usr/src/linux-`uname -r` /usr/src/linux

if ! [ -e /lib/modules/`uname -r`/video/nvidia.o ] ;
then
emerge nvidia-kernel nvidia-glx
modprobe nvidia
fi
, to automatically get the nvidia modules loaded for my new kernel.
Works fine for me.

Posted: Sat Feb 21, 2004 7:36 am
by Fitzsimmons
Well there ya go. You can take that script and put it in your local.start. But it certainly doesn't belong in portage.

Posted: Sat Feb 21, 2004 9:51 am
by Ateo
NiklasH wrote:I have had this for a long time in my /etc/conf.d/local.start:

Code: Select all

ln -sf /usr/src/linux-`uname -r` /usr/src/linux

if ! [ -e /lib/modules/`uname -r`/video/nvidia.o ] ;
then
emerge nvidia-kernel nvidia-glx
modprobe nvidia
fi
, to automatically get the nvidia modules loaded for my new kernel.
Works fine for me.
You're only emerging a package. Do you realize that when you compile programs, some programs use that symlink to compile to?

Posted: Sat Feb 21, 2004 3:58 pm
by NiklasH
Yes, but that package uses the /usr/src/linux symlink to put the nvidia module. And why would I want a program that compiles against the kernel to compile against something other than the running kernel?

Posted: Sat Feb 21, 2004 8:42 pm
by nerdbert
NiklasH wrote:Yes, but that package uses the /usr/src/linux symlink to put the nvidia module. And why would I want a program that compiles against the kernel to compile against something other than the running kernel?
that's not a problem if you always compile it right after emerging.
But if you e.g. use 2.6 and you still have gentoo-sources in your world file it might lead to confusion after emerging world.
This shouldn't become standard, but I can perfectly understand that some people like this to be integrated into kernel ebuilds.

NiklasH: You only reboot rarely, don't you?

Posted: Sat Feb 21, 2004 9:24 pm
by NiklasH
Nope, I turn off my computer almost every night.
Haven't had any problems.
And what kind of confusion would it lead to? If i keep the symlink to an old kernel, it could also cause trouble if I compile some new program against it.
The only programs that could run into troubles are the ones that install their own modules, as far as I can tell. And they aren't that many, at least not on my system.

Could anyone explain why I need to keep the symlink to a kernel that is never used anymore? According to Linus T., that symlink is a relic that shouldn't be used, anyway. Programs should check the kernel version and compile against the correct source tree by themselves.

Tell me if I'm off base here, but that seems more logical to me.

Posted: Sat Feb 21, 2004 10:01 pm
by nerdbert
NiklasH wrote:Nope, I turn off my computer almost every night.
Haven't had any problems.
I didn't expect you to have any problems, but it must take quite some time to boot whenever you've changed your kernel or you decided to boot an alternative kernel. That's why I assumed you don't reboot quite often.
NiklasH wrote: And what kind of confusion would it lead to? If i keep the symlink to an old kernel, it could also cause trouble if I compile some new program against it.
I already said it: If you happen to use a 2.6 kernel and you still have 2.4 in your world file. Let's assume you just did an emerge world and there is an update to 2.4 and another one to nvidia-kernel. If you include a symlink change into the kernel ebuild this will lead to a new nvidia module compiled for a 2.4 kernel. The nvidia-kernel ebuild removes "old" instances, so you won't have nvidia.ko in your /lib/modules/2.6.<whatever>. That's the confusion I'm talking about.
NiklasH wrote: The only programs that could run into troubles are the ones that install their own modules, as far as I can tell. And they aren't that many, at least not on my system.
I've only got 2 myself (nvidia-kernel and at76c503a). But the current setup is quite convenient IMO - I don't want to count the report requests this new ebuild would cause ("I just emerged X and after modprobing it I'm told that Module doesn't exists).

Posted: Sat Feb 21, 2004 10:16 pm
by NiklasH
nerdbert wrote:
NiklasH wrote:Nope, I turn off my computer almost every night.
Haven't had any problems.
I didn't expect you to have any problems, but it must take quite some time to boot whenever you've changed your kernel or you decided to boot an alternative kernel. That's why I assumed you don't reboot quite often.
Maybe I'm too tired to see what you mean, but I don't. My computer boots in about 20-30 seconds, if that's what you mean? And I tend to use one kernel until another one comes along that seems neat. And then I of course use make oldconfig.
And I like more to get the nvidia drivers automatically merged if I use another kernel than having to do it manually. That way, only about half a minute is added to the boot time, instead of a few minutes doing it by hand.
NiklasH wrote: And what kind of confusion would it lead to? If i keep the symlink to an old kernel, it could also cause trouble if I compile some new program against it.
I already said it: If you happen to use a 2.6 kernel and you still have 2.4 in your world file. Let's assume you just did an emerge world and there is an update to 2.4 and another one to nvidia-kernel. If you include a symlink change into the kernel ebuild this will lead to a new nvidia module compiled for a 2.4 kernel. The nvidia-kernel ebuild removes "old" instances, so you won't have nvidia.ko in your /lib/modules/2.6.<whatever>. That's the confusion I'm talking about.
I'm not talking about the kernel ebuild. I'm talking about rebooting into another kernel. The script I use is in my local.start, for precisely that reason: that the module is removed from other kernels.
NiklasH wrote: The only programs that could run into troubles are the ones that install their own modules, as far as I can tell. And they aren't that many, at least not on my system.
I've only got 2 myself (nvidia-kernel and at76c503a). But the current setup is quite convenient IMO - I don't want to count the report requests this new ebuild would cause ("I just emerged X and after modprobing it I'm told that Module doesn't exists).
Maybe we're not talking about the same thing? Are you talking about changing the symlink in the ebuild? If that's the case, then we agree: I don't want it in the ebuild either. But that wasn't in my original post, OTOH. :)

Posted: Sat Feb 21, 2004 10:35 pm
by nerdbert
I don't really know if we're talking about the same thing. I'll try to clarify my point:

Whenever your script leads to a reemerge of nvidia-kernel and nvidia-glx it takes more than 30s to boot. I've got more than 1 kernel in my grub.conf and whenever I want to boot a different one this would really take a while.
But I like your additions to local.start and I can perfectly understand why you use this.

If you want to have an automatic link created whenever you emerge a new kernel (I'm also tired - wasn't this ewan.paton's suggestion?) this might be realized in the kernel's ebuild. IMO it just doesn't make sense in the average case scenario, because people tend to emerge kernels they don't really use.

Posted: Sun Feb 22, 2004 12:04 am
by ewan.paton
yeh the ebuild to make symlink was a stupid idea, i think the idea of startup script is a lot more useful. i was just being lazy and wanted to type as little as posible, the scrip alows me to change kernels often and not have remeber or type stuff

Posted: Sun Feb 22, 2004 1:25 am
by nerdbert
ewan.paton wrote:yeh the ebuild to make symlink was a stupid idea, i think the idea of startup script is a lot more useful. i was just being lazy and wanted to type as little as posible, the scrip alows me to change kernels often and not have remeber or type stuff
it's not a stupid idea to include it in an ebuild - I just believe it doesn't make sense to have it as a default option :wink:
I'm actually thinking about using NiklasH's script. If I add some lines it might also make sense to me to run it at default level.

Posted: Sun Feb 22, 2004 5:54 am
by NiklasH
nerdbert wrote:I don't really know if we're talking about the same thing. I'll try to clarify my point:

Whenever your script leads to a reemerge of nvidia-kernel and nvidia-glx it takes more than 30s to boot. I've got more than 1 kernel in my grub.conf and whenever I want to boot a different one this would really take a while.
But I like your additions to local.start and I can perfectly understand why you use this.

If you want to have an automatic link created whenever you emerge a new kernel (I'm also tired - wasn't this ewan.paton's suggestion?) this might be realized in the kernel's ebuild. IMO it just doesn't make sense in the average case scenario, because people tend to emerge kernels they don't really use.
Then I think we pretty much agree :)
And my script only does an emerge when the nvidia module is missing, so it doesn't do anything other than you would do youself after rebooting to a different kernel.

Posted: Sun Feb 22, 2004 8:47 am
by TheEternalVortex
I have a script that compiles the latest kernel I've installed (since I tend to do 2-3 a week). To change the symlink automatically you can do this (taken from the script):
cd /usr/src
KERNEL=`ls --sort=time -1 | head -n 1`
rm linux 2> /dev/null
ln -s $KERNEL linux

Posted: Thu Mar 11, 2004 6:20 am
by gigatexal
I am planning on running both the latest gs 2.4 kernel and the latest 2.6 kernel, will I have to re-symlink the things everytime I boot to a different kernel?

alex

Posted: Thu Mar 11, 2004 1:01 pm
by Fitzsimmons
I am fairly certain you only need to re-link the kernel if you are trying to build against it.