created_date: 2020-01-02T11:29:24+08:00

update_date: 2020-01-16T02:03:17+08:00


1. 关闭错误报告

可以选择直接卸载apport这个软件包, 但最好还是改配置

# 看说明
sudo vi /etc/default/apport







# -*- coding: utf-8 -*-

filecount = 30000
filesize = 1024

import random, time
from os import system
flush = "sudo su -c 'sync ; echo 3 > /proc/sys/vm/drop_caches'"

randfile = open("/dev/urandom", "r")

print "\ncreate test folder:"
starttime = time.time()
system("rm -rf test && mkdir test")
print time.time() - starttime

print "\ncreate files:"
starttime = time.time()
for i in xrange(filecount):
    rand = * 0.5 + filesize * random.random()))
    outfile = open("test/" + unicode(i), "w")
print time.time() - starttime

print "\nrewrite files:"
starttime = time.time()
for i in xrange(int(filecount / 10)):
    rand = * 0.5 + filesize * random.random()))
    outfile = open("test/" + unicode(int(random.random() * filecount)), "w")
print time.time() - starttime

print "\nread linear:"
starttime = time.time()
for i in xrange(int(filecount / 10)):
    infile = open("test/" + unicode(i), "r")
print time.time() - starttime

print "\nread random:"
starttime = time.time()
outfile = open("/dev/null", "w")
for i in xrange(int(filecount / 10)):
    infile = open("test/" + unicode(int(random.random() * filecount)), "r")
print time.time() - starttime

print "\ndelete all files:"
starttime = time.time()
system("rm -rf test")
print time.time() - starttime


# sudo gdisk -l /dev/sda
Disk /dev/sda: 124822487 sectors, 59.5 GiB
Model: ROS2GO          
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): B3D0C73A-433D-44C1-8F80-FA90167AAADC
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 124822453
Partitions will be aligned on 2048-sector boundaries
Total free space is 1942420 sectors (948.4 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048        20482047   9.8 GiB     8300  ext4
   2        20482048        40962047   9.8 GiB     8300  btrfs
   3        40962048        61442047   9.8 GiB     8300  f2fs
   4        61442048        81922047   9.8 GiB     8300  xfs
   5        81922048       102402047   9.8 GiB     8300  reiserfs


f2fs (rw,nosuid,nodev,relatime,lazytime,background_gc=on,discard,no_heap,user_xattr,inline_xattr,acl,inline_data,inline_dentry,flush_merge,extent_cache,mode=adaptive,active_logs=6,alloc_mode=reuse,fsync_mode=posix,uhelper=udisks2)
btrfs (rw,nosuid,nodev,relatime,space_cache,subvolid=5,subvol=/,uhelper=udisks2)
ext4 (rw,nosuid,nodev,relatime,uhelper=udisks2)
xfs (rw,nosuid,nodev,relatime,attr2,inode64,logbufs=8,logbsize=32k,noquota,uhelper=udisks2)
reiserfs (rw,nosuid,nodev,relatime,uhelper=udisks2)




Linux xiaoxinpro 5.3.0-24-generic #26-Ubuntu SMP Thu Nov 14 01:33:18 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux


create files rewrite files read linear read random delete all files
ext4 0.593394041 3.646025896 0.960836887 2.286855936 0.646140814
btrfs 5.707916975 2.0158391 0.446825027 2.039553881 2.933115005
f2fs 0.737277031 2.216201067 0.841583014 2.216186047 17.70262408
xfs 0.781413078 5.908052206 1.212768078 3.198234081 4.744434118
reiserfs 1.735713959 1.866363049 0.23438096 1.559979916 2.575639963



3. TLP - Linux电源优化利器



4. 要不要swap分区


Archlinux Wiki的文档真是优秀


Swap file creation

For copy-on-write file systems like Btrfs, first create a zero length file, set the No_COW attribute on it with chattr, and make sure compression is disabled:

# truncate -s 0 /swapfile
# chattr +C /swapfile
# btrfs property set /swapfile compression none

See Btrfs#Swap file for more information.

Use fallocate to create a swap file the size of your choosing (M = Mebibytes, G = Gibibytes). For example, creating a 512 MiB swap file:

# fallocate -l 512M /swapfile

Note: fallocate may cause problems with some file systems such as F2FS.[1] As an alternative, using dd is more reliable, but slower:

# dd if=/dev/zero of=/swapfile bs=1M count=512 status=progress

Set the right permissions (a world-readable swap file is a huge local vulnerability):

# chmod 600 /swapfile

After creating the correctly sized file, format it to swap:

# mkswap /swapfile

Activate the swap file:

# swapon /swapfile

Finally, edit the fstab configuration to add an entry for the swap file:

/swapfile none swap defaults 0 0

For additional information, see fstab#Usage.

Note: The swap file must be specified by its location on the file system not by its UUID or LABEL.

Remove swap file

To remove a swap file, it must be turned off first and then can be removed:

# swapoff /swapfile
# rm -f /swapfile



Swap operations are usually significantly slower than directly accessing data in RAM. Disabling swap entirely to improve performance can sometimes lead to a degradation, since it decreases the memory available for VFS caches, causing more frequent and costly disk I/O.

Swap values can be adjusted to help performance:


The swappiness sysctl parameter represents the kernel’s preference (or avoidance) of swap space. Swappiness can have a value between 0 and 100, the default value is 60. A low value causes the kernel to avoid swapping, a higher value causes the kernel to try to use swap space. Using a low value on sufficient memory is known to improve responsiveness on many systems.

To check the current swappiness value:

$ sysctl vm.swappiness

Alternatively, the files /sys/fs/cgroup/memory/memory.swappiness or /proc/sys/vm/swappiness can be read in order to obtain the raw integer value.

Note: As /proc is a lot less organized and is kept only for compatibility purposes, you are encouraged to use /sys instead.

To temporarily set the swappiness value:

# sysctl -w vm.swappiness=10

To set the swappiness value permanently, create a sysctl.d(5) configuration file. For example:


To test and more on why this may work, take a look at this article.

5. 常用软件

  • Google Chrome/Chromium

支持的一些启动参数如下所示,我一般用的是--disk-cache-dir=/tmp/chrome_cache --process-per-site,即缓存扔到/tmp分区,每个站点使用一个进程

对于Chromium,可以在/etc/chromium-browser/default添加自己想要的配置参数,而对于Google Chrome,貌似只能从这里/usr/share/applications/chromium-browser.desktop

--user-data-dir="[PATH]"  自定义用户数据目录
--start-maximized                启动就最大化
--no-sandbox                         取消沙盒模式
--single-process                    单进程运行
--process-per-tab                 每个标签使用单独进程
--process-per-site                每个站点使用单独进程
--in-process-plugins            插件不启用单独进程
--disable-popup-blocking 禁用弹出拦截
--disable-javascript             禁用JavaScript
--disable-java                         禁用Java
--disable-plugins                   禁用插件
--disable-images                   禁用图像
-incognito                               启动进入隐身模式
--enable-udd-profiles        启用账户切换菜单
--proxy-pac-url                   使用pac代理 [via 1/2]
--lang=zh-CN                        设置语言为简体中文
--disk-cache-dir="[PATH]" 自定义缓存目录
--disk-cache-size=              自定义缓存最大值(单位byte)
--media-cache-size=         自定义多媒体缓存最大值(单位byte)
--bookmark-menu              在工具栏增加一个书签按钮
--enable-sync                       启用书签同步
  • Foxit Reader