Re: automount



roN wrote:

Okay, anyways, I thought I'm gonna do it by script too, just as a
temporary solution but I have some troubles... :(
My Script looks like:
[script]
#!/bin/bash
#
# mount external USB drive
#
# $Log$
#
# $Id$
#

case "$1" in
start)
echo "Mounting USB Disk to /media/HARDBOX";
mount /dev/sda1 /media/HARDBOX
;;
stop)
echo "Unmounting USB Disk from /media/HARDBOX";
umount /media/HARDBOX
;;
esac
exit 0
[/script]
Okay and it works or even doesn't as follows:
[shell]
linux-ron:/home/reg # mount
/dev/hda6 on / type reiserfs (rw,acl,user_xattr)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
debugfs on /sys/kernel/debug type debugfs (rw)
udev on /dev type tmpfs (rw)
devpts on /dev/pts type devpts (rw,mode=0620,gid=5)
/dev/hda2 on /windows/C type vfat
(rw,noexec,nosuid,nodev,gid=100,umask=0002,utf8=true)
securityfs on /sys/kernel/security type securityfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
[/shell]
Ok, nothing is mounted yet...
let's execute the script:
[shell]
linux-ron:/home/reg # /etc/init.d/auto_usb_mount start
/etc/init.d/auto_usb_mount: line 12:  : command not found
/etc/init.d/auto_usb_mount: line 14:  : command not found
linux-ron:/home/reg # mount
/dev/hda6 on / type reiserfs (rw,acl,user_xattr)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
debugfs on /sys/kernel/debug type debugfs (rw)
udev on /dev type tmpfs (rw)
devpts on /dev/pts type devpts (rw,mode=0620,gid=5)
/dev/hda2 on /windows/C type vfat
(rw,noexec,nosuid,nodev,gid=100,umask=0002,utf8=true)
securityfs on /sys/kernel/security type securityfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
/dev/sda1 on /media/HARDBOX type vfat (rw)
[/shell]
some errors but still mounted? huh? Why do I get errors?
let's try unmounting it:
[shell]
linux-ron:/home/reg # /etc/init.d/auto_usb_mount stop
/etc/init.d/auto_usb_mount: line 16:  : command not found
/etc/init.d/auto_usb_mount: line 17:  : command not found
/etc/init.d/auto_usb_mount: line 18:  : command not found
linux-ron:/home/reg # mount
/dev/hda6 on / type reiserfs (rw,acl,user_xattr)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
debugfs on /sys/kernel/debug type debugfs (rw)
udev on /dev type tmpfs (rw)
devpts on /dev/pts type devpts (rw,mode=0620,gid=5)
/dev/hda2 on /windows/C type vfat
(rw,noexec,nosuid,nodev,gid=100,umask=0002,utf8=true)
securityfs on /sys/kernel/security type securityfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
/dev/sda1 on /media/HARDBOX type vfat (rw)
linux-ron:/home/reg #
[/shell]
Some errors and umount didn't work...huh?
Can anybody help me? It would be appreciated!
Thank you!

In that kind of script you should always put the full path of the commands,
such as /bin/mount instead of mount, to make sure which command is used.
Here if the mount shows that the script has succeded in mounting
the /dev/sda1 partition it may be the echo which fails. Comment out these
echo lines. You can test such a script with sh -x thescript, or also
putting -x as option on the magic line. You may also add a few options in
the mount command. The umount may fail if you have done a cd into the
directory.

Try this :
#!/bin/bash
#
# mount external USB drive
#
# $Log$
#
# $Id$
#

case "$1" in
start)
/bin/mount /dev/sda1 /media/HARDBOX
;;
stop)
/bin/umount /media/HARDBOX
;;
esac
exit 0


.



Relevant Pages

  • Re: automount
    ... My Script looks like: ... debugfs on /sys/kernel/debug type debugfs ... securityfs on /sys/kernel/security type securityfs ...
    (alt.os.linux.suse)
  • Re: automount
    ... Okay, anyways, I thought I'm gonna do it by script too, just as a temporary ... sysfs on /sys type sysfs ... debugfs on /sys/kernel/debug type debugfs ... securityfs on /sys/kernel/security type securityfs ...
    (alt.os.linux.suse)