Help - Search - Members - Calendar
Full Version: Pdaxi13 : Safer Apm Suspend On Akita
OESF Forums > Distros, Development, and Model Specific Forums > Distro Support and Discussion > pdaXrom
ulutte
Hi,

I have modified the scripts in /etc/apm in order to :

1. umount the swap on /dev/mmcda3
2. stop the processes accessing /mnt/card and /mnt/card2 on the SD card
2 remount /mnt/card and /mnt/card2 RO
... when suspending

and doing the opposite when resuming.

My config :

SD card : partition 1 DOS partition 2 ext2 partition 3 swap
pdaxii13 on C1000 "ipk-batch-install.tgz" install method.

I added the script "fs" in /etc/apm/scripts.d/ :

#! /bin/bash
#
# fd
#
# Ensures there is no IO on the SD card before suspending
# in order to avoid data dorruption

DOS_MNTPT_ON_SD=/mnt/card
DOS_DEVICE_ON_SD=/dev/mmcda1
EXT2_MNTPT_ON_SD=/mnt/card2
EXT2_DEVICE_ON_SD=/dev/mmcda2
SWAP_DEVICE_ON_SD=/dev/mmcda3

# See how we were called.

suspend() {
# Turn swap off.
swapoff $SWAP_DEVICE_ON_SD >/dev/null 2>/dev/null

# Remount dos data partition RO.
fuser -k -SIGSTOP -m $DOS_MNTPT_ON_SD >/dev/null 2>/dev/null
mount -o remount,ro $DOS_MNTPT_ON_SD >/dev/null 2>/dev/null

# Remount ext2 data partition RO.
fuser -k -SIGSTOP -m $EXT2_MNTPT_ON_SD >/dev/null 2>/dev/null
mount -t ext2 -o remount,ro $EXT2_DEVICE_ON_SD $EXT2_MNTPT_ON_SD >/dev/null 2>/dev/null

# Syncing all devices
sync
sleep 2

return 0
}

resume() {
# Turn swap on.
swapon $SWAP_DEVICE_ON_SD >/dev/null 2>/dev/null

# Remount dos data partition RW.
mount -o remount,rw $DOS_MNTPT_ON_SD >/dev/null 2>/dev/null

# Remount ext2 data partition RW.
mount -t ext2 -o remount,rw $EXT2_DEVICE_ON_SD $EXT2_MNTPT_ON_SD >/dev/null 2>/dev/null

# Syncing all devices
sync
sleep 2

# Resuming all processes
fuser -k -SIGCONT -m $DOS_MNTPT_ON_SD >/dev/null 2>/dev/null
fuser -k -SIGCONT -m $EXT2_MNTPT_ON_SD >/dev/null 2>/dev/null

return 0
}


case "$1" in
suspend)
suspend
;;
resume)
resume
;;
*)
echo "Usage: $0 {suspend|resume}"
exit 1
esac

exit $?

I put these two links pointing to "fs"

In /etc/apm/suspend.d : 920fs
In /etc/apm/resume.d : 001fs

Seems to work reliabely. Needs to be tested and adapted to your config. It is not very generic but gives some hints to avoid these nasty IO errors on the filesystem when resuming.

Best,
Ulutte
daniel3000
Isn't this dangerous when swap is heavily used?
I have heard and experiences myself that when unmounting a used swap, not all contents can be swapped back into memory and the system hangs.

daniel
InSearchOf
QUOTE(daniel3000 @ Aug 1 2007, 05:38 AM)
Isn't this dangerous when swap is heavily used?
I have heard and experiences myself that when unmounting a used swap, not all contents can be swapped back into memory and the system hangs.

daniel
*


I agree... and if there aren't issues... suspends will become VERY lengthy...

Late
ulutte
QUOTE(InSearchOf @ Aug 1 2007, 02:34 PM)
QUOTE(daniel3000 @ Aug 1 2007, 05:38 AM)
Isn't this dangerous when swap is heavily used?
I have heard and experiences myself that when unmounting a used swap, not all contents can be swapped back into memory and the system hangs.

daniel
*


I agree... and if there aren't issues... suspends will become VERY lengthy...

Late
*



Yes, your are right, turning off the swap might not be a good idea in case of heavy load. But suspending in this situation is in general not a good idea...

From a general point of view, I prefer a lengthy suspend than a buggy resume. When there is heavy traffic on the SD card while suspending, I experimented some timeout issues from the SD driver that yield I/O errors on the ext2 filesystem. This is very bad and could corrupt the data. Of course, the real culprit is the proprietary SD driver that is apm unaware. The best solution would be to have a better driver. I suggest here only a quickand dirty workaround.

Of course other suggestions are welcome ...
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2014 Invision Power Services, Inc.