Category: /knowledge /linux
Tags: linux


in /etc/fstab

# <file system> <mount point>   <type>  <options>       <dump>  <pass> 
proc /proc proc nodev,noexec,nosuid 0 0 
tmpfs /tmp tmpfs defaults,noatime,nodiratime,mode=1777 0 0 
none /var/log aufs br:/tmp=rw:/var/log=ro 0 0 

# / was on /dev/sda1 during installation 
UUID=50143bce-e400-418b-a8d4-c8e596820fb3 / ext4 noatime,nodiratime,data=writeback,barrier=0,nobh,commit=25,errors=remount-ro 0 1

in /etc/default/grub,

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash elevator=deadline rootflags=data=writeback"

to write that to disk, changed the ext4 file system to use the data=writeback journal mode:

tune2fs -o journal_data_writeback /dev/sda1


echo 1 > /sys/block/sda/queue/iosched/fifo_batch
for dir in apparmor apt news cups dist-upgrade fsck gdm installer samba unattended-upgrades
    if [ ! -e /var/log/$dir ]
            mkdir /var/log/$dir
if [ -d '/sys/module/hid_apple' ] ; then
 echo 2 > /sys/module/hid_apple/parameters/fnmode
elif [ -d '/sys/module/hid/parameters' ] ; then
 echo 2 > /sys/module/hid/parameters/pb_fnmode


vm.dirty_ratio = 40
vm.dirty_background_ratio = 1
vm.dirty_writeback_centisecs = 24000
vm.swappiness = 1

To use tmpfs for /var/lock and /var/run, you can simply symlink them to /run. Make sure to close anything important before doing this, because you will have to reboot, and daemons may not stop cleanly.

 ln -sf /run/lock /var/lock 
 ln -sf /run /var/run 


Firefox ———-

* Open Firefox.
* Type about:config in the search bar.
* Right click on any row.
* Select New > String from the popup menu.
* Add browser.cache.disk.parent_directory and set it to /tmp
* set Edit/Preferences/Downloads directory to /tmp
* Restart Firefox.

Use about:cache to verify.

Google Chrome

Chrome 在Linux下cache的位置是~/.cache/google-chrome/Cache. 只要把这个目录链接到内存里就可以了.

cd ~/.cache/google-chrome/Default
rm -rf Cache
ln -s /tmp Cache
rm -rf Media\ Cache
ln -s /tmp Media\ Cache

Or make the entire cache folder to /tmp

rm -rf .cache
ln -s /tmp .cache

NX client

edit rc.local


do sth about .viminfo

ln -sf /tmp/.viminfo .

User data

sudo chown root:root .Xauthority .xine .xsession-errors 
sudo chattr +i .xsession-errors

ln -sf /tmp/bash_history .bash_history

or disable .bash_history, in ~/.bashrc


Compare with HDD

AMD dual core, 2.0 GHz, My regular 7200rpm HDD:

sudo hdparm -tT /dev/sda5
 Timing cached reads:   1184 MB in  2.00 seconds = 591.93 MB/sec
 Timing buffered disk reads:  218 MB in  3.02 seconds =  72.27 MB/sec

C2D 2.66 GHz, OCZ Vertex 30GB SSD:

sudo hdparm -tT /dev/sda

 Timing cached reads:   12380 MB in  1.99 seconds = 6213.86 MB/sec
 Timing buffered disk reads:  552 MB in  3.00 seconds = 183.77 MB/sec

虽然没达到传说中的220MB/sec, 结果还是相当满意的.

Kingston V 64GB SSD

sudo hdparm -tT /dev/sda2
  Timing cached reads:   13242 MB in  1.99 seconds = 6646.65 MB/sec
  Timing buffered disk reads: 748 MB in  3.01 seconds = 248.91 MB/sec

Test writing speed

dd if=/dev/zero of=/tmp/output.img bs=8k count=128k



  • 如果看不到讨论部分, 请暂时关掉adblock in Firefox/Chrome
  • 本网站使用Javascript实现评论功能, 此处外链对提高您的网站PR没有帮助. (潜台词: 请不要灌水, 谢谢)