View unanswered posts    View active topics

All times are UTC - 6 hours





Post new topic Reply to topic  [ 24 posts ] 
Go to page 1, 2  Next

Print view Previous topic   Next topic  
Author Message
Search for:
PostPosted: Sun Mar 19, 2006 12:03 am 
Offline
Joined: Tue Aug 16, 2005 11:50 am
Posts: 181
Location: Douglasville, GA
I have been at this for almost a year and I still cannot get this figured out.

I have a camera that uses an SD card. So I put a 6-in-1 card reader in my mythtv box. I've NEVER got it to do anything. So I bought a usb pen drive that uses SD. I got that to mount once several months ago, but I don't think it ever worked with my R5A30.2 install.

So how is this done? What details do I need to give to get help?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 19, 2006 2:05 am 
Offline
Joined: Fri Sep 19, 2003 7:05 pm
Posts: 5088
Location: Fontana, Ca
Plug in your USB pen, then run dmesg. You should see what device your device is (/dev/sdX).
Edit you /etc/auto.master so it look like:
Quote:
# $Id: auto.master,v 1.2 1997/10/06 21:52:03 hpa Exp $
# Sample auto.master file
# Format of this file:
# mountpoint map options
# For details of the format look at autofs(5).
# /var/autofs/misc /etc/auto.misc
# /var/autofs/net /etc/auto.net
# KNOPPIX automounts for floppy and cdrom(s), see knoppix-autoconfig
/mnt/auto /etc/auto.mnt --timeout=2
/var/autofs/usb /etc/auto.usb --timeout=2
#/mnt/auto /etc/automount.sh --timeout=2

Edit (create) /etc/auto.usb, it should look like:
Quote:
# Format of file:
# mountpoint options device
#sda -fstype=vfat,uid=1002,gid=1002,umask=002,noatime :/dev/sda1
#sdb -fstype=vfat,uid=1002,gid=1002,umask=002,noatime :/dev/sdb1
sdc -fstype=vfat,uid=1002,gid=1002,umask=002,noatime :/dev/sdc1
#sdd -fstype=vfat,uid=1002,gid=1002,umask=002,noatime :/dev/sdd1
Note in the above example, sdc is what I want to use.
Code:
ln -s /var/autofs/usb/sdc /mnt/usb

Code:
/etc/init.d/autofs restart

Then simply cd to /mnt/usb....

_________________
cesman

When the source is open, the possibilities are endless!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 24, 2006 12:44 am 
Offline
Joined: Thu Mar 25, 2004 11:00 am
Posts: 9551
Location: Arlington, MA
Cecil, I'd really like to be able to use my new USB thumb drives for customizing installs. However since this process is kind of a nusicance to do manually before all my usual infrastructure is set up, I thought turning it into a script might be worthwhile. What do you think?

Code:
root@black2:~# cat setup_usb_drive.sh
#!/bin/bash
if [ $(id -u) != 0 ] ; then
    echo "Error: You must be root to run this script!"
    exit 4
fi
case $1 in
sd[a-z])
    drive=$1
    ;;
/dev/sd[a-z])
    drive=$(basename $1)
    ;;
*)
    echo "Error: Device '$1' is not a SCSI disk (sd?)"
    exit 2
    ;;
esac
if [ -n "$2" ] ; then
    mntpoint=$2
else
    mntpoint=/mnt/${drive}
fi
mntparent=$(dirname $mntpoint)
if [ ! -d "$mntparent" ] ; then
    echo "Error: Parent of mount point '$mntpoint' is not a directory!"
    exit 2
elif [ -L "$mntpoint" ] ; then
    rm $mntpoint
elif [ -e "$mntpoint" ] ; then
    echo "Error: mount point '$mntpoint' already exists!"
    exit 2
fi

if grep ^/var/autofs/usb /etc/auto.master >/dev/null ; then
    echo "Looks like there is already a USB storage hook in auto.master"
