在使用服务器编译代码的时候,因为最近有一个组raid的过程,所以使用的空间是格式化过的。空间虽然大了,但是编译速度却下降很多,十分苦恼。
/dev/sdc1 7.3T 328G 6.6T 5% /root/public-workspace
主要原因是格式化时是直接使用mkfs.ext4命令格式,所以它默认带数据日志的。
ext4 支持多个模式
Data ordering is not preserved, data may be written into the main file system after its metadata has been committed to the journal.
数据和日志写入主文件,但是无顺序的 2. Ordered 模式
All data are forced directly out to the main file system prior to its metadata being committed to the journal.
数据在写日志之前进入主文件
All data are committed into the journal prior to being written into the main file system. Enabling this mode will disable delayed allocation and O_DIRECT support.
所有数据到主文件都是在日志之后
Don't load the journal on mounting. Note that if the filesystem was not unmounted cleanly, skipping the journal replay will lead to the filesystem containing inconsistencies that can lead to any number of problems. 挂载时不加载日志,但是如果文件系统卸载不干净的时候将会导致文件系统的各类问题。
Ext4 can be told to sync all its data and metadata every 'nrsec' seconds. The default value is 5 seconds. This means that if you lose your power, you will lose as much as the latest 5 seconds of work (your filesystem will not be damaged though, thanks to the journaling). This default value (or any low value) will hurt performance, but it's good for data-safety. Setting it to 0 will have the same effect as leaving it at the default (5 seconds). Setting it to very large values will improve performance. 设置commit的时间,默认5s,如果设置提交时间太短,则影响性能,设置时间过长可提高性能,但是异常断电的时候会丢最近nrsec的内容
根据上面的介绍,我可以有两个方式
对于1,我选择60秒同步一次日志,如下设置(/etc/fstab)
LABEL=public-workspace /root/public-workspace ext4 nofail,auto,noatime,data=ordered,commit=60 0 0
对于2,我选择关闭日志,如下设置
LABEL=public-workspace /root/public-workspace ext4 nofail,auto,noatime,noload,norecovery 0 0
最后我选择2,选择权在自己手上,风险自己能把握住就行。
https://www.kernel.org/doc/Documentation/filesystems/ext4.txt