高性能 ext4 临时文件系统

很多时候,我们的文件系统中并不保存重要数据。比如 /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

noatimenodiratime 彻底禁用一切访问时间记录;barrier=0 禁用为安全保护而设计的写入屏障;nosuidnodev 提升安全性;data=writeback 使用不安全而最高效的写入方式。

效果拔群!

分类目录: IT生活, Linux

5 评论

  1. 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.

  2. 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

  3. 不少发行版默认都用tmpfs

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

版权所有 © 2025 比尔盖子 博客

主题设计 Anders Noren返回顶部 ↑