else
    echo "Adding a USB storage hook to auto.master"
    cp /etc/auto.master /etc/auto.master.orig
    echo "/var/autofs/usb /etc/auto.usb --timeout=2" >>/etc/auto.master
fi
if grep ^$drive /etc/auto.usb >/dev/null 2>&1 ; then
   echo "Looks like /dev/$drive is already in auto.usb"
else
   echo "Adding /dev/$drive to auto.usb"
   [ -f /etc/auto.usb ] && cp /etc/auto.usb /etc/auto.usb.orig
   echo "$drive -fstype=vfat,uid=1002,gid=1002,umask=002,noatime :/dev/${drive}1" >>/etc/auto.usb
fi

ln -s /var/autofs/usb/$drive $mntpoint

/etc/init.d/autofs restart


Last edited by tjc on Wed Mar 29, 2006 9:22 pm, edited 1 time in total.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 24, 2006 12:56 am 
Offline
Joined: Fri Sep 19, 2003 7:05 pm
Posts: 5088
Location: Fontana, Ca
Nice! I was thinking of writing a script for this.

_________________
cesman

When the source is open, the possibilities are endless!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 24, 2006 7:17 am 
Offline
Joined: Sun Jun 12, 2005 10:55 pm
Posts: 3161
Location: Warwick, RI
HI,
Subject close to my own interests :) I usually just add a line in the fstab and make a directory to match. With the R5B7 release, my son wanted to also join the KnoppMyth group so when it came time to do the fstab trick, it didn't work. The only thing "un-typical" is that the machine has the additional sd / cf / mmc / etc slots which appears to change things enough to not allow the machine to find the memory stick.

I haven't tried tjc's script yet, as I try to understand what it does first. As a side note, this is a triple boot machine, M$, Ubuntu and KnoppMyth. What is so cool about Ubuntu is the memory stick just pops up on the desktop when plugged in..... That would be very nice KnoppMyth feature, but I am just as happy keeping it simple & manual..

It doesn't make any difference which R5Ax or R5Bx, any ideas or hints?

Have a great day!
Mike


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 24, 2006 8:18 am 
Offline
Joined: Tue Nov 08, 2005 7:31 am
Posts: 195
Location: Secret Lair
mjl wrote:
I haven't tried tjc's script yet, as I try to understand what it does first.

It looks like it checks two command line arguments (required device name and optional pseudo mount point), then does pretty much what Cecil's manual procedure does, being careful not to duplicate stuff that's already in place. The only difference I see is that it leaves automount.sh uncommented rather than switching to auto.mnt, and the ordering of the entries in auto.master is different because it appends... It seems to work OK.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 25, 2006 5:18 am 
Offline
Joined: Fri Sep 19, 2003 7:05 pm
Posts: 5088
Location: Fontana, Ca
A little improvement. Just plug in the key and run the script. "R6" will have a more elegant solution. This only needs to be done once. After this, you simple need to plug in the drive and access the properly directory.
Code:
#!/bin/bash
if [ $(id -u) != 0 ] ; then
     echo "Error: You must be root to run this script!"
     exit 4
fi
echo "Please insert USB key and press <ENTER>."
read
echo "Just a sec..."
echo "Trying to determine location of USB key."
sleep 7
dmesg | tail >> /tmp/usb
drive=$(grep " sd[a-z]: sd" /tmp/usb | awk '{print $2}')
mntpoint=/mnt/$drive
mntparent=$(dirname $mntpoint)
if [ ! -d "$mntparent" ] ; then
    echo "Error: Parent of mount point '$mntpoint' is not a directory!"
    exit 2
elif [ -L "$mntpoint" ] ; then
    rm $mntpoint
elif [ -e "$mntpoint" ] ; then
    echo "Error: mount point '$mntpoint' already exists!"
    exit 2
fi
if grep ^/var/autofs/usb /etc/auto.master >/dev/null ; then
    echo "Looks like there is already a USB storage hook in auto.master"
