2008年8月19日

A Tweaker’s Guide to Solid State Drives (SSDs)

Geek Sheet: A Tweaker’s Guide to Solid State Drives (SSDs) and Linux | Tech Broiler | ZDNet.com
Tweak #1: If your system motherboard uses a disk caching bus, change the BIOS setting from “Write Through” to “Write Back”.
[root@techbroiler ~]# hdparm -W0 /dev/sda

Tweak #2: Use the “noop” I/O scheduler. By default, Linux uses an “elevator” so that platter reads and writes are done in an orderly and sequential matter.
By adding elevator=noop to your kernel boot parameters in your /boot/grub/menu.lst file, you will greatly improve read and write performance on your SSD.
This parameter sets the default I/O scheduler system wide, so if you have mixed SSD and conventional disks in your computer, you will want to set the scheduler on a drive-by-drive basis. This can be achieved using the following command:
echo noop > /sys/block/sda/queue/scheduler

Tweak #3: Change the file system mount options on SSDs to “noatime”.

Tweak #4: Ditch the journal and RAID your SSDs. File system journaling is done primarily for increased reliability, but it’s a drag on performance. Given that SSDs by their nature are going to be less prone to reliability quirks than a conventional drive, Mandrake suggests creating a RAID1 of two SSD units and formatting the file system to ext2, or formatting them to ext3 and mounting them as ext2 in the /etc/fstab. Dump your MySQL database on a RAID of ext2 SSDs, and you’ll be in performance hog heaven. EDIT 07-27-08: Some concerns were raised about what could happen if the power goes out and you lose referential integrity of the FS and are unable to replay it from the journal — so you might want to use a traditional disk using a journaled FS to sync the database to for backups.


ref:
Choosing an I/O Scheduler for Red Hat® Enterprise Linux® 4 and the 2.6 Kernel

2008年8月18日

iSpring Free

PChome Online 網路家庭-下載
iSpring Free 將 Powerpoint 投影片轉檔為 Flash 動畫
iSpring Free 是個免費的 Powerpoint 轉檔到 Flash 格式的外掛工具,能將已經製作好的 Powerpoint 投影片轉為 Flash 動畫,直接放到網頁上,卻不失去原有的虛擬動畫和特效,適合習慣使用 Powerpoint 的使用者或用來將現有豐富的投影片內容轉檔使用,不需要重新製作。

2008年8月17日

Alternate Data Streams in NTFS

介紹好用工具:Streams 讓你瞭解神秘的 NTFS 檔案系統
Windows Sysinternals 工具組中的 Streams 可以讀取 NTFS 檔案系統中目錄或檔案的「替代資料串流(alternate data streams)」的資料,而這個 streams 真的是個「非常神秘」的東西。

「資料串流(Streams)」這個名稱我想大家一定覺得很抽象,在 NTFS 檔案系統中,目錄與檔案都是以資料串流的方式儲存,而預設的檔案內容就是儲存在「未命名資料串流」中,如果要在命令提示字元下取得「未命名資料串流」的資料,很簡單的就是利用 type 命令將資料取出,例如:

C:\>type C:\test.txt
123

或是

C:\>more C:\test.txt
123

而若要寫入或讀取「替代資料串流」的資料就可以利用一個冒號( : )加上一個鍵值(Key)進行存取。

例如你要寫入一個字串 ( Hello ) 到 C:\test.txt 檔案的「替代資料串流」中,並將這個「替代資料串流」命名為 TEST,就可以用以下語法寫入:

echo Hello > C:\test.txt:TEST

這樣子就可以將 Hello 字串(包括斷行)儲存到 C:\test.txt 檔案的「替代資料串流」中,而若你要將這個「替代資料串流」中的資料取出,可以用以下語法:

C:\>more < c:\test.txt:TEST
Hello

注意:你不能使用 type 命令將 C:\test.txt 檔案中的 :TEST 串流資料取出,因為 type 命令並不支援串流資料(stream)的讀取!若你有安裝 cygwin 的話,裡面的 cat 工具也可以讀取「替代資料串流」資料。

「替代資料串流」中的資料就如同「未命名資料串流」中的資料一樣,你想儲存什麼資料都可以,純文字、二進位資料都 OK 的,只是儲存在「替代資料串流」中的資料量大小,在使用檔案總管檢視的時候是不會被計算到的,如下圖示,我的 test.txt 內容有 3 個位元組(bytes),剛剛透過指令寫入 Hello 字串 + 斷行符號 + NULL 字元,一共 8 個 bytes 被寫入到 test.txt 檔案的 TEST 替代資料串流中,照理說這個檔案應該要佔用 11 個位元組(bytes)才對,但是在檔案總管中卻僅僅顯示 3 個位元組(bytes)而已。雖然這裡看不出來,但是磁碟的容量還是實際被佔用 11 個位元組(bytes)的!

test.txt 內容

但你要如何才能看出你的檔案或目錄中有沒有任何「替代資料串流」的資料呢?預設來說 Windows 內建的所有工具或指令,沒有一個能夠查詢檔案中是否有「替代資料串流」資料。

這時,你是否有種心理涼涼的感覺?我剛瞭解到 streams 這個玩意的時候,覺得很恐怖勒!NTFS 檔案系統中竟然有個如此神秘的地方可以藏資料,而且還不會被發現!這就是為什麼當你在 C:\ 下按「全選」然後選「內容」計算檔案大小時,怎麼算都跟磁碟機的「已使用空間」不符,雖然這些神秘的資料並不全然都是儲存在「替代資料串流」中,但也有可能有些許資料藏在這裡。

