怎么查看固态硬盘开启discard

系统安装、升级讨论
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
回复
沐风栉雨
帖子: 4
注册时间: 2016-04-22 20:43
系统: windows10

怎么查看固态硬盘开启discard

#1

帖子 沐风栉雨 » 2016-04-22 20:45

还有怎么在/etc/fstab里写东西啊,初来乍到,还望多多指教 :em06
poloshiao
论坛版主
帖子: 18279
注册时间: 2009-08-04 16:33

Re: 怎么查看固态硬盘开启discard

#2

帖子 poloshiao » 2016-04-22 21:15

參閱
http://askubuntu.com/questions/443761/h ... im-enabled
Conclusion from that link in German:
cron job on weekly basis since discard will lead to too much of a performance hit.
rosynirvana
帖子: 893
注册时间: 2011-02-14 17:46

Re: 怎么查看固态硬盘开启discard

#3

帖子 rosynirvana » 2016-04-22 21:53

例如
UUID=uuid / ext4 noatime,nodiratime,errors=remount-ro 0 1

把,discard加在红字的后面就行

但是一般不建议discard,建议的是手动定时fstrim

另外现在16.04在/etc/cron.weekly/fstrim中,已经对所有SSD都定时跑trim了,所以不用加discard
头像
kashu
帖子: 451
注册时间: 2014-02-07 17:31
系统: Xubuntu 14.04.5 64位

Re: 怎么查看固态硬盘开启discard

#4

帖子 kashu » 2016-04-22 22:13

不要用discard。

Why Doesn’t Ubuntu TRIM By Default?
http://www.howtogeek.com/176978/ubuntu- ... t-yourself


cat /etc/cron.weekly/fstrim(来自:Xubuntu 14.04.4 LTS)
# This only runs on Intel and Samsung SSDs by default, as some SSDs with faulty
# firmware may encounter data loss problems when running fstrim under high I/O

# load (e. g. https://launchpad.net/bugs/1259829). You can append the
# --no-model-check option here to disable the vendor check and run fstrim on
# all SSD drives.



要先确定所用的SSD在当前的Xubuntu系统上是否支持TRIM,然后再决定是否要设置定期fstrim,默认每周的fstrim-all只处理Intel和三星厂商的固态硬盘。

代码: 全选

# SSD TRIM (More: http://www.howtogeek.com/176978/ubuntu-doesnt-trim-ssds-by-default-why-not-and-how-to-enable-it-yourself)
for DISK in $(fdisk -l 2> /dev/null | grep -i "^Disk /" | awk -F'[ |:]' '{print $2}'); do
  hdparm -I ${DISK} | grep -sqim1 "TRIM supported" && { trim_enable=1; break; }
done

if [ "${trim_enable}" -eq 1 ]; then
  if `grep -m1 "^exec fstrim-all" /etc/cron.weekly/fstrim | grep -sqv "no-model-check"`; then
    sed -i 's/^exec/#exec/g' /etc/cron.weekly/fstrim
    echo 'exec fstrim-all --no-model-check' >> /etc/cron.weekly/fstrim
  fi
