Welcome to the Linux Foundation Forum!

How to remove kernel source ?

chekkizhar
chekkizhar Posts: 182

hai,

In fedora, tried to recompile the kernel, but failed. After that During boot menu, the Fedora bootloader is showing the improper kernel too. If i choose, its taking me to login screen, but after that nothing, it just stopped.

I want to remove this, not from bootloader alone, the entire kernel that I compiled wrongly .

thank you

Comments

  • marc
    marc Posts: 647
    linustorvalds wrote:
    hai,
    In fedora, tried to recompile the kernel, but failed. After that During boot menu, the Fedora bootloader is showing the improper kernel too. If i choose, its taking me to login screen, but after that nothing, it just stopped.
    I want to remove this, not from bootloader alone, the entire kernel that I compiled wrongly .

    thank you

    That depends on how you installed it.

    Usually there's a file in the /boot directory which is the kernel.

    Anyway, you do not need to uninstall it, just make sure there's a grub entry pointing to the right kernel (usually the one that comes with the distro is in /boot/vmlinuz)

    Regards
  • atreyu
    atreyu Posts: 216
    If you're absolutely sure that you know your BAD KERNEL VERSION (e.g., 2.6.36), then you can do this to remove it:
    rm -rf /lib/modules/{BAD_KERNEL_VER}/
    rm -f /boot/vmlinuz-{BAD_KERNEL_VER}*
    rm -f /boot/initrd-{BAD_KERNEL_VER}*
    rm -f /boot/config-{BAD_KERNEL_VER}*
    rm -f /boot/System.map-{BAD_KERNEL_VER}*
    
    The first command removes the bad kernel's installed modules. The rest of the commands remove the bad kernel image and any initial ramdisk images, system maps, and kernel config files.

    You can always reinstall a Fedora-packaged kernel, too. First remove the entry from the RPM database:
    rpm -e --justdb kernel (or kernel-PAE)
    

    Then reinstall it w/yum, e,g:
    yum install kernel (or kernel-PAE)
    

    If you have multiple kernel packages installed, then you can do the above rpm/yum commands, but you have to pass the package version info with it, e.g.: kernel-2.6.36-1.fc10

    List all installed kernels with:
    rpm -qa kernel (or kernel-PAE)
    
    Of course, don't do any of this unless you're feeling bold!
  • chekkizhar
    chekkizhar Posts: 182
    atreyu wrote:
    If you're absolutely sure that you know your BAD KERNEL VERSION (e.g., 2.6.36), then you can do this to remove it:
    rm -rf /lib/modules/{BAD_KERNEL_VER}/
    rm -f /boot/vmlinuz-{BAD_KERNEL_VER}*
    rm -f /boot/initrd-{BAD_KERNEL_VER}*
    rm -f /boot/config-{BAD_KERNEL_VER}*
    rm -f /boot/System.map-{BAD_KERNEL_VER}*
    
    The first command removes the bad kernel's installed modules. The rest of the commands remove the bad kernel image and any initial ramdisk images, system maps, and kernel config files.

    You can always reinstall a Fedora-packaged kernel, too. First remove the entry from the RPM database:
    rpm -e --justdb kernel (or kernel-PAE)
    

    Then reinstall it w/yum, e,g:
    yum install kernel (or kernel-PAE)
    

    If you have multiple kernel packages installed, then you can do the above rpm/yum commands, but you have to pass the package version info with it, e.g.: kernel-2.6.36-1.fc10

    List all installed kernels with:
    rpm -qa kernel (or kernel-PAE)
    
    Of course, don't do any of this unless you're feeling bold!
    thank you... I will give a try in coming weekend...
  • woboyle
    woboyle Posts: 501
    You also need to edit /boot/grub/grub.conf and remove the entry for the bad kernel.

    I think what you have gone through is not uncommon for the first-time kernel builder. That happened to me also. Just remember to build/install the kernel like this:

    1. make menuconfig, or make xconfig
    2. make -jN, where N is the number of build threads to use - 1 per core or processor is good.
    3. As root, make headers_install, make modules_install, make install - you can do all that (as root) with one command:

    make headers_install modules_install install

    If you just try make install, it won't do all the dependencies properly sometimes, so installing the headers and modules first makes sure all the drivers are in /lib/modules/KERNEL_VERSION before it actually tries to install the kernel into /boot.

Categories

Upcoming Training