LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   usb mount permissions (http://www.linuxquestions.org/questions/slackware-14/usb-mount-permissions-435670/)

bigwheel 04-16-2006 11:35 AM

usb mount permissions
 
I would like to be able for users to mount usb drives. This is on a 10.2 Slackware install.

I added this line in fstab:

Code:

/dev/sda1        /mnt/usbdrive    vfat        noauto,user,rw  0  0
Here are the permissions for the /mnt/usbdrive directory:

Code:

paul@darkstar:~$ cd /mnt/usbdrive
paul@darkstar:/mnt/usbdrive$ ls -ld
drwxr-xr-x  2 root root 48 2006-04-13 23:18 ./

When I try to mount as a user:

Code:

paul@darkstar:~$ mount /dev/sda1 /mnt/usbdrive
mount: only root can do that

What can I do to allow all users to mount usb drives?

Bruce Hill 04-16-2006 01:24 PM

This should work:
Code:

/dev/sdc1        /mnt/usb        vfat        noauto,users,rw,umask=1000  0  0
mingdao@silas:~$ mount /mnt/usb && cd /mnt/usb && ls -lh
total 48M
-rwxrwxrwx 1 mingdao users  20M 2006-03-13 12:44 AdbeRdr705_enu_full.exe*
-rwxrwxrwx 1 mingdao users 5.0M 2006-02-08 17:12 Firefox\ Setup\ 1.5.0.1.exe*
-rwxrwxrwx 1 mingdao users 6.1M 2006-03-13 12:41 Thunderbird\ Setup\ 1.5.exe*
-rwxrwxrwx 1 mingdao users 6.7M 2006-03-13 12:43 gaim-1.5.0.exe*
-rwxrwxrwx 1 mingdao users 3.0K 2006-04-12 14:03 invisible.tar.gz*
-rwxrwxrwx 1 mingdao users  65 2006-03-13 13:41 key*
-rwxrwxrwx 1 mingdao users 8.5M 2006-03-13 12:41 nentenst.exe*
-rwxrwxrwx 1 mingdao users 184K 2006-04-12 14:03 slack1.png*
-rwxrwxrwx 1 mingdao users  36 2006-04-04 14:15 ssh*
-rwxrwxrwx 1 mingdao users 1.6M 2006-03-13 12:43 xchat-2.6.1a.exe*
mingdao@silas:/mnt/usb$ cd
mingdao@silas:~$ umount /mnt/usb
mingdao@silas:~$ mount /dev/sdc1 /mnt/usb
mount: only root can do that
mingdao@silas:~$

Just issue "mount /mnt/usbdrive" without the block special device.

bigwheel 04-16-2006 09:05 PM

Thank you, that worked. Now my Camera Download script does the job:

Code:

#!/bin/bash
newdir=`date +%a-%b%d-%Y-%R`
/bin/mkdir /home/paul/images/$newdir
/bin/mount /mnt/usbdrive
/bin/mv /mnt/usbdrive/dcim/100_fuji/* /home/paul/images/$newdir
/bin/umount /mnt/usbdrive

My next project is to figure out how to automatically scale down the images and reduce the filesize a bit.

Bruce Hill 04-16-2006 09:14 PM

Thanks for that script. I'll have to try it with my Sony camera.
Can you tell me what "newdir=`date +%a-%b%d-%Y-%R`" does?

I think to scale the images you can use "convert" or something
else from the imagemagick app.

cs-cam 04-16-2006 09:33 PM

Yup, imagemagick will be able to scale the images for you, awesome app suite that one :)

Bruce Hill 04-17-2006 05:24 AM

bigwheel,

I gotta learn bash scripting. Got a book or two but never read them.
That's a nice script -- real clean and efficient. I'm going to add
my videos from my Sony camera to it. Thanks!

bigwheel 04-17-2006 05:44 PM

Chinaman probably already figured this out, but

Code:

newdir=`date +%a-%b%d-%Y-%H-%M-%S`
/bin/mkdir /home/paul/images/$newdir

creates a new directory with a name format like

Mon-Apr17-2006-17-36-29

Which is the output of the date function. Look at man date and you can change the format as needed. Warning, don't use a time which has a colon in the output.

This is what I am trying to do to reduce the size of the images after downloading them:

Code:

#!/bin/bash
newdir=`date +%a-%b%d-%Y-%H-%M-%S`
/bin/mkdir /home/paul/images/$newdir
/bin/mount /mnt/usbdrive
/bin/mv /mnt/usbdrive/dcim/100_fuji/* /home/paul/images/$newdir
/bin/umount /mnt/usbdrive
/bin/cd /home/paul/images/$newdir
/usr/bin/gimp -i -b '(gimp-image-scale "*.jpg" 800 600)' '(gimp-quit 0)'

THE LAST TWO LINES DO NOT WORK YET!

I still need to get the gimp command to work on the command line. Actually I have not tested the cd command yet, need some time off to work on it.

Here is where I got the gimp batch script info from:

http://www.gimp.org/tutorials/Basic_Batch/

Bruce Hill 04-17-2006 05:51 PM

Yes, I issued "man date" just after posting that. And I made me a little script to do my videos, also. I can probably put it in the same script, but haven't yet. When I get some time I'll check out "convert" or something in the Imagemagick app and give you a line to replace that one.

If you get there before me, in a Slackware system we have:
file:///usr/share/doc/ImageMagick-6.2.6/www/convert.html

burninGpi 04-17-2006 08:56 PM

Get ImageMajick and try this:
Code:

#!/bin/bash
newdir="$(date +%a-%b%d-%Y-%H-%M-%S)"
mkdir $HOME/images/$newdir
cd $HOME/images/$newdir
mount /mnt/usbdrive                      # this works
mv /mnt/usbdrive/dcim/100_fuji/* ./      # The "./" is NOT a typo

for file in *.jpg                        # go through every file...
do
  convert -size 800x600 $file          # ...and resize it
done

umount /mnt/usbdisk                      # only if you want to

you should have this line in your .bashrc:
Code:

export PATH=/bin:/usr/bin:/usr/local/bin:$HOME/bin:.
this allows you to type cd instead of /bin/cd on the command line or in scripts.


the $(...) on line 2 is equivalent to `...`, but can be quoted safely.
See man strftime for how to format date.
All characters are safe for file or directory names. You just need to escape special ones with a backslash (\).
finally, you can get ImageMajick from imagemajick.org.

bigwheel 04-23-2006 10:55 AM

woohoot

I was able to get this script to work:

Code:

#!/bin/bash
mount /mnt/usbdrive                      # mounts usb device which is defined in fstab:
                                          # /dev/sda1 /mnt/usbdrive vfat noauto,user,rw 0 0
                                          #
newdir="$(date +%a-%b%d-%Y-%H-%M-%S)"          # creates date string with format: Mon-Apr17-2006-17-36-29
mkdir $HOME/images/$newdir                # makes directory with name = date string
cd $HOME/images/$newdir                  # change to new directory
mv /mnt/usbdrive/dcim/100_fuji/* ./      # move photo images to new directory, using camera specific path, empties camera
mkdir ./web                              # create a new directory to put web optimized images
                                          #
for filename in *.jpg                    # go through every file
do                             
  convert $filename -sample 800x600 -quality 75 web/$filename    #resize, compress, save to web directory
done
                                          #
umount /mnt/usbdrive                      #unmount usb device

It removes images from the camera, puts them in a date/timestamped directory, makes a web directory underneath it, then reduces the size and compresses the images, saving them in the web directory.

Thanks for the help!

Useful links:

http://www.cit.gu.edu.au/~anthony/graphics/imagick6/

http://www.imagemagick.org/script/co...line-tools.php

/usr/doc/ImageMagick-6.2.3

http://linuxcommand.org/learning_the_shell.php


All times are GMT -5. The time now is 05:15 PM.