You are not logged in.
Hello, if you by chance have very limited space on your netbook, and want to use an SD card for say.. your home partition like I do. Then you could use this script I wrote.
#!/bin/bash
. /etc/rc.conf
. /etc/rc.d/functions
#Variables you should change
MNTPNT="/home/coda"
UUID="8d35d9ce-7f16-4fdb-ba8c-aafcdebad05a"
FS="ext4"
#Something that does not change
DEVICE="/dev/disk/by-uuid/$UUID"
case "$1" in
start)
stat_busy "Mounting SD card..."
echo "Waiting for SD card to exist..."
COUNT=0
while [ ! -e $DEVICE ]; do
sleep 1
((COUNT++))
if ((COUNT > 5)); then
echo "Device does not exist..."
stat_fail
exit
fi
done
echo "Card exists!"
mount $DEVICE $MNTPNT -t $FS
if cat /proc/mounts | grep -q $MNTPNT; then
echo "Mounted at $MNTPNT"
stat_done
else
echo "Failed to mount device!"
stat_fail
fi
;;
stop)
stat_busy "Unmounting SD card..."
umount $DEVICE
if cat /proc/mounts | grep -q $MNTPNT; then
echo "Failed to unmount device!"
stat_fail
else
echo "Device has been successfully unmounted."
stat_done
fi
;;
restart)
echo "ummm.... no"
stat_fail
;;
*)
echo "usage: $0 {start|stop|restart}"
esac
exit 0
Just put that in your /etc/rc.d/ folder, and then put it in your daemons list in rc.conf right after hal.
I didn't feel that the restart function would be of any use, so I didn't code it.
If you have suggestions of better ways of doing this, please suggest.
Offline
You can solved your problem with the shell script, great
Thanks for the functionality.
Offline
whats that script exactly for? for us not so pro ppl i have an sd card mounted as my home partition on my netbook and it is working without problems without that script?
does it just check if an sd card is inserted or not, than mount it or unmount it with start/stop?
Last edited by ichbinesderelch (2010-02-24 10:26:17)
Offline
Maybe I am missing something, but what does this achieve over an entry in /etc/fstab...?
Are you familiar with our Forum Rules, and How To Ask Questions The Smart Way?
BlueHackers // fscanary // resticctl
Offline
Maybe I am missing something, but what does this achieve over an entry in /etc/fstab...?
My thoughts exactly...
I have an entry for an SD card in there. It doesn't hold my home partition, but it could if I wanted to using the same method.
Offline
Maybe I am missing something, but what does this achieve over an entry in /etc/fstab...?
Because an entry in fstab tries to mount the SD card too early, before the device exists, and fails.
Offline
Why is this supposed to be a daemon?
This silver ladybug at line 28...
Offline
Why is this supposed to be a daemon?
What do you think it should be?
Offline
A daemon is a program that runs in the background, waiting for events to occur and offering services.
You script is not this kind of thing; IMO it's "daemon abuse".
This silver ladybug at line 28...
Offline
Because an entry in fstab tries to mount the SD card too early, before the device exists, and fails.
it does? my sd card gets mounted proberly on every boot with an fstab entry!
Offline
Ok, fine.. I will keep things like this to myself. This script is something I need, and I thought other people would like it.
Offline
Maybe you could put it in an rc.* script instead of making it a daemon.
Ok, fine.. I will keep things like this to myself. This script is something I need, and I thought other people would like it.
Naa, don't sweat it, he didn't mean it like that This would be a good candidate for the "Post your handy self-made command line utilities" thread.
Offline
Ok, fine.. I will keep things like this to myself. This script is something I need, and I thought other people would like it.
i guess we all didnt mean to offend you, just asking for the need of it.
Offline
DeeCodeUh wrote:Ok, fine.. I will keep things like this to myself. This script is something I need, and I thought other people would like it.
i guess we all didnt mean to offend you, just asking for the need of it.
Not everyone will need it, but some computers like mine have sd card readers that wont be available until very late in the startup process, and a simple entry in fstab wont work. This takes care of it, by waiting up to 5 seconds (usually only takes 1 or 2) for the device to become available, then mounts it. This was a problem I was trying to solve for a while, until I figured that this was the best way in my opinion. Both my friend and I enjoy using this script, as it solves the problem on both of our netbooks.
Offline
Maybe you could put it in an rc.* script instead of making it a daemon.
DeeCodeUh wrote:Ok, fine.. I will keep things like this to myself. This script is something I need, and I thought other people would like it.
Naa, don't sweat it, he didn't mean it like that
This would be a good candidate for the "Post your handy self-made command line utilities" thread.
What do you mean rc.* script? How do I do that?
Offline
Ok, fine.. I will keep things like this to myself. This script is something I need, and I thought other people would like it.
We didn't mean it like that, just trying to understand the problem you were trying to solve... We didn't know that you have issues with the block device being created too late for fstab
Are you familiar with our Forum Rules, and How To Ask Questions The Smart Way?
BlueHackers // fscanary // resticctl
Offline
DeeCodeUh wrote:Ok, fine.. I will keep things like this to myself. This script is something I need, and I thought other people would like it.
We didn't mean it like that, just trying to understand the problem you were trying to solve... We didn't know that you have issues with the block device being created too late for fstab
It's alright, thanks for clarifying.
Offline
Runiq wrote:Maybe you could put it in an rc.* script instead of making it a daemon.
DeeCodeUh wrote:Ok, fine.. I will keep things like this to myself. This script is something I need, and I thought other people would like it.
Naa, don't sweat it, he didn't mean it like that
This would be a good candidate for the "Post your handy self-made command line utilities" thread.
What do you mean rc.* script? How do I do that?
You could edit the /etc/rc.local and add a line to launch your script.
Offline