很多时候,我们的文件系统中并不保存重要数据。比如 /var/tmp
, /usr/src
或 /usr/portage
,对于这些目录,我们可以专门创建一个文件系统,并以牺牲数据安全性(因为我们不需要)换取最高性能。
如果你的 ext4 分区中储存的是 /usr/portage
这样大量小文件构成的数据库,可以使用以下参数格式化:
mkfs.ext4 -b 2048 -i 2048 -O "dir_index" /dev/sdX
-b 2048 -i 2048
确保分区中有足够的 inodes,避免因大量小文件导致明明有空间却没有 inode 的困境发生;”dir_index” 会让内核以类似 ReiserFS 的 btree 储存文件,对于大量小文件有很大的性能提升。但其它类型的数据分区,比如 /usr/src
或 /var/tmp
请勿使用此方法格式化,请使用默认参数。
使用不安全的写入方式提升性能:
tune2fs -o journal_data_writeback /dev/sdX
禁用日志:
tune2fs -O ^has_journal /dev/sdX
使用以下挂载参数(写在 /etc/fstab
):
defaults,noatime,nodiratime,barrier=0,nosuid,nodev,data=writeback
noatime
和 nodiratime
彻底禁用一切访问时间记录;barrier=0
禁用为安全保护而设计的写入屏障;nosuid
和 nodev
提升安全性;data=writeback
使用不安全而最高效的写入方式。
效果拔群!
2019年05月16日 — 12:41
11111
2016年05月20日 — 22:20
Thanks, James. My first musical staged in a theatre . . . Jesus Christ Superstar. Since then, I’ve watched the occasional theatrical production . . . CATS and La Cage Aux Foilles. I’m also fond of watching movie musicals ~ The Sound of Music, Mary Poppins, Rent, Chicago, etc. It’s good for the heart to hear those notes soar.
2016年05月19日 — 01:11
Hey KayWie geht´s so?Hab noch dein Geburtstags Geschenk zuhause stehen kriegst du dann zu Sylvester:Dich hab bei YouTube nen kleinen Kannal gestartet kannst ja mal reinschaun (Rcebtschreihung for the Win ;d)Viele liebe Grüße,und wir könnten ja mal wieder Skypen, von Lukas deinem Hobbit FreundxD
2014年10月08日 — 08:48
不少发行版默认都用tmpfs
2014年10月13日 — 17:21
我所说的这几个场景产生的临时文件都是巨大的,不能用 tmpfs.