# mounting a usb key

## sidkdbl07

I feel a little bit sheepish asking this question,   :Embarassed: 

I have installed usbfs into my kernel and when I plug a usb key into the port and I can see that it has been recognized by doing a dmesg....

How do I get my files? Do I have to mount the usb key?

----------

## d_m

Yes you do ;)

If you see that it has been recognized, then you should see that it has been mapped to some device (/dev/sda or something). Just try mounting that. An example command might be something like this:

```
# create /mnt/usbkey if it doesn't exist

mkdir /mnt/usbkey

mount /dev/sda1 /mnt/usbkey

```

Good luck. If you have more problems, try posting relevant parts of dmesg.

----------

## sidkdbl07

Here are the relevant parts of dmesg...

 *Quote:*   

> usb 1-2: new high speed USB device using ehci_hcd and address 2
> 
> scsi0 : SCSI emulation for USB Mass Storage devices
> 
> usb-storage: device found at 2
> ...

 

When I try 

mount /dev/sg0 /mnt/usb

or

mount -t vfat /dev/scsi/host0/bus0/target0/lun0/generic /mnt/usb/

I get the following message....

 *Quote:*   

> mount: /dev/<...> is not a block device

 

----------

## pjp

 *sidkdbl07 wrote:*   

> When I try 
> 
> mount /dev/sg0 /mnt/usb
> 
> or
> ...

 How 'bout mount -t vfat /dev/sg0 /mnt/usb or mount -t auto /dev/sg0 /mnt/usb?

----------

## sidkdbl07

I saw that USB stuff was poo poo using devfs with the 2.6 kernel so I changed to udev and now I can mount the usbkey.

One more issue...

I want regular users to be able to mount and unmount keys so I made the following entry in /etc/fstab

 *Quote:*   

> /dev/sda1               /mnt/usb        auto            user,noauto,umask=777   0 0

 

I can mount the key without trouble but the permissions are wierd

 *Quote:*   

>  -> ls -al /mnt/
> 
> ...
> 
> d-wxr--r--   2 sid users  48 May  4 11:09 usb
> ...

 

How do I get everone full access... or at least read/write access to the drive?

The octal 777 should give me all access, no?

----------

## pilo

I think there is a suid-bit in permissions, so you would have to write 0777.

Good luck.

----------

## Gentree

seems to be the same thing here.

```
bash-3.00#mount -t auto /dev/sg1 /mnt/usb

mount: /dev/sg1 is not a block device

```

when I plug in the device I can see it with usbview is <USB PRODUCT>

Hwvr, 

```
mount /t vfat /dev/sda1 /mnt/usb 
```

 does work.

Using -t auto mounts it with DOS 8.3 filenames with ~ everywhere.

Try  ls /dev/s*  and see what devices are there.

HTH  :Cool: 

[Sorry , too late, two new posts while I was checking this out.]

----------

## Gentree

```
bash-3.00#ls /mnt/usb -ail

total 118890

    1 d---------  2 root root   16384 Jan  1  1970 .

30737 drwxr-xr-x  8 root root     216 May  5 21:59 ..

  369 ----------  1 root root 4954481 Apr 28 01:05 01 - Dance with me.mp3

  363 ----------  1 root root 3344512 Apr 12 00:05 01-AudioTrack 01.mp3

  354 ----------  1 root root 6104515 Jun 12  2004 02 Haiducii - Dragostea Din Tei.mp3

```

Oops, didnot like 0777 much ! Shouldn't that mask be umask=000 ?

Using

```
/dev/sda1           /mnt/usb      vfat        user,noauto 0 0
```

allows me to mount from a user account and play the tracks. Replacing user by users allows a different user to umount it later.

 eg:

```
  296 ----------  1 prof users 3215446 Apr 23 17:34 human ressource.mp3

```

 :Cool: 

----------

## Mark Xap

I'll happily be corrected on this but wouldn't hotplug/coldplug sort this out without the need for fstab entries and mount commands?

----------

## Gentree

in what context would you expect hotplug to mount device?

----------

## Mark Xap

As I said, I'm open for correction.

http://www.gentoo.org/doc/en/udev-guide.xml

----------

## pilo

