From: blackcat on
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


From: roN on
blackcat wrote:

> 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

even worse :( :
linux-ron:/home/reg # mount # see what's mounted
/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 #ok it's mounted now
(rw,noexec,nosuid,nodev,gid=100,umask=0002,utf8=true,user=reg)
linux-ron:/home/reg # /etc/init.d/auto_usb_mount stop #try to umount by
using the script
/etc/init.d/auto_usb_mount: line 15:  : command not found
/etc/init.d/auto_usb_mount: line 16:  : command not found
linux-ron:/home/reg # umount /dev/sda1 # hm, negativ, ok umount manually
linux-ron:/home/reg # mount # see what's mounted now
/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)
linux-ron:/home/reg # /etc/init.d/auto_usb_mount start #since it's not
mounted, try to mount by using script
/etc/init.d/auto_usb_mount: line 12:  : command not found
/etc/init.d/auto_usb_mount: line 13:  : command not found
linux-ron:/home/reg # mount # there were some errors but last time it was
mounted anyways, and now?
/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)
linux-ron:/home/reg # # it was not mounted :( What's going wrong here?
I'd appreciate help! thank you, btw, the script looked this time like:
#!/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
Thanks for some support and i btw think i should mount it with these options
(since it's a fat partition) which i got out of fstab:
"user,users,gid=users,umask=0002,utf8=true"
--
chEErs roN

I'm root, I'm allowed to do this! ;)
keep on rockin'
From: Lawrence D'Oliveiro on
In article <44a52511$0$22113$ed2619ec(a)ptn-nntp-reader01.plus.net>,
blackcat <hello(a)anywhere.net> wrote:

>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.

Why?