星期四, 9月 02, 2004

Zaurus : C7000, swap file on SD

Site http://home.opaopa.org/zaurus/
===============================
ここ を参考にSD上にスワップを作ります.FATだと不安定だそうなので,ext2 でファイルシステムを作っておきます.

# mkfs.ext2 /mnt/card

あとは,/mnt/card/swapfile を作って,それをスワップに使います.

# cd /mnt/card # dd if=/dev/zero of=swapfile count=32768 # mkswap /mnt/card/swapfile # swapon /mnt/card/swapfile

起動時に swap が有効になるように,/etc/fstab に登録して, /etc/rc.d/init.d/swapも作っておきます.

# vi /etc/fstab /mnt/card/swapfile swap swap defaults 0 0 # cd /etc/rc.d/init.d # vi swap # for i in rc3.d rc4.d rc5.d do cd $i ln -s ../init.d/swap S30swap cd .. done # for i in rc0.d rc6.d do cd $i ln -s ../init.d/swap K70swap cd .. done

ついでに,/dev/mmcda1 のマウントオプションに noatime を追加しました.気休めかもしれませんが….

抜く時は,

# swapoff /mnt/card/swapfile

とするか,

# /etc/rc.d/init.d/swap stop

としてくだしさい.
本当は,ツールバーの SD アイコンと対応させられるといいんですけどね.
===============================
http://www.zaurususergroup.com/
===============================
Can I use a CF or SD card as memory, instead of file storage space?

* Set up a 'swap' file on the card

It is not recommended for normal usage (since writing and rewriting to the same area of flash media will wear it out much more quickly than normal usage), or the faint of heart, but creating a 'swap' file (virtual memory) on a card is possible.

Set up a swap file, and more "memory" will be available for programs. (Just remember to remove the swap file before unmounting and removing the card.)

o Open the 'Terminal'
o Create an empty file for use as swap. For example:

dd if=/dev/zero of=/mnt/cf/SwapFile count=32768

("count" is the size of the file in 512-byte blocks, so 32768 is 16MB. "of" specifies the location of the swapfile. In this case, on the mounted CF card.)

o Turn the blank file into a swap file:

mkswap /mnt/cf/SwapFile

o Activate the swapfile:

swapon /mnt/cf/SwapFile

You can see the swap by checking the available memory. Run the command "free".