Hmm, I was sure I used 0777 on my NTFS-partitions, but I also used uid and gid to specify ownership.

It seems 000 is the way to go, since the permissions are inverted.  :Embarassed: 

----------

## riskable

Oh my!  There's a lot easier way to do all this...

If you're running at least kernel 2.6.10, emerge the following:

```
emerge hal dbus
```

Now, if you're using KDE 3.4, in konqueror type, "media:/" and it'll show you a list of all your connected devices.  Your USB drive should show up in the list and you can open it up just like you'd expect.

If you're using gnome (and whatever the hell it is you need to get it working with hal), it should actually pop up a message asking you what you want to do with the inserted drive (like Windows).

If you're using something else (or you want pretty messages in KDE when something is plugged in)...

```
emerge ivman
```

ivman is an amazingly flexible daemon that you can configure to do whatever the hell you want when a new device shows up in your system.  I have mine setup to do all sorts of neat things (synchronizes my USB drive with /home/riskable/Documents whenever I insert it).

More info on ivman can be found here:  http://ivman.sourceforge.net

----------

## sidkdbl07

I ended up switching to udev and now everything works.

----------

## jswilsonwilson

 *sidkdbl07 wrote:*   

> I ended up switching to udev and now everything works.

 

What udev permissions & rules do you use to make everything work?

----------

## Jeze

when I plug my usb key in I get this error msg:

```
usb 1-6: new high speed USB device using ehci_hcd and address 3

usb 4-2: new full speed USB device using uhci_hcd and address 2

usb 4-2: device descriptor read/64, error -71

usb 4-2: device descriptor read/64, error -71
```

any ideas?

----------

## Jeze

If I have the key plugged into the port at bootup I get this:

```
Initializing USB Mass Storage driver...

usb 2-1: new low speed USB device using uhci_hcd and address 2

input: USB HID v1.10 Mouse [Logitech USB Receiver] on usb-0000:00:10.0-1

scsi4 : SCSI emulation for USB Mass Storage devices

usbcore: registered new driver usb-storage

USB Mass Storage support registered.

usb-storage: device found at 3

usb-storage: waiting for device to settle before scanning

eth0: network connection down

devfs_mk_dev: could not append to parent for vcc/3

devfs_mk_dev: could not append to parent for vcc/a3

devfs_mk_dev: could not append to parent for vcc/4

devfs_mk_dev: could not append to parent for vcc/a4

devfs_mk_dev: could not append to parent for vcc/5

devfs_mk_dev: could not append to parent for vcc/a5

  Vendor: Generic   Model: USB Flash Disk    Rev: 2.00

  Type:   Direct-Access                      ANSI SCSI revision: 02

SCSI device sdc: 511488 512-byte hdwr sectors (262 MB)

sdc: assuming Write Enabled

sdc: assuming drive cache: write through

SCSI device sdc: 511488 512-byte hdwr sectors (262 MB)

sdc: assuming Write Enabled

sdc: assuming drive cache: write through

 /dev/scsi/host4/bus0/target0/lun0: unknown partition table

Attached scsi removable disk sdc at scsi4, channel 0, id 0, lun 0

Attached scsi generic sg4 at scsi4, channel 0, id 0, lun 0,  type 0

usb-storage: device scan complete

```

yet, when I try to mount I get:

```
mount -t vfat /dev/sdc /mnt/usbkey

mount: unknown filesystem type 'vfat'

```

or:

```
mount /dev/sdc /mnt/usbkey

mount: unknown filesystem type 'msdos'

```

* if I plug the key once the system is up I get the dmesg output from the previous post....

----------

## yetihehe

But what if it can't mount it?

```
yeti root # dmesg | tail

usb 1-2: USB disconnect, address 2

usb 1-2: new high speed USB device using address 3

scsi1 : SCSI emulation for USB Mass Storage devices

  Vendor: Kingston  Model: DataTraveler 2.0  Rev: 1.04

  Type:   Direct-Access                      ANSI SCSI revision: 02

Attached scsi generic sg0 at scsi1, channel 0, id 0, lun 0,  type 0

USB Mass Storage device found at 3
```

But when I try to mount it:

