Ubuntu SSD-速度很快,现在非常慢


12

这就是我现在得到的,配备Crucial MX300 750GB SSD(具有最新固件[尚无固件更新])。

lptp [ blah ]: sudo hdparm -Tt /dev/sda

/dev/sda:
 Timing cached reads:   10202 MB in  2.00 seconds = 5103.20 MB/sec
 Timing buffered disk reads: 128 MB in  3.06 seconds =  41.88 MB/sec

看到缓冲的磁盘读取速度!!!!SOOOO SLOWWW !!!! 首次安装笔记本电脑时,我看到的速度超过了400MB / sec,考虑到这是一台较旧的笔记本电脑,并且加密的一切都很好,因此这对我来说非常好。

这是我的/etc/fstab。我已启用修剪,手动运行修剪,启用/禁用功能,重新启动等等。我无法让那些快的速度回来:

/dev/mapper/ubuntu--gnome--vg-root /               ext4    noatime,nodiratime,errors=remount-ro,barrier=0,discard 0       1

显然,这些是我正在使用的选项。我尝试了它们的各种组合都无济于事:

noatime,nodiratime,errors=remount-ro,barrier=0,discard

有小费吗?这真让我抓狂。

哦,我还在带16GB内存和i7处理器的Lenovo T420上运行Ubuntu 16.04(x64):

 lptp [ blah ]: lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.1 LTS
Release:    16.04
Codename:   xenial

Smartctl输出:

 lptp [ blah ]: sudo smartctl /dev/sda -a
smartctl 6.5 2016-01-24 r4214 [x86_64-linux-4.4.0-38-generic] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Device Model:     Crucial_CT750MX300SSD1
Serial Number:    XXXXXX
LU WWN Device Id: 5 XXXXX XXXXXXX
Firmware Version: M0CR011
User Capacity:    750,156,374,016 bytes [750 GB]
Sector Size:      512 bytes logical/physical
Rotation Rate:    Solid State Device
Form Factor:      2.5 inches
Device is:        Not in smartctl database [for details use: -P showall]
ATA Version is:   ACS-3 T13/2161-D revision 5
SATA Version is:  SATA 3.2, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is:    Tue Nov  1 21:22:05 2016 CDT
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

General SMART Values:
Offline data collection status:  (0x00) Offline data collection activity
                    was never started.
                    Auto Offline Data Collection: Disabled.
Self-test execution status:      (   0) The previous self-test routine completed
                    without error or no self-test has ever 
                    been run.
Total time to complete Offline 
data collection:        ( 1987) seconds.
Offline data collection
capabilities:            (0x7b) SMART execute Offline immediate.
                    Auto Offline data collection on/off support.
                    Suspend Offline collection upon new
                    command.
                    Offline surface scan supported.
                    Self-test supported.
                    Conveyance Self-test supported.
                    Selective Self-test supported.
SMART capabilities:            (0x0003) Saves SMART data before entering
                    power-saving mode.
                    Supports SMART auto save timer.
Error logging capability:        (0x01) Error logging supported.
                    General Purpose Logging supported.
Short self-test routine 
recommended polling time:    (   2) minutes.
Extended self-test routine
recommended polling time:    (  10) minutes.
Conveyance self-test routine
recommended polling time:    (   3) minutes.
SCT capabilities:          (0x0035) SCT Status supported.
                    SCT Feature Control supported.
                    SCT Data Table supported.

SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate     0x002f   100   100   000    Pre-fail  Always       -       0
  5 Reallocated_Sector_Ct   0x0032   100   100   010    Old_age   Always       -       0
  9 Power_On_Hours          0x0032   100   100   000    Old_age   Always       -       52
 12 Power_Cycle_Count       0x0032   100   100   000    Old_age   Always       -       41
171 Unknown_Attribute       0x0032   100   100   000    Old_age   Always       -       0
172 Unknown_Attribute       0x0032   100   100   000    Old_age   Always       -       0
173 Unknown_Attribute       0x0032   100   100   000    Old_age   Always       -       1
174 Unknown_Attribute       0x0032   100   100   000    Old_age   Always       -       11
183 Runtime_Bad_Block       0x0032   100   100   000    Old_age   Always       -       0
184 End-to-End_Error        0x0032   100   100   000    Old_age   Always       -       0
187 Reported_Uncorrect      0x0032   100   100   000    Old_age   Always       -       0
194 Temperature_Celsius     0x0022   059   052   000    Old_age   Always       -       41 (Min/Max 21/48)
196 Reallocated_Event_Count 0x0032   100   100   000    Old_age   Always       -       0
197 Current_Pending_Sector  0x0032   100   100   000    Old_age   Always       -       0
198 Offline_Uncorrectable   0x0030   100   100   000    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x0032   100   100   000    Old_age   Always       -       0
202 Unknown_SSD_Attribute   0x0030   100   100   001    Old_age   Offline      -       0
206 Unknown_SSD_Attribute   0x000e   100   100   000    Old_age   Always       -       0
246 Unknown_Attribute       0x0032   100   100   000    Old_age   Always       -       138859820
247 Unknown_Attribute       0x0032   100   100   000    Old_age   Always       -       4354463
248 Unknown_Attribute       0x0032   100   100   000    Old_age   Always       -       1675456
180 Unused_Rsvd_Blk_Cnt_Tot 0x0033   000   000   000    Pre-fail  Always       -       3558
210 Unknown_Attribute       0x0032   100   100   000    Old_age   Always       -       0