else
    echo "Adding a USB storage hook to auto.master"
    cp /etc/auto.master /etc/auto.master.orig
    echo "/var/autofs/usb /etc/auto.usb --timeout=2" >>/etc/auto.master
fi
if grep $drive /etc/auto.usb >/dev/null 2>&1 ; then
   echo "Looks like /dev/$drive is already in auto.usb"
else
   echo "Adding /dev/$drive to auto.usb"
   [ -f /etc/auto.usb ] && cp /etc/auto.usb /etc/auto.usb.orig
   echo "$drive -fstype=vfat,uid=1002,gid=1002,umask=002,noatime :/dev/$drive" >
>/etc/auto.usb
fi

ln -s /var/autofs/usb/$drive $mntpoint
ln -s $mntpoint /myth/gallery/usb
ln -s $mntpoint /myth/music/usb
ln -s $mntpoint /myth/video/usb

/etc/init.d/autofs restart

_________________
cesman

When the source is open, the possibilities are endless!


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 25, 2006 9:51 am 
Offline
Joined: Thu Mar 25, 2004 11:00 am
Posts: 9551
Location: Arlington, MA
I'd thought about looking at the output of dmesg or /var/log/messages for "sd" devices, but had opted to leave it manual so that the timing of when the drives were plugged in or how many you plugged in wasn't an issue. Say if you have a couple external USB HDs which are normally plugged in when you power up, or if you wanted to setup so that when you do plug in the drive later (say in another room) it would be recognized. On the other hand, this actually makes my intended use easier... ;-)

Of course automatically recognizing and mounting the drive the first time it's plugged in is even better. :D


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 26, 2006 2:13 pm 
Offline
Joined: Thu Mar 25, 2004 11:00 am
Posts: 9551
Location: Arlington, MA
Looks like the autodetection in that second version of the script is broken. I'll get back to you with a fix ASAP.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 11, 2006 7:24 am 
Offline
Joined: Fri Mar 03, 2006 8:45 pm
Posts: 7
When I try the script I get the following message...

root@mythtv:~# ./check
Please insert USB key and press <ENTER>.

Just a sec...
Trying to determine location of USB key.
Error: mount point '/mnt/' already exists!

--Proto


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 11, 2006 6:44 pm 
Offline
Joined: Thu Mar 25, 2004 11:00 am
Posts: 9551
Location: Arlington, MA
Try this more recent version:
Code:
#!/bin/bash
if [ $(id -u) != 0 ] ; then
    echo "Error: You must be root to run this script!"
    exit 4
fi
if grep ^/var/autofs/usb /etc/auto.master >/dev/null ; then
    echo "Looks like there is already a USB storage hook in auto.master"
else
    echo "Adding a USB storage hook to auto.master"
    cp /etc/auto.master /etc/auto.master.orig
    echo "/var/autofs/usb /etc/auto.usb --timeout=2" >>/etc/auto.master
fi
echo "Please insert USB key and press <ENTER>."
read
echo "Just a sec..."
echo "Trying to determine location of USB key."
sleep 7
drives=$(dmesg | awk '/Attached scsi removable disk sd/ {print $7}' | sort -u)
for drive in $drives ; do
  mntpoint=/mnt/$drive
  mntparent=$(dirname $mntpoint)
  if [ ! -d "$mntparent" ] ; then
    echo "Error: Parent of mount point '$mntpoint' is not a directory!"
    exit 2
  elif [ -L "$mntpoint" ] ; then
    rm $mntpoint
  elif [ -e "$mntpoint" ] ; then
    echo "Error: mount point '$mntpoint' already exists!"
    exit 2
  fi
  if grep ^$drive /etc/auto.usb >/dev/null 2>&1 ; then
   echo "Looks like /dev/$drive is already in auto.usb"
  else
   echo "Adding /dev/$drive to auto.usb"
   [ -f /etc/auto.usb ] && cp /etc/auto.usb /etc/auto.usb.orig
   echo "$drive -fstype=vfat,uid=1002,gid=1002,umask=002,noatime :/dev/$drive" >>/etc/auto.usb
  fi
  ln -s /var/autofs/usb/$drive $mntpoint
done

/etc/init.d/autofs restart

This still could use a few enhancements but it should work a bit better.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 13, 2006 9:06 pm 
Offline
Joined: Mon Mar 21, 2005 1:43 pm
Posts: 388
Location: Nanaimo BC
Ok I tried the newest script to mount a usb harddrive

it seems to mount under /var/autofs/usb

If I try to create a directory as root I get a permission denied.

The permisions on /var/autofs/usb are 755

Any suggestions as to what may be going on.

Also look for my thread on mount points.

Craig


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 13, 2006 10:03 pm 
Offline
Joined: Thu Mar 25, 2004 11:00 am
Posts: 9551
Location: Arlington, MA
That's because /var/autofs/usb isn't a normal filesystem. Try running the mount command with no arguments and notice that instead of a device it's associated with a process. Why do you think you need to create a directory? The automounter does that for you based on what is in the auto.XXX file. Once you've run that script you should be able to refer to the symbolic link it sets up and see/modify the drives contents. You may need to comment out this line:
Code:
#/mnt/auto       /etc/automount.sh       --timeout=2

in /etc/auto.master, as Cecil shows in his original directions, but other than that it, it should just work.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 13, 2006 10:43 pm 
Offline
Joined: Mon Mar 21, 2005 1:43 pm
Posts: 388
Location: Nanaimo BC
Fortunately I am comfortable feeling like an Idiot.

If I am understanding it correctly I should be able to cd to /mnt/usb

when I try I get
root@mythtv:/# cd /mnt/usb
-bash: cd: /mnt/usb: No such file or directory

My auto.usb file is

# Format of file:
# mountpoint options device
#sda -fstype=vfat,uid=1002,gid=1002,umask=002,noatime :/dev/sda1
sda -fstype=ext3,uid=1002,gid=1002,umask=002,noatime :/dev/sda1
#sdb -fstype=vfat,uid=1002,gid=1002,umask=002,noatime :/dev/sdb1
sdc -fstype=vfat,uid=1002,gid=1002,umask=002,noatime :/dev/sdc1
#sdd -fstype=vfat,uid=1002,gid=1002,umask=002,noatime :/dev/sdd1



my auto.master is

# $Id: auto.master,v 1.2 1997/10/06 21:52:03 hpa Exp $
# Sample auto.master file
# Format of this file:
# mountpoint map options
# For details of the format look at autofs(5).
# /var/autofs/misc /etc/auto.misc
# /var/autofs/net /etc/auto.net
# KNOPPIX automounts for floppy and cdrom(s), see knoppix-autoconfig
/mnt/auto /etc/auto.mnt --timeout=2
#/mnt/removable auto.removable
/var/autofs/usb /etc/auto.usb --timeout=2
#/mnt/auto /etc/automount.sh --timeout=2

seems to be correct. Am I misunderstanding where the mount point is?

Craig


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 14, 2006 10:12 am 
Offline
Joined: Thu Mar 25, 2004 11:00 am
Posts: 9551
Location: Arlington, MA
iscraigh wrote:
If I am understanding it correctly I should be able to cd to /mnt/usb

Only if you created that as a symbolic link.
iscraigh wrote:
My auto.usb file is

- Comment out the line for sdc.

- Unplug and replug your USB drive.

- Go look in /var/log/messages for how it was recognized and hopefully mounted. This should be as "/dev/sda".

- Look at the /mnt directory - ls -al /mnt the script should have set up a /mnt/sda link there.

- Use that link to access the device. You can create any other links to the same target that you want.


Top
 Profile  
 

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 24 posts ] 
Go to page 1, 2  Next



All times are UTC - 6 hours




Who is online

Users browsing this forum: No registered users and 13 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group

Theme Created By ceyhansuyu