```
yeti root # mount /dev/sg0 /mnt/usb

mount: /dev/sg0 is not a block device
```

dev:

```
yeti root # ls /dev/s*

/dev/sbpcd   /dev/scd2   /dev/sda14  /dev/sdb12  /dev/sdc10  /dev/sdd    /dev/sdd8        /dev/sg3      /dev/sr0   /dev/sr7

/dev/sbpcd0  /dev/scd3   /dev/sda15  /dev/sdb13  /dev/sdc11  /dev/sdd1   /dev/sdd9        /dev/sg4      /dev/sr1   /dev/sr8

/dev/sbpcd1  /dev/scd4   /dev/sda2   /dev/sdb14  /dev/sdc12  /dev/sdd10  /dev/sequencer   /dev/sg5      /dev/sr10  /dev/sr9

/dev/sbpcd2  /dev/scd5   /dev/sda3   /dev/sdb15  /dev/sdc13  /dev/sdd11  /dev/sequencer2  /dev/sg6      /dev/sr11  /dev/st0

/dev/sbpcd3  /dev/scd6   /dev/sda4   /dev/sdb2   /dev/sdc14  /dev/sdd12  /dev/sg0         /dev/sg7      /dev/sr12  /dev/st0a

/dev/scd0    /dev/scd7   /dev/sda5   /dev/sdb3   /dev/sdc15  /dev/sdd13  /dev/sg1         /dev/sg8      /dev/sr13  /dev/st0l

/dev/scd1    /dev/scd8   /dev/sda6   /dev/sdb4   /dev/sdc2   /dev/sdd14  /dev/sg10        /dev/sg9      /dev/sr14  /dev/st0m

/dev/scd10   /dev/scd9   /dev/sda7   /dev/sdb5   /dev/sdc3   /dev/sdd15  /dev/sg11        /dev/sjcd     /dev/sr15  /dev/st1

/dev/scd11   /dev/sda    /dev/sda8   /dev/sdb6   /dev/sdc4   /dev/sdd2   /dev/sg12        /dev/smpte0   /dev/sr16  /dev/st1a

/dev/scd12   /dev/sda1   /dev/sda9   /dev/sdb7   /dev/sdc5   /dev/sdd3   /dev/sg13        /dev/smpte1   /dev/sr2   /dev/st1l

/dev/scd13   /dev/sda10  /dev/sdb    /dev/sdb8   /dev/sdc6   /dev/sdd4   /dev/sg14        /dev/smpte2   /dev/sr3   /dev/st1m

/dev/scd14   /dev/sda11  /dev/sdb1   /dev/sdb9   /dev/sdc7   /dev/sdd5   /dev/sg15        /dev/smpte3   /dev/sr4   /dev/stderr

/dev/scd15   /dev/sda12  /dev/sdb10  /dev/sdc    /dev/sdc8   /dev/sdd6   /dev/sg16        /dev/sndstat  /dev/sr5   /dev/stdin

/dev/scd16   /dev/sda13  /dev/sdb11  /dev/sdc1   /dev/sdc9   /dev/sdd7   /dev/sg2         /dev/sonycd   /dev/sr6   /dev/stdout
```

I have udev, but not configured.

----------

## yetihehe

Sorry, I have just tried /dev/sda1 and it works.

----------

## fb

 *Jeze wrote:*   

> If I have the key plugged into the port at bootup I get this:
> 
> ```
> Initializing USB Mass Storage driver...
> 
> ...

 

Try:

```
mount -t vfat /dev/sdc1 /mnt/usbkey
```

notice sdc1. I had the strange message "device descriptor read/64, error -71"

on a regular basis. My usb stick has a "lock" switch which I suspect may be partly

to blame. Usually after trying to unplug it and repluging it a few time (and toying with

the lock as well) I got through. Most of the time I had to do "touch /dev/sda" (in your

case it would be /dev/sdc) before mounting.

I have switched to kernel 2.6.11 and hal, dbus and ivman and all those warning have

disapeared. I have a few new ones and at the moment my stick is unusable on this

computer (x86 PC with usb2 plugs, on all the mac I tried it works flawlessly and on

my linux ppc install too (gentoo as well but only usb1.1) I never had any trouble.).

hope that helps.

----------