fi
上面的脚本代码不适用于所有的人,如:电脑里装有不同厂商的多块SSD,其中有的SSD支持TRIM,有的却不支持,那请不要使用这脚本。只使用同一厂商的,这脚本应该可以。(另:不太清楚16.04在SSD的TRIM上有没有变化,我现在还没用过16.04 :em06
[/size]


OS: Xubuntu 14.04.5 LTS 64-bit
CPU: Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz
RAM: 12GB DDR3 1333MHz
128GB SSD + 2TB HDD
神舟优雅A480B-I5B 购于 2012.08

YouTube频道:https://www.youtube.com/channel/UCGSPXZ ... DuDYX8L6Qg
沐风栉雨
帖子: 4
注册时间: 2016-04-22 20:43
系统: windows10

Re: 怎么查看固态硬盘开启discard

#5

帖子 沐风栉雨 » 2016-04-22 23:09

rosynirvana 写了:例如
UUID=uuid / ext4 noatime,nodiratime,errors=remount-ro 0 1

把,discard加在红字的后面就行

但是一般不建议discard,建议的是手动定时fstrim

另外现在16.04在/etc/cron.weekly/fstrim中,已经对所有SSD都定时跑trim了,所以不用加discard

这个是自动的吗? :Haha
沐风栉雨
帖子: 4
注册时间: 2016-04-22 20:43
系统: windows10

Re: 怎么查看固态硬盘开启discard

#6

帖子 沐风栉雨 » 2016-04-22 23:10

poloshiao 写了:參閱
http://askubuntu.com/questions/443761/h ... im-enabled
Conclusion from that link in German:
cron job on weekly basis since discard will lead to too much of a performance hit.
:em01
沐风栉雨
帖子: 4
注册时间: 2016-04-22 20:43
系统: windows10

Re: 怎么查看固态硬盘开启discard

#7

帖子 沐风栉雨 » 2016-04-22 23:11

kashu 写了:不要用discard。

Why Doesn’t Ubuntu TRIM By Default?
http://www.howtogeek.com/176978/ubuntu- ... t-yourself


cat /etc/cron.weekly/fstrim(来自:Xubuntu 14.04.4 LTS)
# This only runs on Intel and Samsung SSDs by default, as some SSDs with faulty
# firmware may encounter data loss problems when running fstrim under high I/O

# load (e. g. https://launchpad.net/bugs/1259829). You can append the
# --no-model-check option here to disable the vendor check and run fstrim on
# all SSD drives.



要先确定所用的SSD在当前的Xubuntu系统上是否支持TRIM,然后再决定是否要设置定期fstrim,默认每周的fstrim-all只处理Intel和三星厂商的固态硬盘。

代码: 全选

# SSD TRIM (More: http://www.howtogeek.com/176978/ubuntu-doesnt-trim-ssds-by-default-why-not-and-how-to-enable-it-yourself)
for DISK in $(fdisk -l 2> /dev/null | grep -i "^Disk /" | awk -F'[ |:]' '{print $2}'); do
  hdparm -I ${DISK} | grep -sqim1 "TRIM supported" && { trim_enable=1; break; }
done

if [ "${trim_enable}" -eq 1 ]; then
  if `grep -m1 "^exec fstrim-all" /etc/cron.weekly/fstrim | grep -sqv "no-model-check"`; then
    sed -i 's/^exec/#exec/g' /etc/cron.weekly/fstrim
    echo 'exec fstrim-all --no-model-check' >> /etc/cron.weekly/fstrim
  fi
fi
上面的脚本代码不适用于所有的人,如:电脑里装有不同厂商的多块SSD,其中有的SSD支持TRIM,有的却不支持,那请不要使用这脚本。只使用同一厂商的,这脚本应该可以。(另:不太清楚16.04在SSD的TRIM上有没有变化,我现在还没用过16.04 :em06
[/size]
用的镁光M4,这个支持trim :em06
rosynirvana
帖子: 893
注册时间: 2011-02-14 17:46

Re: 怎么查看固态硬盘开启discard

#8

帖子 rosynirvana » 2016-04-22 23:29

沐风栉雨 写了:
rosynirvana 写了:例如
UUID=uuid / ext4 noatime,nodiratime,errors=remount-ro 0 1

把,discard加在红字的后面就行

但是一般不建议discard,建议的是手动定时fstrim

另外现在16.04在/etc/cron.weekly/fstrim中,已经对所有SSD都定时跑trim了,所以不用加discard

这个是自动的吗? :Haha
是,每周自动跑一次
头像
kashu
帖子: 451
注册时间: 2014-02-07 17:31
系统: Xubuntu 14.04.5 64位

Re: 怎么查看固态硬盘开启discard

#9

帖子 kashu » 2016-04-22 23:49

rosynirvana 写了: 是,每周自动跑一次

我想问一下,在16.04里,那个每周计划任务里,现在fstrim-all是支持对所有厂商的固态硬盘的TRIM吗?
还是像14.04一样,“only runs on Intel and Samsung SSDs by default”?


OS: Xubuntu 14.04.5 LTS 64-bit
CPU: Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz
RAM: 12GB DDR3 1333MHz
128GB SSD + 2TB HDD
神舟优雅A480B-I5B 购于 2012.08

YouTube频道:https://www.youtube.com/channel/UCGSPXZ ... DuDYX8L6Qg
rosynirvana
帖子: 893
注册时间: 2011-02-14 17:46

Re: 怎么查看固态硬盘开启discard

#10

帖子 rosynirvana » 2016-04-22 23:56

kashu 写了:
rosynirvana 写了: 是,每周自动跑一次

我想问一下,在16.04里,那个每周计划任务里,现在fstrim-all是支持对所有厂商的固态硬盘的TRIM吗?
还是像14.04一样,“only runs on Intel and Samsung SSDs by default”?
如果fstrim --all是对于部分厂商的SSD做trim,那14.04的脚本就没必要写厂商检测的函数了
头像
kashu
帖子: 451
注册时间: 2014-02-07 17:31
系统: Xubuntu 14.04.5 64位

Re: 怎么查看固态硬盘开启discard

#11

帖子 kashu » 2016-04-23 0:25

哦,我忘了,看一下man就好了

代码: 全选

kashu:~$ man fstrim-all
kashu:~$ man fstrim
[/size]


OS: Xubuntu 14.04.5 LTS 64-bit
CPU: Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz
RAM: 12GB DDR3 1333MHz
128GB SSD + 2TB HDD
神舟优雅A480B-I5B 购于 2012.08

YouTube频道:https://www.youtube.com/channel/UCGSPXZ ... DuDYX8L6Qg
汇购生活在线
帖子: 5
注册时间: 2016-04-20 3:21
系统: windows7

Re: 怎么查看固态硬盘开启discard

#12

帖子 汇购生活在线 » 2016-04-23 3:21

写的东西真的看不懂
回复