2012/09/01 

MBP加到16GB之後的第一件事, 加RamDisk筆記



MBP加到16GB之後的第一件事, 加RamDisk筆記

原本是要用Esperance DV來做RamDisk的,
但在我的MBA 2012 搭 OS X 10.8竟然顯示-2048MB(沒錯,就是負2048MB)
但其它App都要費用,所以自已加了script來做

步驟:
//1. Create 2GB RamDISK
//    2GB/512= 4000000    (至少512MB,如果太小請先確認你目前的Safari的cache size)
計算此值給diskutil建立Ramdisk之用,加在wakeup.sh中
diskutil erasevolume HFS+ "ramdisk" `hdiutil attach -nomount ram://4000000`

//2. Install the "sleep watcher" from macports 
port install sleepwatcher 

//2.1. Start/Stop the "sleep watcher" Service
port unload sleepwatcher
port load sleepwatcher

//2.2  Create the sleep and wakeup script
//sleep script
vi /etc/sleepwatcher/sleep.sh
#!/bin/sh

rsync -av --delete /Volumes/ramdisk/ /var/spool/rdimage/
diskutil unmount /dev/disk1
diskutil eject /dev/disk1

//wakeup script
vi /etc/sleepwatcher/wakeup.sh
#!/bin/bash

# Create a 2048MB ramdisk, mount on /Volumes/ramdisk
ramDisk=`diskutil list | awk '/ramdisk/{print $5}'`
if [ ! -e "/dev/$ramDisk" ];then
echo "Not exist"
diskutil erasevolume HFS+ "ramdisk" `hdiutil attach -nomount ram://4000000`
diskutil enableOwnership /Volumes/ramdisk
#restore ramdisk image from disk
rsync -a /var/spool/rdimage/ /Volumes/ramdisk/
fi

//2.3 Attched to "sleep watcher"  
echo "/etc/sleepwatcher/sleep.sh" >> /opt/local/etc/rc.sleep
echo "/etc/sleepwatcher/wake.sh" >> /opt/local/etc/rc.wake

//3. Change the Safari cache folder to RamDisk
//3.1 Find your Safari cache folder
//3.1.1 Cache Folder:1
    #find /var/folders/ -name com.apple.Safari
     ex:/var/folders//xx/xxxx/C/com.apple.Safari
//3.1.2 Cache Folder:2
    #~/Library/Caches/com.apple.Safari
//3.2 Close your Safari then to do flow command.

//4 Setup RamDisk path
//4.1 Move the Cache folder to RamDisk
   #mv /var/folders//xx/xxxx/C/com.apple.Safari /Volumes/ramdisk
   #mv ~/Library/Caches/com.apple.Safari /Volumes/ramdisk/user/
//4.2 Create the Link path form RamDISK to Safari
   #ln -s /Volumes/ramdisk/com.apple.Safari /var/folders//xx/xxxx/C/com.apple.Safari
   #ln -s /Volumes/ramdisk/user/com.apple.Safari ~/Library/Caches/

//5. Launch your Safari


以上,如果MAC遇到沒有的目錄,可用mkdir建立 
(MAC都一定要將參數加在前面嗎?,用慣Linux的我很不習慣說)
例:mkdir -p /etc/sleepwatcher
     mkdir -p /Volumes/ramdisk/ /var/spool/rdimage
     
註1.如果不想安裝macport的話,可以直接安裝sleepwatcher
在安裝完sleepwatcher後將以下command加到daemon
/opt/local/sbin/sleepwatcher --verbose --sleep /etc/sleepwatcher/sleep.sh --wakeup /etc/sleepwatcher/wakeup.sh 
再做上列的Step 2.2, 3.*,4.*及5就可以啦.

註2.OS X 10.4及之前的版本

hdid -nomount ram://4000000
newfs_hfs /dev/disk1
mkdir /tmp/ramdisk1
mount -t hfs /dev/disk1 /var/spool/rdimage


註3. Chrome的cache在此
~/Library/Caches/Google/Chrome 

Labels:

2009/03/08 

bandluxe c120 in ubuntu 8.10 (C100S也適用)

我的Bandluxe C120是搭配威寶的關係企業半價專案綁二年約送的
再配合買儲值卡一個月只NT$300/月
我同時還有一張C100S(自費網購而來)搭配的台灣大哥大3G相比較而言(NT$600/月,綁約一年)
實在省多多

速度方面 個人覺得在市區差異不大 ,不過到了鄉下或郊區時,台哥大通常會好一點。

在我的C120搭配Ubuntu 8.10(8.04測試ok)的設定方面如下,供大家參考
#lsusb
Vendor/Device ID: 1a8d:1002
PlugIn時option.ko並沒detected到

我使用的是wvdial 1.60(ubuntu 8.10內建) 及
官網(http://www.bandrich.com/download03.aspx?id=33&c=25&lang=3)給eeepc的部份設定及firmware,檔名EeePC patch.zip(請注意並沒有使用它的driver)
安裝方式如下:
解壓縮以後我們只需要 bandluxe-eeepc.tar.bz2

#tar jxvf bandluxe-eeepc.tar.bz2
#cd bandluxe-eeepc
文件上說明以下的rules是auto switch from CDROM to Modem
#cp -vf 10-bandluxe.rules /etc/udev/rules.d/10-bandluxe.rules
如果是C100S,請修改10-bandluxe.rules,新增一行
#vi /etc/udev/rules.d/10-bandluxe.rules
SYSFS{idVendor}=="1a8d", SYSFS{idProduct}=="1002", RUN="/usr/bin/eject /dev/%k"
#cp -vf bandluxe.fdi /usr/share/hal/fdi/preprobe/20thirdparty/bandluxe.fdi
需要重新插拔C120,如果udev有建立ttyUSB0,1就對了
#ls /dev/ttyUSB*
會看到ttyUSB0及ttyUSB1

另需設定/etc/wvdial.conf,個人從網路上隨便抄來的
vi /etc/wvdial.conf
[Dialer Defaults]
Phone = *99#
Username = username
Password = password
Stupid Mode =1
Dial Command = ATDT
modem = /dev/ttyUSB0
modem Type = Analog Modem
Baud = 460800
Init2 = ATZ
Init3 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Init4 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
ISDN = 0
#New PPPD = yes

再執行wvdial
如果有看到pppd取得IP address,dns address就對了

經過測試,不需要修改,也適用在C100S加台哥大的3G上

Labels:

2008/09/02 

內壢<->高鐵夜騎


一直想要參加桃園巨蛋<->林口的夜騎活動,不過很多中壢內壢楊梅新屋的朋友都有高鐵夜騎的經驗,這是我用TrackLog加google map畫出來的路線。

Labels:

About me

  • I'm Martin's blog 馬汀的部落格
  • From 中壢市, 桃園縣, Taiwan
  • -----BEGIN GEEK CODE BLOCK----- Version: 3.1 Comment: For info see http://www.geekcode.com GC/CS/CC/E/IT/TW d- s a C++++ L++++ P+ L++++ E--- W+++ N++ o+ K- w+++ O- M- V- PS+ PE++ Y+ PGP+ t 5- X++ R- tv- b+++ DI+ D-- G e+++ h+ r+ y+ z? ------END GEEK CODE BLOCK------ /**************************** 旅行是我生命的動力 它的樂趣從計劃旅行開始 我樂於分享旅行及Linux Kernel上的每一件事. ****************************/
My profile