WD SN550 I/O Error on Linux
Many people are switching over to M.2 NVMe drives. NVMe has been supported in the Linux kernel for quite some time.
The Sandisk WD SN550 is among the cheaper M.2 drives, without a DRAM cache but utilizing a custom SanDiskWD controller and NAND flash.
Problem
The problem is that earlier (or maybe all) of these drives have a major problem with the Linux kernel. I also don't know if this is limited to the SN 550, or if their other product lines are affected as well.
The SN550 will randomly time out (?) and you will be left unable to access anything on the system. Running any command in a terminal just returns “I/O Error”. You can't debug from logs, since there is no drive anymore to log the errors to. It seems like the entire file system unmounts itself as though you unplugged it.
Interestingly, this never happened using a PCIe 3.0 x4 to M.2 adapter in my desktop but happens very frequently on my ThinkPad E495 (not with the original SkHynix drive, but after I replaced it with the sn550 for extra capacity). It has happened on both Fedora and Arch Linux so far, and causes the whole system to lock up anywhere from a minute to a day after booting.
Solution
Thanks to the ArchLinux forums, I found a kernel parameter that has solved this problem for me.
You need to add the following to your kernel parameters at boot:
nvme_core.default_ps_max_latency_us=5500
If you use GRUB, add it to your
GRUB_CMDLINE_LINUX_DEFAULT="nvme_core.default_ps_max_latency_us=5500"
variable, separated by a space from any other parameters you have.
On Arch, this is found in
/etc/default/grub
Make sure you do
sudo grub-mkconfig -o /your-efi-path/grub.cfg
to generate the new GRUB configuration! The process is similar on other bootloaders such as rEFInd, just add it to your list of other kernel parameters. You can do that directly in /path-to-efi/refind.conf (or whatever you named it).
There are many instructions to add kernel parameters on the ArchWiki.
Extras
PS: The reason I call it Sandisk is that the NAND flash is still made by Sandisk, but as far as I know, WD acquired Sandisk a few years ago, and sells many SSDs under the WD brand name instead. Similar to how Toshiba is now rebranded as Kioxia.
Now I just need to fix the stupid AMDGPU Freeze error that locks up my system every other day…