SMART Error Log Version: 1
No Errors Logged

SMART Self-test log structure revision number 1
No self-tests have been logged.  [To run self-tests, use: smartctl -t]

SMART Selective self-test log data structure revision number 1
 SPAN  MIN_LBA  MAX_LBA  CURRENT_TEST_STATUS
    1        0        0  Not_testing
    2        0        0  Not_testing
    3        0        0  Not_testing
    4        0        0  Not_testing
    5        0        0  Not_testing
Selective self-test flags (0x0):
  After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.

杀死我的是它正在运转一会儿。它一天有效,然后第二天停止,我什至没有做任何可以改变它的事情(我能想到)。

更新

测试了特定的设备(/dev/sda1),但结果缓慢:

lptp [ ~ ]: sudo hdparm -Tt /dev/sda1

/dev/sda1:
 Timing cached reads:   13130 MB in  2.00 seconds = 6568.77 MB/sec
 Timing buffered disk reads: 128 MB in  3.06 seconds =  41.79 MB/sec

更新

在逻辑分区上也进行了测试:

 lptp [ ~ ]: sudo hdparm -Tt /dev/mapper/ubuntu--gnome--vg-root 

/dev/mapper/ubuntu--gnome--vg-root:
 Timing cached reads:   11468 MB in  2.00 seconds = 5736.85 MB/sec
 Timing buffered disk reads: 178 MB in  3.04 seconds =  58.47 MB/sec

UPDATE dd测试

该测试表明它甚至比hdparm显示的还要慢...

 lptp [ blah ]:  dd if=/dev/zero of=tempfile bs=1M count=1024 conv=fdatasync,notrunc status=progress
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 35.0156 s, 30.7 MB/s
 lptp [ blah ]: sudo bash -c "echo 3 > /proc/sys/vm/drop_caches"
 lptp [ blah ]: dd if=tempfile of=/dev/null bs=1M count=1024 status=progress
1066401792 bytes (1.1 GB, 1017 MiB) copied, 34.0193 s, 31.3 MB/s
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 34.256 s, 31.3 MB/s

更新:分区对齐

这是笔记本电脑上的分区对齐方式:

lptp [ ~ ]: sudo parted
GNU Parted 3.2
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p                                                                
Model: ATA Crucial_CT750MX3 (scsi)
Disk /dev/sda: 750GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End    Size   Type      File system  Flags
 1      1049kB  512MB  511MB  primary   ext2         boot
 2      513MB   750GB  750GB  extended
 5      513MB   750GB  750GB  logical

(parted) align-check opt 1                                                       
1 aligned
(parted) align-check opt 2
2 not aligned
(parted) align-check opt 5
5 aligned
(parted)

我不确定对分区2未对齐的看法:^ /,但是分区1和5是对齐的。

另外,这是从 fdisk -l

Device     Boot   Start        End    Sectors   Size Id Type
/dev/sda1  *       2048     999423     997376   487M 83 Linux
/dev/sda2       1001470 1465147391 1464145922 698.2G  5 Extended
/dev/sda5       1001472 1465147391 1464145920 698.2G 83 Linux

