LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 04-16-2006, 10:35 AM   #1
bigwheel
Member
 
Registered: Feb 2005
Distribution: Mint, Raspbian
Posts: 34

Rep: Reputation: 15
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?
 
Old 04-16-2006, 12:24 PM   #2
Bruce Hill
HCL Maintainer
 
Registered: Jun 2003
Location: McCalla, AL, USA
Distribution: Arch, Gentoo
Posts: 6,940

Rep: Reputation: 129Reputation: 129
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.
 
Old 04-16-2006, 08:05 PM   #3
bigwheel
Member
 
Registered: Feb 2005
Distribution: Mint, Raspbian
Posts: 34

Original Poster
Rep: Reputation: 15
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.
 
Old 04-16-2006, 08:14 PM   #4
Bruce Hill
HCL Maintainer
 
Registered: Jun 2003
Location: McCalla, AL, USA
Distribution: Arch, Gentoo
Posts: 6,940

Rep: Reputation: 129Reputation: 129
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.
 
Old 04-16-2006, 08:33 PM   #5
cs-cam
Senior Member
 
Registered: May 2004
Location: Australia
Distribution: Gentoo
Posts: 3,545

Rep: Reputation: 57
Yup, imagemagick will be able to scale the images for you, awesome app suite that one
 
Old 04-17-2006, 04:24 AM   #6
Bruce Hill
HCL Maintainer
 
Registered: Jun 2003
Location: McCalla, AL, USA
Distribution: Arch, Gentoo
Posts: 6,940

Rep: Reputation: 129Reputation: 129
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!
 
Old 04-17-2006, 04:44 PM   #7
bigwheel
Member
 
Registered: Feb 2005
Distribution: Mint, Raspbian
Posts: 34

Original Poster
Rep: Reputation: 15
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/

Last edited by bigwheel; 04-17-2006 at 04:53 PM.
 
Old 04-17-2006, 04:51 PM   #8
Bruce Hill
HCL Maintainer
 
Registered: Jun 2003
Location: McCalla, AL, USA
Distribution: Arch, Gentoo
Posts: 6,940

Rep: Reputation: 129Reputation: 129
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
 
Old 04-17-2006, 07:56 PM   #9
burninGpi
Member
 
Registered: Mar 2006
Location: Fort McMurray, Canada
Distribution: Gentoo ~amd64
Posts: 163

Rep: Reputation: 30
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.

Last edited by burninGpi; 04-17-2006 at 07:59 PM.
 
Old 04-23-2006, 09:55 AM   #10
bigwheel
Member
 
Registered: Feb 2005
Distribution: Mint, Raspbian
Posts: 34

Original Poster
Rep: Reputation: 15
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
 
  


Reply

Tags
camera, compression, image, mount, script, usb



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
when i mount my USB Flash Drive A Messenge has come that mount: can't find /dev/sda/h feda82 Red Hat 2 12-24-2005 07:16 AM
when i mount my USB Flash Drive A Messenge has come that mount: can't find /dev/sda/h feda82 Red Hat 1 12-24-2005 04:25 AM
when i mount my USB Flash Drive A Messenge has come that mount: can't find /dev/sda/h feda82 Red Hat 2 12-24-2005 02:15 AM
Mount USB disk with permissions EcceVery Debian 4 06-05-2005 12:18 PM
mount usb module then mount usb hard drive guanyu Linux - Hardware 1 10-08-2003 11:50 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 10:17 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration