DEV Community

Dmitry Gordin
Dmitry Gordin

Posted on

1

NVIDIA Drivers with Secure Boot on Ubuntu

After enabling Secure Boot in BIOS settings on my PC with Kubuntu, I noticed laggy animations. When checking nvidia-smi, I got this error:

NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.

Updating apt packages and drivers didn't help. After a day of troubleshooting, here's what worked for me:

# Install necessary tools
sudo apt update && sudo apt install -y openssl mokutil

# Create directory for keys
sudo mkdir -p /var/lib/shim-signed/mok/

# Generate the key that will be used to sign drivers
sudo openssl req -new -x509 -newkey rsa:2048 -keyout /var/lib/shim-signed/mok/MOK.priv -outform DER -out /var/lib/shim-signed/mok/MOK.der -days 36500 -subj "/CN=MyKey4Nvidia/" -nodes

# Import generated key
sudo mokutil --import /var/lib/shim-signed/mok/MOK.der
Enter fullscreen mode Exit fullscreen mode

Now you will be prompted to enter a new password, this can be any string (not necessary your user's password). Remember it! You'll need to enter it after reboot.

# Reinstall NVIDIA drivers
sudo apt purge 'nvidia*'
sudo apt autoremove
sudo ubuntu-drivers autoinstall
Enter fullscreen mode Exit fullscreen mode

Reboot your system. At the beginning of the boot process, you'll see a countdown for 10 seconds to enter the MOK management menu.
Select "Enroll MOK", press continue, and enter the password you created earlier. After enrollment, select the reboot option.

That's it! After booting up, you should have working NVIDIA drivers. Verify this with the nvidia-smi command.

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someone’s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay