Nvidia drivers don't work with mainline kernel

9,161

(answering my own question, as Bruno suggested in comments)

This problem is fixed by installing the Nvidia-provided drivers by hand, following the below steps.

  1. Download the drivers from the Nvidia website
  2. Reboot into recovery mode as the drivers won't install with X running. Do this by rebooting, holding shift if necessary to get into Grub and choosing the recovery option, then "Root shell" at the text menu.
  3. You should now be faced with a shell that looks something like this:

    root@sirius:~# 
    

    Enter the following command so that the root filesystem is writable:

    mount -o rw,remount /
    
  4. Install a few required packages (you may need to do dhclient eth0 to bring the network up beforehand):

    apt-get install dkms
    
  5. Make the Nvidia installer executable and run it:

    chmod +x $INSTALLER_FILE
    ./$INSTALLER_FILE
    

    where $INSTALLER_FILE is the location where the installer is downloaded to (use tab-completion to help you, probably something like /home/josh/Downloads/NVIDIA-Linux-x86_64-302.17.run)

  6. Work through the steps in the installer. The defaults should work.

  7. Reboot into a normal system.
Share:
9,161

Related videos on Youtube

dutchie
Author by

dutchie

Updated on September 18, 2022

Comments

  • dutchie
    dutchie almost 2 years

    I want to try some of the new features in the btrfs filesystem, and to do that I need to use a newer kernel than is included in Ubuntu 12.04. To do that, I have installed linux-headers-3.4.0-030400_3.4.0-030400.201205210521_all.deb, linux-headers-3.4.0-030400-generic_3.4.0-030400.201205210521_amd64.deb, and linux-image-3.4.0-030400-generic_3.4.0-030400.201205210521_amd64.deb from the mainline kernel download here.

    However, on rebooting into the 3.4 kernel, my desktop is stuck at a very low resolution and I cannot increase it to the full. This did happen when I first installed, but a simple install of the nvidia-current package got everything working nicely with my GTX570 card. There were appear to be some DKMS errors when I installed the kernel, and they indicated I should look at /var/lib/dkms/nvidia-current/295.40/build/make.log:

    josh@sirius:~/Downloads$ sudo dpkg -i linux-*.deb
    Selecting previously unselected package linux-headers-3.4.0-030400.
    (Reading database ... 309400 files and directories currently installed.)
    Unpacking linux-headers-3.4.0-030400 (from linux-headers-3.4.0-030400_3.4.0-030400.201205210521_all.deb) ...
    Selecting previously unselected package linux-headers-3.4.0-030400-generic.
    Unpacking linux-headers-3.4.0-030400-generic (from linux-headers-3.4.0-030400-generic_3.4.0-030400.201205210521_amd64.deb) ...
    Selecting previously unselected package linux-image-3.4.0-030400-generic.
    Unpacking linux-image-3.4.0-030400-generic (from linux-image-3.4.0-030400-generic_3.4.0-030400.201205210521_amd64.deb) ...
    Done.
    Setting up linux-headers-3.4.0-030400 (3.4.0-030400.201205210521) ...
    Setting up linux-headers-3.4.0-030400-generic (3.4.0-030400.201205210521) ...
    Examining /etc/kernel/header_postinst.d.
    run-parts: executing /etc/kernel/header_postinst.d/dkms 3.4.0-030400-generic /boot/vmlinuz-3.4.0-030400-generic
    ERROR (dkms apport): kernel package linux-headers-3.4.0-030400-generic is not supported
    Error! Bad return status for module build on kernel: 3.4.0-030400-generic (x86_64)
    Consult /var/lib/dkms/nvidia-current/295.40/build/make.log for more information.
    Setting up linux-image-3.4.0-030400-generic (3.4.0-030400.201205210521) ...
    Running depmod.
    update-initramfs: deferring update (hook will be called later)
    Examining /etc/kernel/postinst.d.
    run-parts: executing /etc/kernel/postinst.d/dkms 3.4.0-030400-generic /boot/vmlinuz-3.4.0-030400-generic
    ERROR (dkms apport): kernel package linux-headers-3.4.0-030400-generic is not supported
    Error! Bad return status for module build on kernel: 3.4.0-030400-generic (x86_64)
    Consult /var/lib/dkms/nvidia-current/295.40/build/make.log for more information.
    run-parts: executing /etc/kernel/postinst.d/initramfs-tools 3.4.0-030400-generic /boot/vmlinuz-3.4.0-030400-generic
    update-initramfs: Generating /boot/initrd.img-3.4.0-030400-generic
    run-parts: executing /etc/kernel/postinst.d/pm-utils 3.4.0-030400-generic /boot/vmlinuz-3.4.0-030400-generic
    run-parts: executing /etc/kernel/postinst.d/update-notifier 3.4.0-030400-generic /boot/vmlinuz-3.4.0-030400-generic
    run-parts: executing /etc/kernel/postinst.d/zz-update-grub 3.4.0-030400-generic /boot/vmlinuz-3.4.0-030400-generic
    Generating grub.cfg ...
    Found linux image: /boot/vmlinuz-3.4.0-030400-generic
    Found initrd image: /boot/initrd.img-3.4.0-030400-generic
    Found linux image: /boot/vmlinuz-3.2.0-24-generic
    Found initrd image: /boot/initrd.img-3.2.0-24-generic
    Found memtest86+ image: /memtest86+.bin
    Found Ubuntu 12.04 LTS (12.04) on /dev/sda1
    Found Windows 7 (loader) on /dev/sda2
    Found Windows 7 (loader) on /dev/sda3
    done
    

    /var/lib/dkms/nvidia-current/295.40/build/make.log:

    DKMS make.log for nvidia-current-295.40 for kernel 3.4.0-030400-generic (x86_64)
    Thu Jun  7 00:58:39 BST 2012
    NVIDIA: calling KBUILD...
    test -e include/generated/autoconf.h -a -e include/config/auto.conf || (        \
        echo;                               \
        echo "  ERROR: Kernel configuration is invalid.";       \
        echo "         include/generated/autoconf.h or include/config/auto.conf are missing.";\
        echo "         Run 'make oldconfig && make prepare' on kernel src to fix it.";  \
        echo;                               \
        /bin/false)
    mkdir -p /var/lib/dkms/nvidia-current/295.40/build/.tmp_versions ; rm -f /var/lib/dkms/nvidia-current/295.40/build/.tmp_versions/*
    make -f scripts/Makefile.build obj=/var/lib/dkms/nvidia-current/295.40/build
      cc -Wp,-MD,/var/lib/dkms/nvidia-current/295.40/build/.nv.o.d  -nostdinc -isystem /usr/lib/gcc/x86_64-linux-gnu/4.6/include -I/usr/src/linux-headers-3.4.0-030400-generic/arch/x86/include -Iarch/x86/include/generated -Iinclude  -include /usr/src/linux-headers-3.4.0-030400-generic/include/linux/kconfig.h -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -fno-delete-null-pointer-checks -O2 -m64 -mtune=generic -mno-red-zone -mcmodel=kernel -funit-at-a-time -maccumulate-outgoing-args -fstack-protector -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_FXSAVEQ=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -Wframe-larger-than=1024 -Wno-unused-but-set-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -pg -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -DCC_HAVE_ASM_GOTO -I/var/lib/dkms/nvidia-current/295.40/build -Wall -MD -Wsign-compare -Wno-cast-qual -Wno-error -D__KERNEL__ -DMODULE -DNVRM -DNV_VERSION_STRING=\"295.40\" -Wno-unused-function -Wuninitialized -mno-red-zone -mcmodel=kernel -UDEBUG -U_DEBUG -DNDEBUG  -DMODULE  -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(nv)"  -D"KBUILD_MODNAME=KBUILD_STR(nvidia)" -c -o /var/lib/dkms/nvidia-current/295.40/build/.tmp_nv.o /var/lib/dkms/nvidia-current/295.40/build/nv.c
    In file included from include/linux/kernel.h:19:0,
                     from include/linux/sched.h:55,
                     from include/linux/utsname.h:35,
                     from /var/lib/dkms/nvidia-current/295.40/build/nv-linux.h:38,
                     from /var/lib/dkms/nvidia-current/295.40/build/nv.c:13:
    include/linux/bitops.h: In function ‘hweight_long’:
    include/linux/bitops.h:66:41: warning: signed and unsigned type in conditional expression [-Wsign-compare]
    In file included from /usr/src/linux-headers-3.4.0-030400-generic/arch/x86/include/asm/uaccess.h:577:0,
                     from include/linux/poll.h:14,
                     from /var/lib/dkms/nvidia-current/295.40/build/nv-linux.h:97,
                     from /var/lib/dkms/nvidia-current/295.40/build/nv.c:13:
    /usr/src/linux-headers-3.4.0-030400-generic/arch/x86/include/asm/uaccess_64.h: In function ‘copy_from_user’:
    /usr/src/linux-headers-3.4.0-030400-generic/arch/x86/include/asm/uaccess_64.h:53:6: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    In file included from /var/lib/dkms/nvidia-current/295.40/build/nv.c:13:0:
    /var/lib/dkms/nvidia-current/295.40/build/nv-linux.h: At top level:
    /var/lib/dkms/nvidia-current/295.40/build/nv-linux.h:114:75: fatal error: asm/system.h: No such file or directory
    compilation terminated.
    make[3]: *** [/var/lib/dkms/nvidia-current/295.40/build/nv.o] Error 1
    make[2]: *** [_module_/var/lib/dkms/nvidia-current/295.40/build] Error 2
    NVIDIA: left KBUILD.
    nvidia.ko failed to build!
    make[1]: *** [module] Error 1
    make: *** [module] Error 2
    
    • Admin
      Admin about 12 years
      You should, as an option, remove the nvidia-current packages and install the drivers manually from the Nvidia site instead.
    • Admin
      Admin about 12 years
      Please feel free to delete your question or as an option (preferable) add a answer to it with the steps that it took to solve the issue.\
    • Admin
      Admin almost 10 years
      does this work with Ubuntu 14.04 too?