To turn off the swapfile (you won't be able to eject the card unless you do this first!!!), run the command:

swapoff /mnt/cf/SwapFile

See also: Increasing virtual memory on your 5000D

Source: Howard R. Abbey, Huge Eaves, Rick Spickelmier

Last updated: 2002.Apr.06

======================================================
http://hpcgi2.nifty.com/gary/wiki.cgi?Zaurus
======================================================
dd if=/dev/zero of=/mnt/card/.swap bs=512 count=65536 #32MのswapをSDに作成
mkswap /mnt/card/.swap
su
swapon /mnt/card/.swap # swap有効
swapoff /mnt/card/.swap # swap無効
======================================================
Site : unknown
=======================================================
Site:PIL
=======================================================
相信在幾位前輩的教導下, 大家的 C700 都已成功開好 swap 了. 但是預設的 swap 是使用 vfat 的檔案格式,因為 fat 較不安定,且讀取較頻繁,所以會減少 sd/cf 卡的壽命及使用時間. 在此建議大家改成 Linux 的原生檔案格式 ext2 會更好哦!!
方法如下:

Code:[Copy to clipboard]

# swapoff /mnt/card/swap
# umount /dev/mmcda1
# mkfs.ext2 /dev/mmcda1
# mount -t ext2 /dev/mmcda1 /mnt/card
# dd if=/dev/zero of=/mnt/card/swap count=20000
# mkswap /mnt/card/swap
# swapon /mnt/card/swap

記得還要將 /etc/sdcontrol 開頭的環境變數改一下:以後就都生效嘍!!

Code:[Copy to clipboard]

#FSTYPE="-t vfat"
FSTYPE="-t ext2"
#FATOPTS="-o noatimei,quiet,umask=000,iocharset=utf8"
FATOPTS="-o rw,noatime"

非常感謝心得分享
我的/etc/sdcontrol 是參考這裡的設定
http://club.h14m.org/kenji/diary/?200302a#200302024
FSTYPE="-t ext2" 這行更新後被拿掉了,系統會自動判斷
FATOPTS="-o noatimei,quiet,umask=000,iocharset=utf8" 這行可保留
FATOPTS="-o rw,noatime" 這行要改成EXT2OPTS="-o rw,noatime"
這些設定已經在1.3的升級中修正,如果已經升級的就無須修改
須注意記憶卡格式化成ext2後Win32平台或數位像機會不能存取
如果打算SD卡插上後不會拔了就可以這樣做

=================================================================
And Here
=================================================================
and

建議 sdcontrol 的檔案中加入一些錯誤檢查, 比較保險!!
並把 swapfile 改為 .swapfile (unix 中的隱藏檔) 可防止誤刪!!

改更如下:



Quote:

#!/bin/sh
#
# sdcontrol 1.0 2001/8/8 21:33:19 (Hideki Hayami)
#
# Initialize or shutdown a SD card device
#
# The first argument should be either 'insert' of 'eject'.
#

ACTION=$1
DEVICE=/dev/mmcda1
MOUNT_POINT=/mnt/card
SMB_MOUNT=/home/samba/SD_Card
INSTALL_DIR=Documents/Install_Files
#FSTYPE="-t vfat"
FATOPTS="-o noatimei,quiet,umask=000,iocharset=utf8"

###### for QPE ######
get_pid()
{
echo $1
}

wait_release()
{
count=1
while true
do
umount $MOUNT_POINT
if [ $? = 0 ]; then
#echo umount >> /tmp/sd
return
fi
echo count=$count >> /tmp/sd
if [ `expr $count \>= 500` = 1 ]; then
#echo time out >> /tmp/sd
return
fi
count=`expr $count + 1`
usleep 200000
done
}

kill_task()
{
ps_line=`ps ax | grep -w 'qpe$'`
qpe_pid=`get_pid $ps_line`
#echo qpe_pid = $qpe_pid >> /tmp/sd
target_pids=`fuser -m $DEVICE | cut -d : -f2`
#echo $target_pids >> /tmp/sd
if [ "$target_pids" = "" ]; then
return
fi
is_exist_qpe=`echo $target_pids | fgrep -w $qpe_pid`
if [ "$is_exist_qpe" = "" ]; then
kill -9 $target_pids
#echo kill -9 $target_pids >> /tmp/sd
else
#echo "found qpe!!!" >> /tmp/sd
target_pids=`echo $target_pids | sed -e "s/$qpe_pid//"`
if [ "$target_pids" != "" ]; then
kill -9 $target_pids
#echo kill -9 $target_pids >> /tmp/sd
fi
wait_release
exit 0
fi
}
###### for QPE ######

case "$ACTION" in
'insert')
mount $FSTYPE $FATOPTS $DEVICE $MOUNT_POINT
MOUNT_RES = `mount | grep $DEVICE`
if [ "$MOUNT_RES" = "" ]; then
mount $FSTYPE $DEVICE $MOUNT_POINT
fi
chkmntsh ${MOUNT_POINT}
if [ -d $SMB_MOUNT ] ; then
rm -rf $SMB_MOUNT
fi
ln -s $MOUNT_POINT $SMB_MOUNT
mkdir -p $MOUNT_POINT/$INSTALL_DIR
#echo mount $? >> /tmp/sd
# for card swap support
if [ -f /mnt/card/.swapfile ]; then
swapon /mnt/card/.swapfile
fi
;;
'eject')
# for card swap support
if [ -f /mnt/card/.swapfile ]; then
/sbin/swapoff /mnt/card/.swapfile
fi

fuser -s -m $DEVICE
if [ $? = 1 ]; then
umount $MOUNT_POINT
rm $SMB_MOUNT
else
exit 1
fi
;;
'compeject')
is_mount=`mount | fgrep $DEVICE`
if [ "$is_mount" = "" ]; then
exit 0
fi
kill_task # for QPE
#fuser -k -m $DEVICE > /dev/null
# for card swap support
if [ -f /mnt/card/.swapfile ]; then
/sbin/swapoff /mnt/card/.swapfile
fi
umount $MOUNT_POINT
if [ $? != 0 ]; then
usleep 500000
umount $MOUNT_POINT
#echo umount $? >> /tmp/sd
#else
# echo umount >> /tmp/sd
fi
rm $SMB_MOUNT
;;
'change')
$0 compeject
$0 insert
;;
'*')
exit 1
;;
esac

exit 0

沒有留言:

張貼留言