how do I only install a kernel without it's source directory?
SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: Xubuntu, Mythbuntu, Lubuntu, Picuntu, Mint 18.1, Debian Jessie
Posts: 1,207
Rep:
how do I only install a kernel without it's source directory?
I recently did a fresh install of Slackware on a 4 GB drive. Not much space was there (I didn't include KDE or the kernel source) and now I only have ~500 MB. I want to recompile the kernel on another pc so that my Slack 13 install has APM built in rather than a module. Now, I've re-done the kernel many times over the years...but I'm thinking that I'm installing too much (it wouldn't fit inside of 500 MB).
This is what I do:
On another pc with more space I download a fresh kernel and cryptographically check it. Then I untar, do make mrproper, copy an old kernel config file to /linux-2.6.xx, cd /linux-2.6.xx, make oldconfig, make menuconfig-make changes and save-and finally make bzImage && make modules. Once this is done compiling I compress the file into a single file for transporting with tar -cvvzf.
On my old pc I copy the file to /usr/src and then untar the file with tar -xvvzf. This rebuilds a huge directory called linux-2.6.xx. I cd into this directory and then do make modules_install. Then I copy 3 files over to /boot>bzimage, config and systemmap. I make needed changes to /etc/lilo.conf and then do lilo to get it to boot.
Now-is this overkill? Can I put the linux-2.6.xx source directory onto an usb drive (untarred) and do a make modules_install (the usb drive will be removed later)?
You don't need to copy the whole compiled source tree just to install the modules. You can install the modules tree to some temporary place and copy them over.
Code:
make modules_install INSTALL_MOD_PATH=/tmp/tempmodules
Distribution: Xubuntu, Mythbuntu, Lubuntu, Picuntu, Mint 18.1, Debian Jessie
Posts: 1,207
Original Poster
Rep:
The installed modules that wind up in /lib/modules/2.6.xx don't take up much space...what I'm wondering about is the huge source directory (700+ MB) that is made during kernel building in /usr/src/linux-2.6.xx. Do I need to install that huge directory on a computer to make it boot? I've tried without that directory and cannot get the pc to boot.
There must be a way, though, since you don't have to install the kernel source on a Slackware installation to make it boot (nothing has to be in /usr/src and you don't have to install the k package). How do the Slackware gurus make the pc boot without a kernel source?
Last edited by linuxhippy; 10-13-2009 at 09:14 AM.
Distribution: Xubuntu, Mythbuntu, Lubuntu, Picuntu, Mint 18.1, Debian Jessie
Posts: 1,207
Original Poster
Rep:
That's what I figured-you only need bzImage, systemmap and the kernel modules in /lib/modules. I cannot get my pc to boot without the kernel source, though. Would you give me step by step instructions of how to compile on another pc and then move it to a smaller pc?
That's what I figured-you only need bzImage, systemmap and the kernel modules in /lib/modules. I cannot get my pc to boot without the kernel source, though. Would you give me step by step instructions of how to compile on another pc and then move it to a smaller pc?
Look at 'Building a Linux Kernel from source'. Alien_Bob's wiki has it all laid out for you on how to build. Transporting kernels from a build system is done all the time.
This link and others can be found at 'Slackware-Links'. More than just SlackwareŽ links!
Distribution: Xubuntu, Mythbuntu, Lubuntu, Picuntu, Mint 18.1, Debian Jessie
Posts: 1,207
Original Poster
Rep:
ok-something is missing in that link...that's how I have been building kernels with the source directory in /usr/src. Now if I leave the source directory on an external drive after doing make modules_install my pc won't boot. How do I get my pc to boot without /usr/src/linux-2.6.xx?
When you build on a separate system you will need to transport your modules along with the kernel, config and map. Place your modules in the proper '/lib/modules/' directory for the new kernel. Then copy your kernel, config and map files to /boot. You will need to link your map. Then setup the /etc/lilo.conf' to reflect the new kernel. Be sure to run 'lilo' to update.
I like to set the '/usr/src/linux/Makefile'; 'EXTRAVERSION' to something unique;
Code:
excerpt from '/usr/src/linux/Makefile';
VERSION = 2
PATCHLEVEL = 6
SUBLEVEL = 30
EXTRAVERSION = .5-1
NAME = Man-Eating Seals of Antiquity
That way I can transport '/lib/modules/2.6.30.5-1' with the rest.
Distribution: Xubuntu, Mythbuntu, Lubuntu, Picuntu, Mint 18.1, Debian Jessie
Posts: 1,207
Original Poster
Rep:
Quote:
Originally Posted by onebuck
Hi,
When you build on a separate system you will need to transport your modules along with the kernel, config and map. Place your modules in the proper '/lib/modules/' directory for the new kernel. Then copy your kernel, config and map files to /boot. You will need to link your map. Then setup the /etc/lilo.conf' to reflect the new kernel. Be sure to run 'lilo' to update.
I like to set the '/usr/src/linux/Makefile'; 'EXTRAVERSION' to something unique;
Code:
excerpt from '/usr/src/linux/Makefile';
VERSION = 2
PATCHLEVEL = 6
SUBLEVEL = 30
EXTRAVERSION = .5-1
NAME = Man-Eating Seals of Antiquity
That way I can transport '/lib/modules/2.6.30.5-1' with the rest.
This is helpful...I'm thinking I may have to use an extraversion in my kernel Makefile so that /lib/modules is unique (I was renaming the installed /lib/modules/2.6.29.6 as /lib/modules/2.6.29.6-orig and then doing a make modules_install to create /lib/modules/2.6.29.6). I'm building the kernel and modules again as I type.
What I'm not sure about is where do I do make modules_install?? Do I do that on my big computer where I compiled the kernel and modules or do I do it on my smaller computer and have the kernel source directory on a flash drive?? I thought the modules were made during make modules...but it sounds like you're saying it's when the directory in /lib/modules is created during make modules_install and so I need to do make modules_install on my big computer and then copy this modules directory.
Last edited by linuxhippy; 10-13-2009 at 09:35 PM.
Distribution: Xubuntu, Mythbuntu, Lubuntu, Picuntu, Mint 18.1, Debian Jessie
Posts: 1,207
Original Poster
Rep:
well, that didn't work. I did make modules_install on my big computer after rebuilding the kernel as 2.6.29.6-1 and then copied the directory 2.6.29.6-1 (the modules) to a flash drive and then copied them to my small computer with vmlinuz, System.map and config. These were copied to /lib/modules and /boot and then lilo.conf was updated with lilo being ran. Then I rebooted and picked Linux-apm. All looked ok (it found the kernel) and the BIOS checked out then the screen went blank. I have no idea what I did wrong. Maybe I had to do make modules_install on the small computer?
This is helpful...I'm thinking I may have to use an extraversion in my kernel Makefile so that /lib/modules is unique (I was renaming the installed /lib/modules/2.6.29.6 as /lib/modules/2.6.29.6-orig and then doing a make modules_install to create /lib/modules/2.6.29.6). I'm building the kernel and modules again as I type.
What I'm not sure about is where do I do make modules_install?? Do I do that on my big computer where I compiled the kernel and modules or do I do it on my smaller computer and have the kernel source directory on a flash drive?? I thought the modules were made during make modules...but it sounds like you're saying it's when the directory in /lib/modules is created during make modules_install and so I need to do make modules_install on my big computer and then copy this modules directory.
You don't rename the modules directory. When you build the kernel and you have added the 'EXTRAVERSION=' then the 'make, make modules and make modules _install' will create the modules with the name as identified by the name that will be unique form from the identifier. You did look at the link that was provided for the build technique;
You should move a copy of the generated modules for the kernel that was compiled. The make modules and make modules_install is for that kernel therefore it is dependent on these.
I use a build directory for this. This way I can create what I want and move it as a whole.
The use of a non-production box is done all the time. As long as the tree for the np box is the same for the other boxes this will not be a problem. I move these over then create a stanza in my lilo.conf to reflect the new test kernel. Then I run a test to make sure everything is working. You should now be able to dep -a for the test kernel.
Please post your procedure exact from the notes your are keeping so we can help identify the problem.
You say it doesn't work. How? Errors? Which 'config' was used for the test kernel? Which kernel?
You seem to have some confusion still. This procedure is done all the time and is not that complicated.
Another possibility is to build the kernel as a tarball using:
make targz-pkg
Then on the target machine:
1. tar zxf <my kernel>.tar.gz -C /
2. No need to run depmod. It is embedded.
3. cd /boot; rm vmlinux-<my version>
(i.e., you only need the compressed kernel)
4.mkinitrd -c -k <my version> -o /boot/initrd-<my version>
(Skip if not using initrd)
5. rm vmlinuz config System.map (i.e., delete the soft links)
6. Remake the soft links to point to the new files.
7. /sbin/lilo -v (skip if using grub)
8. reboot
Also, there is no need to set the local version string in Makefile.
In "make menuconfig" or "make xconfig", there is a placeholder to
enter a custom string in .config. Double click and type, for example,
"-custom2-smp". Drop "-smp" for a single core.
Distribution: Xubuntu, Mythbuntu, Lubuntu, Picuntu, Mint 18.1, Debian Jessie
Posts: 1,207
Original Poster
Rep:
ok-here's what I did as of last night. I'm about to try make targz-pkg.
This is on my big AMD 64 running Fedora Core 10 x86_64 (gcc is 4.3.2-7 and Slackware 13 is 4.3.3):
Download and cryptographically check linux-2.6.29.6.tar.gz
Uncompress with tar -xvvzf linux-2.6.29.6.tar.gz
cd linux 2.6.29.6
linux32 make mrproper
cp ../config-huge-2.6.29.6 .config
nano -w Makefile
change EXTRAVERSION = .6
to EXTRAVERSION = .6-1
Configure the kernel:
linux32 make oldconfig
linux32 make menuconfig
Enter Power Management and ACPI options
Unselect ACPI Support and * APM BIOS support
Go into APM BIOS support and * Enable PM at boot time
Back 1 level and go into CPU Frequency scaling
Unselect CPU Frequency scaling
Exit and save
Build the kernel and modules:
linux32 make bzImage && linux32 make modules
Insert the modules:
linux32 make modules_install INSTALL_MOD_PATH=tempmodules
Copy the modules directory and 3 files to a flash drive:
cp -r tempmodules/lib/modules/2.6.29.6-1 /media/usb
cp arch/i386/boot/bzImage (rename to vmlinuz-2.6.29.6-1)
cp System.map (rename to System.map-2.6.29.6-1)
cp .config (rename to config-2.6.29.6-1)
Now I unmount the flash drive and put it in my smaller Slackware 13 x86 laptop:
Copy modules directory to /lib/modules
Copy vmlinuz-2.6.29.6-1, System.map-2.6.29.6-1 and config-2.6.29.6-1 to /boot
cd /boot
ln -s System.map-2.6.29.6-1 System.map
Edit lilo with pico -w /etc/lilo.conf and add this:
Distribution: Xubuntu, Mythbuntu, Lubuntu, Picuntu, Mint 18.1, Debian Jessie
Posts: 1,207
Original Poster
Rep:
I just realized links in /lib/modules/2.6.29.6-1 get messed up when you don't do make modules_insert on the target pc. This would probably mess up the boot process. Is there a quick way to fix these links?
There are two soft links under /lib/modules/<my version>, "build" and "source". As far I know, they are only for book keeping purposes. They are not used at run time.
The source directory is only needed if you want to build drivers, e.g., nvidia or certain wireless modules. After those modules have been built, the source can be deleted.
The entire make and cp sequence can be replaced by one command:
make targz-pkg
Then after un-tarring it on the target machine, only the symlink and lilo sequences need to be done.
When you do this process in the labourious manual way, keep in mind that /lib/modules/<my version> is not the only place that "make modules_install" installs files. Check out /lib/firmware.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.