更新:已修复? 我将调度程序更改为noop调度程序(而不是截止日期)。这似乎奏效了(通过更改/etc/default/grub为以下行来完成此操作:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash elevator=noop"

然后使用更新grub sudo update-grub2并重新启动。

我将等待几天,以查看它是否在重新启动/使用几次后是否有效,然后我做出回答并接受。

更改调度程序后的当前速度:

 lptp [ ~ ]: sudo hdparm -Tt /dev/sda

/dev/sda:
 Timing cached reads:   12388 MB in  2.00 seconds = 6197.19 MB/sec
 Timing buffered disk reads: 1454 MB in  3.00 seconds = 484.59 MB/sec

fstab中的选项是:

noatime,nodiratime,errors=remount-ro,barrier=0

在此处输入图片说明

“修复”更新

在使用了一段时间并重新启动几次之后,它又回到了缓慢的速度 :( :( :( :( :( :( :(

更新-可能的“修复”

我曾想过,也许我的笔记本电脑在启动并用完电池时会进行一些节电的优化。在插入充电器的情况下进行一次简单的启动测试后,它又恢复了其真正的快速速度。我可以肯定是这种情况-一直以快速的速度进行测试,一直插上充电器。我将再进行一些测试以进行验证,但我可以肯定这是造成速度下降的原因。


如果您测试特定分区的速度,例如/dev/sda1而不是,会发生/dev/sda什么?
thomasrutter

好问题-我将尝试并更新我的问题
d0c_s4vage 2016年

同样在逻辑分区上,例如/dev/mapper/ubuntu--gnome--vg-root
thomasrutter '16

已测试/dev/sda1,也将测试逻辑分区
d0c_s4vage

k,两者都测试过,没有运气:6 /
d0c_s4vage

Answers:


19

快速答案:

sudo hdparm -B254 /dev/sda

长答案:

看起来,一般情况下,使用电池启动时,Linux或便携式计算机(在Lenovo和Dell上均已验证)默认为APM级别80h(128),而使用交流电源时默认为FEh(254)。

对于大多数SSD,您不会发现太大的差异。Lite-on SSD似乎根本不支持电源管理,并且始终以最大速度运行。英特尔SSD在APM级别128时似乎以全速约75%的速度运行,在APM 254/255时以100%的速度运行。但是,与APM级别254(使用交流电源引导)相比,关键SSD在APM级别128(由电池引导)下似乎以6%的全速运行。

坏消息是这里没有错误,也没有错误。ATA规范含糊不清,因此允许以APM模式128超慢运行的Crucial SSD符合该规范。同样,默认设置为APM级别80h(128)的笔记本电脑也是完全合理的。规范只是说:

表106 — APM级别
COUNT字段级别
00h保留
01h待机模式下的最低功耗
02h..7Fh 待机模式下的中级电源管理级别
80h不待机模式下的
中级功耗管理81h..FDh 待机模式下的中级电源管理级别
FEh最高性能
FFh已预留

(从ATA规格

这是我使用电池供电的Crucial MX300 SSD的经验:

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

相同:(由于缺乏格式而致歉,缩进似乎无法在注释中起作用)$ sudo hdparm -t / dev / sdb2 / dev / sdb2:定时缓冲的磁盘读取:3.01秒中的76 MB = 25.23 MB / sec $ sudo hdparm -t / dev / sda3 $ sudo hdparm -B / dev / sdb / dev / sdb:APM_level = 128 $ sudo hdparm -B254 / dev / sdb / dev / sdb:将Advanced Power Management级别设置为0xfe(254)APM_level = 254 $ sudo hdparm -t / dev / sdb2 / dev / sdb2:定时缓冲磁盘读取:3.00秒内1448 MB = 482.28 MB / sec
KevinButler

哇。哇 这个答案非常有帮助。还有一件事:如果您使用GNOME,则其磁盘实用程序实际上允许在其GUI上设置APM级别。
Venemo

我认为这不是一个完整的答案,因为APM_level = not supported台式机上的Samsung SSD 840 EVO 120GB()上出现了同样的问题(即从未用电池供电)。读取速度下降一定有更普遍的原因。
cprn

很好的分析,尽管与WD ssd并没有太大区别,但是对理解此问题有很大帮助。谢谢
ajcg

6

您可能需要检查/etc/hdparm.conf,可以在其中为电源和电池模式配置apm级别。

apm = 254
apm_battery = 254

到/etc/hdparm.conf


3

我始终发现,在插入电源的情况下启动笔记本电脑时,我能够达到较快的速度。如果在没有电池的情况下启动笔记本电脑,然后再插入电源,我仍然会陷入低速状态。

这可能是笔记本电脑(Lenovo T420)特有的。我更改了所有BIOS设置,以不节省任何电量,以实现最佳性能。但是,这仅在使用电池时并不能使其具有较快的速度。开机时我仍然必须插上电源才能获得快速的速度。

另一个注意事项:我可以在启动时接通电源,然后在启动后拔出笔记本电脑的电源。笔记本电脑将保持高速运行,直到下次启动。

解答:引导时已插入电源。


0

请使用足够新的内核(v4.15 +),并为您的Crucial MX300尝试使用med_power_with_dipm。

LPM min_power不适用于所有驱动程序,如果med_power_with_dipm适合您,我们应该使用一个新的怪癖,使其在选择min_power时回退到med_power_with_dipm。

另外,请在Launchpad上提交错误,以便Ubuntu内核工程师可以解决该错误,或​​将问题提出给上游。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.