比尔盖子 博客

高性能 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 使用不安全而最高效的写入方式。

效果拔群!

Categories: IT生活, Linux

OpenRC 无法正确配置 IPv6 » « 服务器 SSH 端口再次变更

5 Comments

  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

发表评论

Your email address will not be published.

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax

Copyright © 2023 比尔盖子 博客

Theme by Anders NorenUp ↑