Ubuntu SSD - Was fast, is now extremely slow
Solution 1:
The quick answer:
sudo hdparm -B254 /dev/sda
The long answer:
It appears that Linux or laptops in general (verified on both Lenovo and Dells) default to APM level 80h (128) when booted on battery and FEh (254) when booted on AC power.
For most SSDs, you won't notice much difference. Lite-on SSDs seem to not support power management at all and always run at max speed. Intel SSDs seem to run at about 75% full speed at APM level 128, and 100% speed at APM level 254/255. Crucial SSDs however seem to run at about 6% full speed at APM level 128 (booted on battery) when compared to APM level 254 (booted on AC power).
The bad news is that there is no bug and no fault here. The ATA spec is sufficiently vague that Crucial SSDs running super slow in APM mode 128 is allowed and is compliant with the spec. Similarly a laptop defaulting to APM level 80h (128) is perfectly reasonable. The spec just says:
Table 106 — APM levels
COUNT field Level
00h Reserved
01h Minimum power consumption with Standby mode
02h..7Fh Intermediate power management levels with Standby mode
80h Minimum power consumption without Standby mode
81h..FDh Intermediate power management levels without Standby mode
FEh Maximum performance
FFh Reserved
(From the ATA spec)
Here is my experience with a Crucial MX300 SSD booted on battery power:
root@ubuntu:~# hdparm -B /dev/sda
/dev/sda:
APM_level = 128
root@ubuntu:~# hdparm -t /dev/sda
/dev/sda:
Timing buffered disk reads: 94 MB in 3.02 seconds = 31.11 MB/sec
root@ubuntu:~# hdparm -B254 /dev/sda
/dev/sda:
setting Advanced Power Management level to 0xfe (254)
APM_level = 254
root@ubuntu:~# hdparm -t /dev/sda
/dev/sda:
Timing buffered disk reads: 1466 MB in 3.00 seconds = 488.44 MB/sec
Solution 2:
You may want to check /etc/hdparm.conf where you can configure the the apm level for power and battery mode.
Add
apm = 254
apm_battery = 254
to /etc/hdparm.conf
Solution 3:
I consistently found that I was able to hit the fast speeds when I booted the laptop while being plugged in. If I booted the laptop while it was running off the battery, and then plugged in, I was still stuck on the slow speeds.
This may have been something specific to my laptop (Lenovo T420). I changed all the BIOS settings to not save any power, to go for maximum performance; however, this did not let it have the fast speeds when only using the battery. I still had to be plugged in when I booted to have the fast speeds.
Another note: I can be plugged in when I boot, and then once booted, unplug the laptop. The laptop will keep the fast speeds until it boots up the next time.
ANSWER: Be plugged in when you boot.