Compile Kernel 2.6 under Debian Sarge

Discussion in 'Kernel Questions' started by falko, Apr 21, 2005.

  1. falko

    falko Super Moderator Howtoforge Staff

    This is a little bit different from compiling a kernel 2.6 on Debian Woody because Sarge uses grub as the boot loader (instead of lilo) and because module-init-tools, initrd-tools, procps are already installed. After all it's similar to http://www.howtoforge.com/howto_linux_kernel_2.6_compile_debian. This is how you do it:

    Code:
    apt-get install kernel-package libncurses5-dev fakeroot wget bzip2
    cd /usr/src
    wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.11.7.tar.bz2
    tar xjf linux-2.6.11.7.tar.bz2
    cd linux-2.6.11.7/
    make menuconfig
    It is normally a good idea to take the configuration of your existing (working!) kernel 2.6 as a starting point for the configuration of your new kernel. Usually the current kernel configuration is saved in a file under /boot, e.g. /boot/config-2.6.3. I will load this configuration and then do the changes I desire. If you do not have the config file of a working kernel 2.6 this one might help you: http://www.falkotimme.com/howtos/debian_kernel2.6_compile/config-2.6.8.1

    Code:
    make-kpkg clean
    fakeroot make-kpkg --initrd --revision=custom.1.0 kernel_image
    If the compilation stops with an error, run

    Code:
    make clean
    and then re-run the previous commands starting with

    Code:
    make menuconfig
    Go ahead with
    Code:
    cd ../
    dpkg -i kernel-image-2.6.11.7_custom.1.0_i386.deb
    This will install your new kernel (including a ramdisk) and also update grub. You can now reboot your system, and you should then have a new kernel. You can check that by running:
    Code:
    uname -a
     
    Last edited: Nov 4, 2005
  2. tylerdurden

    tylerdurden New Member

    Nice walkthrough, thanks! :)

    tyler
     
  3. floobit

    floobit New Member

    some errors

    after running the apt-get update with these sources:
    deb http://security.debian.org/ stable/updates main contrib non-free
    deb http://secure-testing.debian.net/debian-secure-testing testing/security-updates main contrib non-free
    deb http://http.us.debian.org/debian/ stable main contrib non-free
    deb http://http.us.debian.org/debian/ testing main contrib non-free
    deb http://http.us.debian.org/debian/ unstable main contrib non-free
    deb http://debian.kcore.org/ ./


    I started following the instructions. On the first line

    apt-get install kernel-package ncurses-dev fakeroot wget bzip2
    I encountered 2 errors. First, it informed me that:
    Reading Package Lists...
    Building Dependency Tree...
    Package ncurses-dev is a virtual package provided by:
    libncurses5-dev 5.4-9
    You should explicitly select one to install.

    and it installed none of the packages

    so, I removed the ncurses-dev from the install list and tried again. this time, all packages were installed, but it prompted me for if I wanted to stop gdm before I installed glibc. This was slightly weird, because I logged in as "repair" from grub. also, I don't believe gdm was running, because ps -A yielded:

    PID TTY TIME CMD
    1 ? 00:00:00 init
    2 ? 00:00:00 ksoftirqd/0
    3 ? 00:00:00 events/0
    4 ? 00:00:00 khelper
    5 ? 00:00:00 kacpid
    35 ? 00:00:00 kblockd/0
    45 ? 00:00:00 pdflush
    46 ? 00:00:00 pdflush
    48 ? 00:00:00 aio/0
    47 ? 00:00:00 kswapd0
    184 ? 00:00:00 kseriod
    293 ? 00:00:00 kjournald
    346 ? 00:00:00 udevd
    1452 ? 00:00:00 khubd
    2731 ? 00:00:00 dhclient
    2736 ? 00:00:00 portmap
    3083 tty1 00:00:00 init
    3101 tty1 00:00:00 bash
    3497 tty1 00:00:00 ps


    I chose to install glibc anyway, but can easily start over if I need to.

    Thanks,
    Dylan Evans
     
  4. falko

    falko Super Moderator Howtoforge Staff

    Have you been successful in installing your new kernel, or did you encounter problems?
     
  5. floobit

    floobit New Member

    sorta...

    My kernel compiled completely with some warnings. When I rebooted, it gave me a
    Code:
    VFS: Cannot open root device "hdb1" or unknown block (0,0)
    kernel panic: not syncing: unable to mount root fs on unknown-block(0,0)
    
    I have two physical HDs, one 6.4 gig (primary slave) with / and a swap on it, and a 80 gig with windows and /home and a swap. I believe the ramdrive installed correctly (at least no errors popped up) and I used my earlier kernel as a start point, and it boots fine. Any ideas?

    Dylan
     
  6. falko

    falko Super Moderator Howtoforge Staff

    What's in /boot/grub/menu.1st?
     
  7. floobit

    floobit New Member

    Code:
    title		Debian GNU/Linux, kernel 2.6.13.4 
    root		(hd1,0)
    kernel		/boot/vmlinuz-2.6.13.4 root=/dev/hdb1 ro 
    savedefault
    boot
    + an identical (recovery mode)

    and my vanilla kernel

    Dylan
     
  8. falko

    falko Super Moderator Howtoforge Staff

    I need to see the whole file, not just an excerpt.
     
  9. floobit

    floobit New Member

    # menu.lst - See: grub(8), info grub, update-grub(8)
    # grub-install(8), grub-floppy(8),
    # grub-md5-crypt, /usr/share/doc/grub
    # and /usr/share/doc/grub-doc/.

    ## default num
    # Set the default entry to the entry number NUM. Numbering starts from 0, and
    # the entry number 0 is the default if the command is not used.
    #
    # You can specify 'saved' instead of a number. In this case, the default entry
    # is the entry saved with the command 'savedefault'.
    default 0

    ## timeout sec
    # Set a timeout, in SEC seconds, before automatically booting the default entry
    # (normally the first entry defined).
    timeout 5

    # Pretty colours
    color cyan/blue white/blue

    ## password ['--md5'] passwd
    # If used in the first section of a menu file, disable all interactive editing
    # control (menu entry editor and command-line) and entries protected by the
    # command 'lock'
    # e.g. password topsecret
    # password --md5 $1$gLhU0/$aW78kHK1QfV3P2b2znUoe/
    # password topsecret

    #
    # examples
    #
    # title Windows 95/98/NT/2000
    # root (hd0,0)
    # makeactive
    # chainloader +1
    #
    # title Linux
    # root (hd0,1)
    # kernel /vmlinuz root=/dev/hda2 ro
    #

    #
    # Put static boot stanzas before and/or after AUTOMAGIC KERNEL LIST

    ### BEGIN AUTOMAGIC KERNELS LIST
    ## lines between the AUTOMAGIC KERNELS LIST markers will be modified
    ## by the debian update-grub script except for the default options below

    ## DO NOT UNCOMMENT THEM, Just edit them to your needs

    ## ## Start Default Options ##
    ## default kernel options
    ## default kernel options for automagic boot options
    ## If you want special options for specifiv kernels use kopt_x_y_z
    ## where x.y.z is kernel version. Minor versions can be omitted.
    ## e.g. kopt=root=/dev/hda1 ro
    # kopt=root=/dev/hdb1 ro

    ## default grub root device
    ## e.g. groot=(hd0,0)
    # groot=(hd1,0)

    ## should update-grub create alternative automagic boot options
    ## e.g. alternative=true
    ## alternative=false
    # alternative=true

    ## should update-grub lock alternative automagic boot options
    ## e.g. lockalternative=true
    ## lockalternative=false
    # lockalternative=false

    ## altoption boot targets option
    ## multiple altoptions lines are allowed
    ## e.g. altoptions=(extra menu suffix) extra boot options
    ## altoptions=(recovery mode) single
    # altoptions=(recovery mode) single

    ## controls how many kernels should be put into the menu.lst
    ## only counts the first occurence of a kernel, not the
    ## alternative kernel options
    ## e.g. howmany=all
    ## howmany=7
    # howmany=all

    ## should update-grub create memtest86 boot option
    ## e.g. memtest86=true
    ## memtest86=false
    # memtest86=true

    ## ## End Default Options ##

    title Debian GNU/Linux, kernel 2.6.13.4
    root (hd1,0)
    kernel /boot/vmlinuz-2.6.13.4 root=/dev/hdb1 ro
    savedefault
    boot

    title Debian GNU/Linux, kernel 2.6.13.4 (recovery mode)
    root (hd1,0)
    kernel /boot/vmlinuz-2.6.13.4 root=/dev/hdb1 ro single
    savedefault
    boot

    title Debian GNU/Linux, kernel 2.6.8-2-k7
    root (hd1,0)
    kernel /boot/vmlinuz-2.6.8-2-k7 root=/dev/hdb1 ro
    initrd /boot/initrd.img-2.6.8-2-k7
    savedefault
    boot

    title Debian GNU/Linux, kernel 2.6.8-2-k7 (recovery mode)
    root (hd1,0)
    kernel /boot/vmlinuz-2.6.8-2-k7 root=/dev/hdb1 ro single
    initrd /boot/initrd.img-2.6.8-2-k7
    savedefault
    boot

    ### END DEBIAN AUTOMAGIC KERNELS LIST

    # This is a divider, added to separate the menu items below from the Debian
    # ones.
    title Other operating systems:
    root


    # This entry automatically added by the Debian installer for a non-linux OS
    # on /dev/hda1
    title Microsoft Windows XP Professional
    root (hd0,0)
    savedefault
    makeactive
    chainloader +1
     
  10. falko

    falko Super Moderator Howtoforge Staff

    You have no initrd line for your new kernel. Maybe that causes the error.
     
  11. floobit

    floobit New Member

    You're right!

    I added a initrd line to my menu.lst, and it booted wonderfully - thanks a bunch! However, when compiling, I had installed the latest gcc (4.0) and g++, but it said it would use the earlier 3.3 version to compile the kernel. does this mean if I compile any modules (like the latest nvidia driver), they will use gcc/g++ 4.0, and won't be compatible with my kernel? Is there a way to check (to see if I'm wrong) which g++/gcc compiler I used?

    Dylan
     
  12. falko

    falko Super Moderator Howtoforge Staff

    I don't think so. I'd try it.
     
  13. JL84

    JL84 New Member

    I went through the whole process of upgrading to kernel 2.6 and I made sure that the initr-img was in the right place, but when I loaded with the new kernel 2.6 it gave me another error. The boot was trying to find /sbin/init/ and /dev/console/ where would those be entered in so that the kernel can load?
     
  14. Iwan

    Iwan New Member

    Works great except I had to

    apt-get install yaird

    aswell ;)
     
  15. Januss

    Januss New Member

    Are you sure you have your root FS compiled in kernel?

    Hi,
    I had the same problem with my upgrade to 2.6.8.
    At first the kernel didn't boot at all, but after i
    did mkinitrd and added the initrd image to grub menu.lst I had the same results as you had written.
    As it turned out, I forgot to compile ext3 support into the kernel, which is needed if you have ext3 as the root fs (/).

    Hope this helps someone.
     
  16. stevendemetrius

    stevendemetrius New Member


    Check the command you typed. It should be "libncurses5-dev" not "ncurses-dev"
     
  17. stevendemetrius

    stevendemetrius New Member

    Do you know the type of file system on your boot drive? It must be complied in the kernel and *not* as a module. This is set in the kernel configuration.

    If you boot file system is ext3 then when you configure the kernel then the ext3 file system must be marked to be compiled in the kernel.
     
  18. Flip

    Flip New Member

    Ill get this error,
    Pivot_root: No such file or directory
    /sbin/init: 432: cannot open dev/console: No such file
    Kernel panic - not syncing: Attempted to kill init:

    This is my /boot/grub/menu.lst

    Code:
    # menu.lst - See: grub(8), info grub, update-grub(8)
    #            grub-install(8), grub-floppy(8),
    #            grub-md5-crypt, /usr/share/doc/grub
    #            and /usr/share/doc/grub-doc/.
    
    ## default num
    # Set the default entry to the entry number NUM. Numbering starts from 0, and
    # the entry number 0 is the default if the command is not used.
    #
    # You can specify 'saved' instead of a number. In this case, the default entry
    # is the entry saved with the command 'savedefault'.           
    default		0
    
    ## timeout sec
    # Set a timeout, in SEC seconds, before automatically booting the default entry
    # (normally the first entry defined).
    timeout		20
    
    # Pretty colours
    color cyan/blue white/blue
    
    ## password ['--md5'] passwd
    # If used in the first section of a menu file, disable all interactive editing
    # control (menu entry editor and command-line)  and entries protected by the
    # command 'lock'
    # e.g. password topsecret
    #      password --md5 $1$gLhU0/$aW78kHK1QfV3P2b2znUoe/
    # password topsecret
    
    #
    # examples
    #
    # title		Windows 95/98/NT/2000
    # root		(hd0,0)
    # makeactive
    # chainloader	+1
    #
    # title		Linux
    # root		(hd0,1)
    # kernel	/vmlinuz root=/dev/hda2 ro
    #
    
    #
    # Put static boot stanzas before and/or after AUTOMAGIC KERNEL LIST
    
    ### BEGIN AUTOMAGIC KERNELS LIST
    ## lines between the AUTOMAGIC KERNELS LIST markers will be modified
    ## by the debian update-grub script except for the default options below
    
    ## DO NOT UNCOMMENT THEM, Just edit them to your needs
    
    ## ## Start Default Options ##
    ## default kernel options
    ## default kernel options for automagic boot options
    ## If you want special options for specifiv kernels use kopt_x_y_z
    ## where x.y.z is kernel version. Minor versions can be omitted.
    ## e.g. kopt=root=/dev/hda1 ro
    # kopt=root=/dev/hda1 ro
    
    ## default grub root device
    ## e.g. groot=(hd0,0)
    # groot=(hd0,0)
    
    ## should update-grub create alternative automagic boot options
    ## e.g. alternative=true
    ##      alternative=false
    # alternative=true
    
    ## should update-grub lock alternative automagic boot options
    ## e.g. lockalternative=true
    ##      lockalternative=false
    # lockalternative=false
    
    ## altoption boot targets option
    ## multiple altoptions lines are allowed
    ## e.g. altoptions=(extra menu suffix) extra boot options
    ##      altoptions=(recovery mode) single
    # altoptions=(recovery mode) single
    
    ## controls how many kernels should be put into the menu.lst
    ## only counts the first occurence of a kernel, not the
    ## alternative kernel options
    ## e.g. howmany=all
    ##      howmany=7
    # howmany=all
    
    ## should update-grub create memtest86 boot option
    ## e.g. memtest86=true
    ##      memtest86=false
    # memtest86=true
    
    ## ## End Default Options ##
    
    title		Debian GNU/Linux, kernel 2.6.15.6 
    root		(hd0,0)
    kernel		/boot/vmlinuz-2.6.15.6 root=/dev/hda1 ro 
    initrd		/boot/initrd.img-2.6.15.6
    savedefault
    boot
    
    title		Debian GNU/Linux, kernel 2.6.15.6 (recovery mode)
    root		(hd0,0)
    kernel		/boot/vmlinuz-2.6.15.6 root=/dev/hda1 ro single
    initrd		/boot/initrd.img-2.6.15.6
    savedefault
    boot
    
    title		Debian GNU/Linux, kernel 2.6.11.7 
    root		(hd0,0)
    kernel		/boot/vmlinuz-2.6.11.7 root=/dev/hda1 ro 
    initrd		/boot/initrd.img-2.6.11.7
    savedefault
    boot
    
    title		Debian GNU/Linux, kernel 2.6.11.7 (recovery mode)
    root		(hd0,0)
    kernel		/boot/vmlinuz-2.6.11.7 root=/dev/hda1 ro single
    initrd		/boot/initrd.img-2.6.11.7
    savedefault
    boot
    
    title		Debian GNU/Linux, kernel 2.4.27-2-386 
    root		(hd0,0)
    kernel		/boot/vmlinuz-2.4.27-2-386 root=/dev/hda1 ro 
    initrd		/boot/initrd.img-2.4.27-2-386
    savedefault
    boot
    
    title		Debian GNU/Linux, kernel 2.4.27-2-386 (recovery mode)
    root		(hd0,0)
    kernel		/boot/vmlinuz-2.4.27-2-386 root=/dev/hda1 ro single
    initrd		/boot/initrd.img-2.4.27-2-386
    savedefault
    boot
    
    ### END DEBIAN AUTOMAGIC KERNELS LIST
    
    # This is a divider, added to separate the menu items below from the Debian
    # ones.
    title		Other operating systems:
    root
    
    
    Can you help me?
     
  19. falko

    falko Super Moderator Howtoforge Staff

    Can you post your /etc/fstab here?
     
  20. Flip

    Flip New Member

    This is my /etc/fstab

    Code:
    # /etc/fstab: static file system information.
    #
    # <file system> <mount point>   <type>  <options>       <dump>  <pass>
    proc            /proc           proc    defaults        0       0
    /dev/hda1       /               ext3    defaults,errors=remount-ro 0       1
    /dev/hda5       none            swap    sw              0       0
    /dev/hdc        /media/cdrom0   iso9660 ro,user,noauto  0       0
    /dev/fd0        /media/floppy0  auto    rw,user,noauto  0       0
    /dev/hdb1       /home           ext3    defaults,errors=remount-ro 0       1
    
     

Share This Page