Not too long ago, I got myself a nice 500GB PCI-e NVME SSD, for those who don’t know what that is, it’s basically a very fast SSD. The model I got is a Kingston A2000 and I must say, it’s a very good drive for the price. It was fine and all but I ran into OS lock-ups where randomly, without any warning, the main drive would behave as if someone has unplugged it. I couldn’t even install Fedora at one point, it failed to format the drive! Of course, this is unacceptable and something had to be done… Let’s begin with a back story.
Install Windows… why?
Yes, I’ve tested it on Windows 10 and I’ve had no issues regarding OS lockups. Of course, I could just use Windows and be done with it but because we don’t do that around here, I had to find a solution to this and so, the research began.
Bug report, hooray!
I found this bug report and reading some of the things people posted, it looked like it wasn’t going to be fixed due to the mixed responses people gave. Luckily, after testing some GRUB options out, I found one that worked perfectly. All I had to do was add a line to my GRUB_CMDLINE_LINUX
and reload the GRUB configuration. That’s it!
The solution
Open up a terminal, and find your GRUB file, generally it is /etc/default/grub
but check your distribution’s documentation. Open it up in a text editor with superuser privileges. I’ll use vim for this…
sudo vim /etc/default/grub
Then, in the GRUB_CMDLINE_LINUX
part, simply append the code below into the GRUB_CMDLINE_LINUX=””, to the end of it.
nvme_core.default_ps_max_latency_us=0
It should look something like this after you’ve done it, don’t copy what I have as your system will have different.
Save and exit the text editor, then run the following command
# For Fedora, Arch Linux, etc.
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
# For Ubuntu, Debian, Linux Mint, etc. (debian-based)
sudo update-grub
Then reboot!
If you want to check if the command worked, you can run the following command and the expected output should be 0:
cat /sys/module/nvme_core/parameters/default_ps_max_latency_us
Hopefully that should fix your NVME problems. If you want to keep up-to-date on the bug-report, consider checking here once in a while.
Timo
August 22, 2020 — 10:03 am
Thank you so so so much for this article! It was the only thing that helped me with my NVMe Linux problem.
I have a XPS 9570 that is running Linux and Windows (just for gaming). It came with a SK Hynix 500GB NVMe that made zero problems under Linux. Then I upgraded to a Kingston A2000 1TB NVMe and the problems started…
I also had random freezes especially when I started to write a lot of data to the SSD (big downloads, system updates etc.). dmesg said something about the NVMe controller resetting.
I’ve researched a lot about compatibility problems with the A2000 and Linux and also the controller that is used by this SSD. Nothing…
In Windows I had no problems.
So I opened a RMA and Kingston replaced the SSD within one week (great service btw!). But after one day the problems started again…
So I researched again without any hope and thought I wasted my money on this SSD.
And then I found your article that you’ve written a few days before my new SSD from Kingston service arrived 😀
Again: Big big thanks to you!
berk
August 22, 2020 — 12:36 pm
No problem! That’s quite a journey you had there! I’m glad it worked out for you. 🙂
Scott
September 5, 2020 — 5:23 am
Hi. Do you know how I could update the Fedora Live ISO with this new command so that I can install it to my ThinkPad?
berk
September 7, 2020 — 2:55 am
So when you pick the USB as boot-device, you get presented with a GRUB boot screen which where you can pick to “Install Fedora …” or “Test this media & install …” Highlight the one you want to go into and press “E” on your keyboard (if you’re booting with EFI). If you’re using legacy mode to boot, you might need to press “TAB”. You will then go into edit mode.
Go to the end of the line “vmlinuz …. …. quiet ” and append “nvme_core.default_ps_max_latency_us=0” (no quotes).
Again, if you’re on UEFI, you will press “Ctrl+x” which will boot into Fedora with the new changes. If you’re using legacy mode, pressing enter should suffice.
Hope this helps!
Scott
September 7, 2020 — 9:39 pm
Hi. Thanks!!! It worked perfectly.
Just a note for other users I had to use F10 to save the new changes in the Grub menu because Ctrl+X wasn’t working.
Thanks again. Hopefully we get an upstream fix soon.
Alexey
October 2, 2020 — 6:20 pm
Hi. Thanks! It worked for me. I had the same problem with 2 TB Kingston KC2000. It was quite unpleasant time till I came across your article. 🙂
M
November 26, 2020 — 10:51 am
Thanks so much. This saved my bacon when I installed this harddrive as my main drive on my laptop and leading me to crashes I had never seen before in my time on linux. Thanks!!!
Dee
December 7, 2020 — 9:26 am
Hi Berk and thanks for writing this.
I’m up to the GRUB2.MKConfig but I’m having an error.
I’ve installed “sudo apt install grub2”
Now I type “sudo grub2-mkconfig -o /boot/grub2/grub.cfg” it says command not found
berk
December 7, 2020 — 9:44 am
Hi Dee,
Since you’re on Ubuntu, the command to update GRUB would be: “sudo update-grub”. The command supplied in the guide is for different operating systems.
Give that a shot and let me know how you go. 🙂
R
December 24, 2020 — 11:17 pm
Hi Berk,
I’ve had the freezing issue a couple of times before testing your fix. I managed to make the change on my GRUB and updated successfully. The device was running okay for about a week and a half before the same symptoms reappeared.
After rebooting, and running cat /sys/module/nvme_core/parameters/default_ps_max_latency_us it still returned 0 as value. Any other areas that I may need to change to avoid further device lockup?
Intel 660p NVME SSD with i5-10210U on Ubuntu 20.04