Gentoo Linux on T43 (14) 内存虚拟盘加速系统

对于一个喜欢折腾系统的人来说,为笔记本电脑建立内存虚拟盘,来弥补笔记本小硬盘天然的性能瓶颈问题,总是免不了的。 内核选项  Linux 内核内建了ramdisk支持,正常情况下,内核中下列选项应该是enable 的。 $ zcat /proc/config.gz |grep -i tmpfs CONFIG_TMPFS=y CONFIG_TMPFS_POSIX_ACL=y 这就表明,可以直接利用mount 命令创建一个内存虚拟盘。...

对于一个喜欢折腾系统的人来说,为笔记本电脑建立内存虚拟盘,来弥补笔记本小硬盘天然的性能瓶颈问题,总是免不了的。

内核选项 

Linux 内核内建了ramdisk支持,正常情况下,内核中下列选项应该是enable 的。

$ zcat /proc/config.gz |grep -i tmpfs
CONFIG_TMPFS=y
CONFIG_TMPFS_POSIX_ACL=y

这就表明,可以直接利用mount 命令创建一个内存虚拟盘。

创建内存盘

我打算把内存虚拟盘放在/mnt/ram 。使用以下简单的命令:

# mkdir /mnt/ram 
# mount -t tmpfs -o 128m none /mnt/ram

也可以不指定内存盘大小:

# mount -t tmpfs none /mnt/ram 

在内存盘建立之后,查看top 或者系统监视器,可用内存并未相应减少(明确指定大小的内存盘也是如此)。经过测试,未明确指定大小的内存盘会动态分配内存,可以持续向内存盘中写入文件,当再无可用物理内存时才会报空间不足的错误。 tmpfs 文件系统默认采用1G 的容量,但并未实际分配并占用这部分内存,而是动态分配。这要比Windows下流行的内存虚拟盘方案 方便得多。

启动时自动创建

接下来,将以下行加入/etc/fstab,让系统在每次启动时自动创建内存盘。

none            /mnt/ram    tmpfs       noatime 0 0 

利用内存盘 

最后,可以把一些常用软件的临时文件夹指定到/mnt/ram,如果应用程序不支持临时文件夹配置,也可以将其转换成到/mnt/ram 的符号链接。

Lotus Notes 8

notes 8会在$HOME目录自动建立workplace-tmp 目录来存储临时文件,我们可以将其转移到内存盘中。先关闭notes,然后执行以下命令:

$ mkdir /mnt/ram/workplace-tmp
$ echo ' mkdir /mnt/ram/workplace-tmp' >> ~/.bash_profile
$ mv ~/workplace-tmp ~/workplace-tmp.bak
$ ln -s /mnt/ram/workplace-tmp ~/workplace-tmp
$ ls -l ~/workplace-tmp
lrwxrwxrwx 1 alex users 22 2008-02-19 09:36 /home/alex/workplace-tmp -> /mnt/ram/workplace-tmp  

更新 2008-03-24

将/var/tmp 与/tmp 也加入到tmpfs

/etc/fstab

none			/tmp	    tmpfs		noatime	0 0
none			/var/tmp    tmpfs		noatime	0 0

设置Notes

修改~/.bash_profile

if [ ! -e /var/tmp/workplace-tmp ]; then
mkdir /var/tmp/workplace-tmp
fi

重启后,修改Notes临时文件夹符号连接

$ rm ~/workplace-tmp
$ ln -s /var/tmp/workplace-tmp ~/workplace-tmp

将/var/tmp/ 放入tmpfs 之后,在merge一些巨大的软件包时,中途可能因为临时空间不足而失败退出,这种情况下,可以指定PORTAGE_TMPDIR 到其它具有足够空间的路径来解决。比如:

# PORTAGE_TMPDIR=~/tmp emerge -av openoffice
$ sudo PORTAGE_TMPDIR=~/tmp emerge -av openoffice 

延展阅读

(未完)

running firefox on Ram disk

I had ever moved my IE temporary files folder into a Ram disk for reducing the...

I had ever moved my IE temporary files folder into a Ram disk for reducing the disk IO during surfing.

When I play with Firefox, I don't find any option for moving its temporary files folder like IE does. But finally I found it, not just moving the firefox's profiles, even for firefox.exe itself.

There're 3 level solutions you may choose.

  1. Enable built-in memory cache feature to speed firefox up.
  2. Move profile folder to Ram disk including temporary files folder.
  3. Run both firefox.exe and profile folder on Ram disk.

The 1th solution is most simple, the 3th solution is most complex but has the maximum of reducing disk IO.

The steps for the 1th solution refer to:

Before starting to do the next 2 solutions, you will have to create a Ram disk on your computer. I use this tool called RamDisk, download it at:

  • http://www.greendown.cn/Software.asp?id=530

The steps for the 2th solution refer to:

The steps for the 3th solution: 

  1. Copy the Firefox application folder and your profile folder to the Ram disk. In this example we will use R:\Firefox for the application folder and R:\FFProfile as the profile folder, assuming the drive letter for the Ram disk is R:.
  2. Create a simple batch file called R:\Firefox.bat with the following line:
    start R:\Firefox\firefox.exe -profile R:\FFProfiles
  3. Optionally, you may don't want to lose the bookmarks saved in Ram disk after reboot. Move bookmark file back to harddisk folder by entering about:config in the address field of firefox and set
    browser.bookmarks.file=C:\\Documents and Settings\\Alex\\Application Data\\Mozilla\\Firefox\\Profiles\\ve6luvh6.default\\bookmarks.html
  4. Make system copy firefox application and profile folder from hard disk to Ram disk automatically at each boot time by adding following lines to file C:\AUTOEXEC.BAT.
    rd /S /Q R:\Firefox
    rd /S /Q R:\FFProfiles
    del R:\Firefox.bat

    xcopy /E /H /K "%APPDATA%\Mozilla\Firefox\Profiles\ve6luvh6.default\*" R:\FFProfiles\*
    xcopy /E /H /K "C:\Program Files\Mozilla Firefox\*" R:\Firefox\*

    echo start R:\Firefox\firefox.exe -profile R:\FFProfiles>R:\Firefox.bat
    R:\Firefox.bat
  5. Optionally, disable firefox memory cache to reduce memory usage because the whole program and profiles are running in Ram by setting
    browser.cache.memory.enable=false
  6. Notes: With this solution, all settings made in Ram disk will be lost after system reboots. If you want the settings to be used after rebooting, should make the setting change by running firefox based on harddisk, and then re-copy all folder from hard disk to Ram disk by running AUTOEXEC.BAT.
  7. Refer to:
    Run Firefox from removable media
    http://www.mozilla.org/support/firefox/tips#oth_usb

Refer to

Tested on

  • OS: Windows xp professional
  • Firefox: version 1.5

继续阅读 "running firefox on Ram disk" 的剩余内容

mail.png


标签订阅|Tag Subscription

If you use an RSS reader, you can subscribe to a feed of all future entries tagged 'ramdisk'. [What is this?]

Subscribe to feed Subscribe to feed

最近更新|Recent Entries

不定期更新|Handy Entries

其它标签|Other Tags

分类栏目|Categories

按月归档|By Month

2008
11
10
07
05
04
03
02
01
2007
12
10
07
06
05
04
03
02
01
2006
12
11
10
09
08
07
06
05
04
03
02
01
2005
11
10
09
08
07
04
03
2004
12
11
10
09
08
07
06
05
04
03
02
01
2003
12
10
09
08
06
2002
09
08
04
03
02
2001
12
09
07
06
05

站内链接|Site Links

Powered by
Movable Type 3.34