若要查詢出檔案或目錄中是否有「替代資料串流」的資料,就只能靠 Windows Sysinternals 工具組中的 Streams 工具幫你檢視了,streams 的用法很簡單,如下:

C:\>streams

Streams v1.56 - Enumerate alternate NTFS data streams
Copyright (C) 1999-2007 Mark Russinovich
Sysinternals - www.sysinternals.com

usage: streams [-s] [-d]
-s Recurse subdirectories
-d Delete streams

當我們用 streams 工具查詢剛剛的 C:\test.txt 檔案時,就會查到該檔案中所有「替代資料串流」的所有鍵值:

C:\>streams test.txt

Streams v1.56 - Enumerate alternate NTFS data streams
Copyright (C) 1999-2007 Mark Russinovich
Sysinternals - www.sysinternals.com

C:\test.txt:
:TEST:$DATA 8

你也可以利用 -s 參數掃瞄整個磁碟機中所有的目錄與檔案,看看到底有多少檔案或目錄有「替代資料串流」資料:

C:\>streams -s .

最後,我再分享一個小經驗,大部分人應該都曾經看過以下的安全性警告視窗吧:

安全性警告視窗

這是因為你透過 IE 線上下載 *.exe 的檔案(例如:putty.exe),IE 在開啟或儲存檔案的時候,就會幫你多加上一個「替代資料串流」資料,並且會將「替代資料串流」的鍵值取名為 Zone.Identifier,如下:

C:\>streams putty.exe

Streams v1.56 - Enumerate alternate NTFS data streams
Copyright (C) 1999-2007 Mark Russinovich
Sysinternals - www.sysinternals.com

C:\putty.exe:
:Zone.Identifier:$DATA 26

若你將這個鍵值的內容取出,會發現以下資料:

C:\>more < putty.exe:Zone.Identifier
[ZoneTransfer]
ZoneId=3

而當你透過 streams.exe 工具用 -d 指令將 putty.exe 檔案的「替代資料串流」資料刪除後,就不會再出現這個畫面了。

C:\>streams -d putty.exe

Streams v1.56 - Enumerate alternate NTFS data streams
Copyright (C) 1999-2007 Mark Russinovich
Sysinternals - www.sysinternals.com

C:\putty.exe:
Deleted :Zone.Identifier:$DATA

等一段時間後(大約幾十秒吧),你再透過檔案總管或捷徑啟動 putty.exe 就不會再有安全性警告的提示了。

相關連結

* Streams v1.56 - Sysinternals
* FAQ: Alternate Data Streams in NTFS
* LADS - List Alternate Data Streams by Frank Heyne
* Windows NTFS Alternate Data Streams
* Practical Guide to Alternative Data Streams in NTFS
* Accessing alternative data-streams of files on an NTFS volume
* Fork (filesystem) - Wikipedia
* NTFS - Wikipedia

有特定格式的 JPEG 圖檔無法在 IE 瀏覽器中顯示

有特定格式的 JPEG 圖檔無法在 IE 瀏覽器中顯示
有特定格式的 JPEG 圖檔無法在 IE 瀏覽器中顯示

好久以前我就發現 IE 在讀取特定 JPEG 圖檔的時候會無法顯示,也就是會顯示俗稱的叉燒包 ( image ),但圖片下載回來後使用各式看圖工具都可以正常顯示,唯獨 IE 無法瀏覽,有幾次客戶在我們開發的網站後台上傳圖片發現前台都看不到,就急忙的打電話來說我們寫的程式有 Bug,真的是很冤望啊。

通常的作法都是用繪圖軟體將該圖檔打開,重新存檔一次就可以在 IE 看到了。在 IE/Firefox 中看不見圖片的真正原因出在於這些 JPEG 圖檔是用 CMYK 模式存檔的,而 IE 只能讀取 RGB 模式的圖檔,所以就會導致圖片無法開啟了。

如果你是用 Photoshop 的話,可以在存檔的時候選擇 Save for web 也可以將圖檔強制轉成 RGB 模式。

之前也有介紹過一篇 在 Linux 下批次轉換 JPEG 圖片尺寸的方法 ,你也可以用 ImageMagick 中的 mogrify 工具轉換圖片,如下指令:

mogrify -colorspace RGB Your_CMYK_Image.jpg

如果想實驗的可以下載這張圖片回去玩玩看,直接拖曳圖片到 IE 瀏覽器中即可。

Battlefield 2 DEMO on Ubuntu

Install bf2
checking docs below

Remove the time limit
Open Battlefield 2 Standalone Demo Server\mods\bf2\python\game\gamemodes\gpm_cq.py

Comment the line by adding a "#" at the begining
#host.registerHandler('TimeLimitReached', onTimeLimitReached, 1)

To remove the display timer edit your serversettings.con file and change sv.timelimit to sv.timelimit 1000000000000

Triumphs and Trecharies of Linux on Vostro 1500: Setting up Battlefield 2
DirectX 9.0c March 2008 redistributable on Linux with Wine | Wine Reviews
Wine AppDB - Battlefield 2 1.x
Battlefield 2 DEMO: How to Remove the time limit - AgeRage.net Forum