This tip is NOT for someone who has never compiled a kernel before. This tip was performed on a Debian Linux system.
I recently ran into a problem where I needed to access shares on a windows 2003 server from a linux system running a pre 2.6.10 kernel.
Instead of upgrading the kernel I decided to upgrade the 2.4.27 kernel with cifs support. Upgrading to a 2.6 kernel would have been the better choice but this particular server was at a remote location.
I don’t recommend compiling and installing a kernel from a remote location however. I’m just thick headed.
Just for reference this is a copy of my /etc/apt/sources.list file:
#deb-src http://ftp.debian.org/debian testing main
deb http://http.us.debian.org/debian stable main contrib non-free
deb http://security.debian.org/ stable/updates main
I commented and uncommented the sources as needed. After each update to the sources.list file do the following:
# apt-get check
First perform the following to install the kernel source:
# apt-get install kernel-package ncurses-dev fakeroot wget bzip2 [with top 2 in sources.list used]
# cd /usr/src
# bzip2 -dv kernel-source-2.4.27.tar.bz2
# tar -xvf kernel-source-2.4.27.tar
Next download the 2.4 cifs kernel patch from the samba website, untar and patch the kernel:
# tar -xzf cifs-1.20c-2.4.tar.gz
# cp -R kernel-source-2.4.27 kernel-source-2.4.27-CIFS
# cd kernel-source-2.4.27-CIFS
# patch -p1 < ../linux/cifs_24.patch
# cp -R ../linux/fs/cifs fs/
Now enter the directory with the patched kernel and bring up menuconfig:
# make menuconfig
Select Load an Alternate Configuration File and enter the location of your current running kernel. This will kep your current working settings for the new kernel compile. (Example my running kernel was located at: /boot/config-2.4.27-speakup)
Once you have loaded your current running settings do the following:
Select
Main menu > File systems > Network File Systems > CIFS Support
Also select CIFS POSIX Protocol Extensions under CIFS Support
Once the changes have been made exit the menu and save the changes.
Double check you have been working in the /usr/src/kernel-source-2.4.27-CIFS directory
Now compile the new kernel:
# make dep
# make-kpkg clean
# fakeroot make-kpkg –revision=Custom.1.0 –append-to-version=-CIFS kernel_image
NOTE ONLY DO THIS IF YOU ARE HAVING PROBLEMS COMPILING
If you have errors compiling the kernel you may be running a new version of gcc try using a previous verison. For example on my system gcc-4.0 was being used and I was having problems compiling.
# ls -al | grep gcc
lrwxrwxrwx 1 root root 7 2006-11-10 15:17 gcc -> gcc-4.0
-rwxr-xr-x 1 root root 85244 2005-06-20 18:05 gcc-3.3
-rwxr-xr-x 1 root root 89112 2005-07-12 00:29 gcc-4.0
To fix the compiling problems I changed the gcc dynamic link to point to gcc-3.3 instead of gcc-4.0
# ln -s gcc-3.3 gcc
After I updated the gcc version I went back to /usr/src/kernel-source-2.4.27-CIFS and recompiled:
NOTE ONLY DO THIS IF YOU ARE HAVING PROBLEMS COMPILING
Once you have the kernel compiled you should have a new *.deb file in /usr/src. Do the following to install the kernel:
# dpkg -i dpkg -i kernel-image-2.4.27-CIFS_Custom.1.0_i386.deb
I was using grub as my bootloader so to use the new kernel I added the kernel image to the head of the boot menu to be booted by default.
# vi menu.1st
title Debian GNU/Linux, kernel 2.4.27-CIFS
root (hd0,0)
kernel /boot/vmlinuz-2.4.27-3-cifs root=/dev/hda1 ro
initrd /boot/initrd.img-2.4.27-CIFS
savedefault
boot
title Debian GNU/Linux, kernel 2.4.27-CIFS (recovery mode)
root (hd0,0)
kernel /boot/vmlinuz-2.4.27-3-cifs root=/dev/hda1 ro single
initrd /boot/initrd.img-2.4.27-CIFS
savedefault
boot
title Debian GNU/Linux, kernel 2.4.27-speakup
root (hd0,0)
kernel /boot/vmlinuz-2.4.27-speakup root=/dev/hda1 ro
initrd /boot/initrd.img-2.4.27-speakup
savedefault
boot
title Debian GNU/Linux, kernel 2.4.27-speakup (recovery mode)
root (hd0,0)
kernel /boot/vmlinuz-2.4.27-speakup root=/dev/hda1 ro single
initrd /boot/initrd.img-2.4.27-speakup
savedefault
boot
Finally reboot the server, cross your fingers and you should now have cifs filesystem support, you can check the current running kernel with uname.
Linux Archive 2.4.27-CIFS #1 Fri Nov 10 15:18:53 EST 2006 i686 GNU/Linux
Mount a Windows 2003 share: