LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-16-2010, 11:32 AM   #16
fopetesl
Member
 
Registered: Jan 2005
Location: Yorkshire Dales, UK
Distribution: Ubuntu 5.10; Mandriva 2007; Debian Lenny
Posts: 147

Original Poster
Rep: Reputation: 15
Exclamation


Quote:
Originally Posted by catkin View Post
When I dabbled with automount and it automounted file systems they were listed by df. Could it be that the automounting is not working? Can you post the content of /etc/auto.master and the /etc/auto.* files listed in it, presumably including (maybe only) /etc/auto.vol?
Oh the USB drive gets mounted alright since I use it quite a lot and it's never failed.
/etc/auto.vol:
Code:
#
# $Id: auto.vol,v 1.2 2003/09/29 08:22:35 raven Exp $
#
# This is an automounter map and it has the following format
# key [ -mount-options-separated-by-comma ] location
# Details may be found in the autofs(5) manpage

FLOPPY		-fstype=vfat,rw,sync,umask=002 		:/dev/fd0
CD_DVD		-fstype=iso9660,rw,nosuid,nodev    	:/dev/cdrom
USBDISKA	-fstype=vfat,rw,gid=100,umask=002	:/dev/sda1
USBDISKB 	-fstype=vfat,rw,gid=100,umask=002	:/dev/sdb1
USBDISKC 	-fstype=vfat,rw,gid=100,umask=002	:/dev/sdc1

# the following entries are samples to pique your imagination
#linux		-ro,soft,intr		ftp.example.org:/pub/linux
#boot		-fstype=ext2		:/dev/hda1
#floppy		-fstype=ext2		:/dev/fd0
#e2floppy	-fstype=ext2		:/dev/fd0
#jaz		-fstype=ext2		:/dev/sdc1
#removable	-fstype=ext2		:/dev/hdd
/etc/auto.net:
Code:
#!/bin/sh

# $Id: auto.net,v 1.5 2003/09/29 08:22:35 raven Exp $

# Look at what a host is exporting to determine what we can mount.
# This is very simple, but it appears to work surprisingly well

key="$1"

# add "nosymlink" here if you want to suppress symlinking local filesystems
# add "nonstrict" to make it OK for some filesystems to not mount
opts="-fstype=nfs,hard,intr,nodev,nosuid,nonstrict,rsize=8192,wsize=8192,async"

# Showmount comes in a number of names and varieties.  "showmount" is
# typically an older version which accepts the '--no-headers' flag
# but ignores it.  "kshowmount" is the newer version installed with knfsd,
# which both accepts and acts on the '--no-headers' flag.
#SHOWMOUNT="kshowmount --no-headers -e $key"
#SHOWMOUNT="showmount -e $key | tail +2"

# Newer distributions get this right
SHOWMOUNT="/sbin/showmount --no-headers -e $key"

$SHOWMOUNT | LC_ALL=C sort +0 | \
	awk -v key="$key" -v opts="$opts" -- '
	BEGIN		{ ORS=""; first=1 }
			{ if (first) { print opts; first=0 }; print " \\\n\t" $1, key ":" $1 }
	END		{ if (!first) print "\n"; else exit 1 }
	'
The others auto.master and auto.misc are pretty much comments.
 
Old 04-16-2010, 11:58 PM   #17
pielas
Member
 
Registered: Jan 2009
Location: Poland
Distribution: Arch Linux
Posts: 50

Rep: Reputation: 17
Maybe use output of /proc/mounts would works.
 
Old 04-17-2010, 04:43 AM   #18
fopetesl
Member
 
Registered: Jan 2005
Location: Yorkshire Dales, UK
Distribution: Ubuntu 5.10; Mandriva 2007; Debian Lenny
Posts: 147

Original Poster
Rep: Reputation: 15
Question

Quote:
Originally Posted by pielas View Post
Maybe use output of /proc/mounts would works.
/proc/mounts links to /proc/~self/6448:
Code:
rootfs / rootfs rw 0 0
none /dev ramfs rw 0 0
/dev/sda1 / ext3 rw,data=ordered 0 0
/dev/sda1 /dev/.static/dev ext3 rw,data=ordered 0 0
proc /proc proc rw 0 0
sysfs /sys sysfs rw 0 0
usbfs /proc/bus/usb usbfs rw 0 0
devpts /dev/pts devpts rw 0 0
tmpfs /dev/shm tmpfs rw 0 0
automount(pid5988) /vol autofs rw,fd=4,pgrp=5988,timeout=4,minproto=2,maxproto=4,indirect 0 0
/dev/sdb1 /vol/USBDISKB vfat rw,gid=100,fmask=0002,dmask=0002,codepage=cp437,iocharset=iso8859-1 0 0
also exact copy in /etc/mtab
 
Old 04-17-2010, 09:15 AM   #19
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 250Reputation: 250Reputation: 250
Well if auto.vol always maps USBDISKB to /dev/sdb1 you can test for a block device on /dev/sdb1 similar to my original comment

Code:
if [ -b /dev/sdb1 ]

Last edited by smoker; 04-17-2010 at 09:21 AM.
 
Old 04-17-2010, 09:41 AM   #20
fopetesl
Member
 
Registered: Jan 2005
Location: Yorkshire Dales, UK
Distribution: Ubuntu 5.10; Mandriva 2007; Debian Lenny
Posts: 147

Original Poster
Rep: Reputation: 15
Question

Code:
#!/bin/bash
if [ -b /dev/sdb1 ]; then
 echo "Found the device"
else
 echo "Not found: block device!"
fi
Code:
~# ./bashtest
Found the device
So that works but this doesn't
Code:
#!/bin/bash
if [ -b /vol/USBDISKB ]; then
 echo "Found the device"
else
 echo "Not found: block device!"
fi
but
Code:
 ~# ls /vol/USBDISKB
still shows files and directories.

So. You are suggesting only to check for /dev/sdx1?

If /dev/sdb1 is a block device, what is /vol/USBDISKB?
 
Old 04-17-2010, 10:16 AM   #21
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 250Reputation: 250Reputation: 250
Essentially a mount point I guess. And a mount point isn't a block device, it's at the filesystem level, which is why ls works.

i.e.

I have a directory called voice on my usbdisk, I can run ls /media/usbdisk/voice fine, but ls /dev/sde1/voice returns "not a directory".

The only problem I can see with your situation is that sdx is usually used for SATA disks( and SCSI), so if you add a SATA disk to the system your mapping may pick up the wrong disk.
 
Old 04-17-2010, 10:32 AM   #22
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Helpful observations, smoker

But the OP reported this code not working
Code:
#!/bin/bash
 if [ -d /vol/USBDISKB ]; then
   echo "Found USB drive"
 else
   echo "Not found: USB drive!"
 fi
I just tested some mount points and bash tests for them being directories do work
Code:
c@CW8:~$ [[ -d / ]] && echo true || echo false
true
c@CW8:~$ [[ -d /var ]] && echo true || echo false
true
c@CW8:~$ [[ -d /srv/bacula ]] && echo true || echo false
true
 
Old 04-17-2010, 10:50 AM   #23
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 250Reputation: 250Reputation: 250
I realise it didn't work on his system. But it works fine on mine so there is some other issue that prevents it being seen as a directory in his case. I did suggest trying to test for a sub-directory of /vol/USBDISKB , I don't know whether the OP tried that or not.

I should say that I've concentrated on getting the script to work, rather than figuring out why it doesn't in the original format.

Last edited by smoker; 04-17-2010 at 10:53 AM.
 
Old 04-17-2010, 10:59 AM   #24
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by smoker View Post
I realise it didn't work on his system. But it works fine on mine so there is some other issue that prevents it being seen as a directory in his case. I did suggest trying to test for a sub-directory of /vol/USBDISKB , I don't know whether the OP tried that or not.

I should say that I've concentrated on getting the script to work, rather than figuring out why it doesn't in the original format.
Understood. It might be worth running stat /vol/USBDISKB and file /vol/USBDISKB. too.
 
Old 04-17-2010, 11:49 AM   #25
fopetesl
Member
 
Registered: Jan 2005
Location: Yorkshire Dales, UK
Distribution: Ubuntu 5.10; Mandriva 2007; Debian Lenny
Posts: 147

Original Poster
Rep: Reputation: 15
Exclamation

Quote:
Originally Posted by catkin View Post
Understood. It might be worth running stat /vol/USBDISKB and file /vol/USBDISKB. too.
~# stat /vol/USBDISKB
Code:
  File: `/vol/USBDISKB'
  Size: 12288     	Blocks: 24         IO Block: 4096   directory
Device: 811h/2065d	Inode: 1           Links: 47
Access: (0775/drwxrwxr-x)  Uid: (    0/    root)   Gid: (  100/   users)
Access: 1970-01-01 01:00:00.000000000 +0100
Modify: 1970-01-01 01:00:00.000000000 +0100
Change: 1970-01-01 01:00:00.000000000 +0100
Where did those timestamps come from??

~# file /vol/USBDISK
Code:
/vol/USBDISKB: directory

Last edited by fopetesl; 04-17-2010 at 11:51 AM. Reason: Added a query
 
  


Reply



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
[SOLVED] Using a long Bash command including single quotes and pipes in a Bash script antcore Linux - General 9 07-22-2009 11:10 AM
website blocker that can't be defeated by admin? newbiesforever Linux - Software 8 11-16-2008 08:54 PM
BASH -copy stdin to stdout (replace cat) (bash browser) gnashley Programming 4 07-21-2008 01:14 PM
why did bash 2.05b install delete /bin/bash & "/bin/sh -> bash"? johnpipe Linux - Software 2 06-06-2004 06:42 PM
reward (ive been defeated by linux) engineer55 Linux - Networking 45 06-27-2003 12:24 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:54 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