Installing NVIDIA Driver and Fix Boot Loading and Freezing Issue in Kali Linux

After spending nearly a week on fixing this issue and searching around i finally found an amazing tutorial which will definitely going to work for you. I don’t know why on official kali.org website they have a tutorial as well but that didn’t work for me i have to restore my Kali Linux.

But here’s an amazing tutorial:

My system:

[email protected]:~# uname -a
Linux TheHackerToday 4.9.0-kali4-amd64 #1 SMP Debian 4.9.30-2kali1 (2017-06-22) x86_64 GNU/Linux

Code:

[email protected]:~# cat /etc/*release*
DISTRIB_ID=Kali
DISTRIB_RELEASE=kali-rolling
DISTRIB_CODENAME=kali-rolling
DISTRIB_DESCRIPTION="Kali GNU/Linux Rolling"
PRETTY_NAME="Kali GNU/Linux Rolling"
NAME="Kali GNU/Linux"
ID=kali
VERSION="2017.1"
VERSION_ID="2017.1"
ID_LIKE=debian
ANSI_COLOR="1;31"
HOME_URL="http://www.kali.org/"
SUPPORT_URL="http://forums.kali.org/"
BUG_REPORT_URL="http://bugs.kali.org/"

Installing NVIDIA Driver and Fix Boot Loading and Freezing Issue

Before we begin,couple of notes:

***USE AT YOUR OWN RISK***
*This tutorial is for official NVIDIA Driver not Bumblebee 
*Tutorial found on official Kali website is BROKEN! It never works for optimus/hybrid Graphics enabled laptop

1. Verify you have hybrid graphics

[email protected]:~# lspci | grep -E "VGA|3D"
00:02.0 VGA compatible controller: Intel Corporation HD Graphics 530 (rev 06)
02:00.0 3D controller: NVIDIA Corporation GM107M [GeForce GTX 960M] (rev a2)

2.Disable nouveau

echo -e "blacklist nouveau\noptions nouveau modeset=0\nalias nouveau off" > /etc/modprobe.d/blacklist-nouveau.conf

update-initramfs -u && reboot

3.system will reboot and nouveau should be disabled.verify if nouveau is disabled:

lsmod |grep -i nouveau

If shows nothing,means nouveau successfully disabled.

4.Install nvidia driver from kali repo:

apt-get install  nvidia-driver nvidia-xconfig

You can also download latest .run file from nvidia website.execute and procceed with installation.whether its from kali repo or nvidia website,procedure is same.

5.Now we have to find bus id of our nvidia card:

nvidia-xconfig --query-gpu-info | grep 'BusID : ' | cut -d ' ' -f6

it should show something like this:

PCI:5:0:0

This is our Bus ID.
6.Now we generate /etc/X11/xorg.conf file with this bus ID according to nvidia guide http://us.download.nvidia.com/XFree8…E/randr14.html:

Section "ServerLayout"
    Identifier "layout"
    Screen 0 "nvidia"
    Inactive "intel"
EndSection

Section "Device"
    Identifier "nvidia"
    Driver "nvidia"
    BusID "PCI:5:0:0"
EndSection

Section "Screen"
    Identifier "nvidia"
    Device "nvidia"
    Option "AllowEmptyInitialConfiguration"
EndSection

Section "Device"
    Identifier "intel"
    Driver "modesetting"
EndSection

Section "Screen"
    Identifier "intel"
    Device "intel"
EndSection

Replace the bold string with your Bus ID and save it to /etc/X11/xorg.conf

7.Now we have to create some scripts according to our display manager https://wiki.archlinux.org/index.php…splay_Managers.Since im using default Kali linux which is GDM,i created two files:
/usr/share/gdm/greeter/autostart/optimus.desktop
/etc/xdg/autostart/optimus.desktop
with the following content:

[Desktop Entry]
Type=Application
Name=Optimus
Exec=sh -c "xrandr --setprovideroutputsource modesetting NVIDIA-0; xrandr --auto"
NoDisplay=true
X-GNOME-Autostart-Phase=DisplayServer

8. Now reboot and you should be using Nvidia Driver.Verify if everything is ok:

[email protected]:~# glxinfo | grep -i "direct rendering"

direct rendering: Yes

Optional: you can now install your cuda toolkits:

apt-get install ocl-icd-libopencl1 nvidia-cuda-toolkit

FIXING SCREEN TEARING ISSUE:
After you successfully boot up with Nvidia Driver, you most probably experiencing screen tearing issue eg: playing videos in VLC,youtube video on Chrome/Firefox etc.Luckily,we can fix this by enabling PRIME Sync.

1.Verify if PRIME is disabled

xrandr --verbose|grep PRIME

it should output something like this:
PRIME Synchronization: 0
PRIME Synchronization: 1

First one is our connected display.So PRIME sync is disabled.
2. Edit /etc/default/grub and append nvidia-drm.modeset=1 in GRUB_CMDLINE_LINUX_DEFAULT after quiet.Like the following:

....
GRUB_CMDLINE_LINUX_DEFAULT="quiet nvidia-drm.modeset=1"
...

3.Save the changes.Update grub

update-grub

4.Reboot your system.
5.Verify if PRIME is enabled:

xrandr --verbose|grep PRIME

Now it should output:
PRIME Synchronization: 1
PRIME Synchronization: 1 

If it still shows 0 for you,then there is probably something wrong with your system config/kernel.Since this is still an experimental feature from Nvidia,you are out of luck.

***IF YOU STUCK IN BOOT SCREEN***
Revert what we have done so far:
Press CTRL+ALT+F2 or CTRL+ALT+F3 ,login with your password.

apt-get remove --purge nvidia*
rm -rf /etc/X11/xorg.conf

Remove those display manager files we created earlier (for GDM):

rm -rf /usr/share/gdm/greeter/autostart/optimus.desktop
rm -rf /etc/xdg/autostart/optimus.desktop
Now Reboot! You should be able get back to your old system.

Back to top button
Close