« Subversion downgrade and permission errors | Main | OSCON 2008 - where is Open Source going? »

Automounting SD card on EeePC

For some time, I'm seeing strange messages in powertop with mounted SD card:

A USB device is active 100.0% of the time:
USB device  5-5 : UB6225 (ENE)

Since I'm leaving for OSCON (and will mostly work on eee while there) I wanted to be conservative about my battery usage, so I took a closer look at this problem.

At first, installing autofs seemed like good idea. However, autofs can't run scripts (and I really want to toggle card reader's power) so I took a looked at afuse which seemed nice, but I didn't want to add another layer of indirection (missing timeout feature could be solved by script which sleeps in background).

Than I thought about it a bit more and decided that best solution is probably simplest possible: do a small shell script. I usually know when I want to access files on SD card anyway (otherwise, I couldn't really power off card because I would be using files on it).

#!/bin/sh

dir=/rest

if mount | grep $dir >/dev/null ; then
umount $dir && sudo sh -c "echo 0 > /proc/acpi/asus/cardr"
sudo rmmod usb-storage
sudo dmesg -c
else
if [ `cat /proc/acpi/asus/cardr` -eq 1 ] ; then
mount $dir && df $dir
else
sudo modprobe usb-storage delay_use=0
sudo sh -c "echo 1 > /proc/acpi/asus/cardr"
sudo dmesg -c
sleep 2
sudo dmesg -c
mount $dir && df $dir
fi
fi

You might want to remove dmesg calls if you don't care about output or don't want this script to mess with your kernel logs.

TrackBack

TrackBack URL for this entry:
http://blog.rot13.org/mt/mt-tb.cgi/594

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

About

This page contains a single entry from the blog posted on July 18, 2008 8:58 PM.

The previous post in this blog was Subversion downgrade and permission errors.

The next post in this blog is OSCON 2008 - where is Open Source going?.

Many more can be found on the main index page or by looking through the archives.

Creative Commons License
This weblog is licensed under a Creative Commons License.
Powered by
Movable Type 5.04