# How to mount an usb memory stick?

## seteh

First of all: hi everyone, this is my first post. And sorry if I'm bringing up a topic that has already been discussed - searching didn't help me. 

I'm trying to get my usb memory stick to work under Gentoo. I'm using kernel-2.6.7-gentoo-r8. This is what I get in /var/log/messages when I plug the stick in:

Jul 24 12:39:22 xxx usb 1-5: new high speed USB device using address 2

Jul 24 12:39:22 xxx Initializing USB Mass Storage driver...

Jul 24 12:39:22 xxx scsi0 : SCSI emulation for USB Mass Storage devices

Jul 24 12:39:22 xxx Vendor: SanDisk   Model: Cruzer Mini       Rev: 0.1

Jul 24 12:39:22 xxx Type:   Direct-Access                      ANSI SCSI revision: 02

Jul 24 12:39:22 xxx Attached scsi generic sg0 at scsi0, channel 0, id 0, lun 0,  type 0

Jul 24 12:39:22 xxx USB Mass Storage device found at 2

Jul 24 12:39:22 xxx usbcore: registered new driver usb-storage

Jul 24 12:39:22 xxx USB Mass Storage support registered.

Jul 24 12:39:22 xxx scsi.agent[7166]: disk at /devices/pci0000:00/0000:00:10.3/usb1/1-5/1-5:1.0/host0/0:0:0:0

So as far as I can tell, it seems to be recognized. But now, how do I mount/access it? Thanks for your help.

----------

## sireyessire

 *seteh wrote:*   

> 
> 
> Jul 24 12:39:22 xxx scsi0 : SCSI emulation for USB Mass Storage devices
> 
> Jul 24 12:39:22 xxx Vendor: SanDisk   Model: Cruzer Mini       Rev: 0.1
> ...

 

As you can read, linux uses a scsi emulation to deal with usb key. Fortunately your kernel seems to be well configured to recognize usbkey as scsi device. Now you have to mount it with: 

```
# mkdir /mnt/usbkey

# mount /dev/sdg0 /mnt/usbkey
```

NB : # means you have to be root

But  you should first check if your kernel can deal with the filesystem of your key (fat i think).

then you can enjoy your key.  :Mr. Green: 

If you want  users to use freely the usbkey you have to dive into /etc/fstab to configure it  :Wink: 

----------

## seteh

```
# mkdir /mnt/usbkey

# mount /dev/sdg0 /mnt/usbkey
```

There's no /dev/sdg0. There is /dev/sg0 but trying to mount it I get "mount: /dev/sg0 is not a block device". 

What am I missing here?

----------

## bennettp

Try /dev/sda1.

I'm assuming you use devfs (the default/easiest option). When the kernel detects your usb drive, devfs will allocate the next available device node. If there are no other scsi devices, then this will be /dev/sda1.

So try # mount /dev/sda1 /mount/point

If you have other scsi devices, then try others: /dev/sdb1, sdc1, etc.

----------

## bennettp

Also, my usb pen drive doesn't have a partition table (the 1 in sda1 refers to the partition number), so i need to mount mine using /dev/sda. If you have any trouble with sda1 (or sdb1, etc), try mounting sda (or sdb, etc).

Also, make sure you unmount the drive before you unplug it, otherwise the /dev/ entry will be stuck there. Until you reboot. Its a bug in devfs, which, as far as I know, can only be fixed by switching to udev.

----------

## ctford0

 *bennettp wrote:*   

> Also, my usb pen drive doesn't have a partition table (the 1 in sda1 refers to the partition number), so i need to mount mine using /dev/sda. If you have any trouble with sda1 (or sdb1, etc), try mounting sda (or sdb, etc).

 

This is also a bug because sdax relates to a device number not a partition.  My HP printers photo card reader is sda1 where as my usb zip drive is always sda4.  BTW, the I've had the zip driver longer than the printer and it has always been sda4 so devfs somehow relates it to the device type.

EDIT:  Not getting the correct device number could also be lack of usbfs support.  I've never really messed with it enough to know if it's a bug in devfs or lack of usbfs support.

chris

----------

## seteh

Ok, I finally got it to work. There was still some scsi stuff missing from the kernel. Now i have one reason less to use windows  :Razz: 

----------

## bennettp

 *ctford0 wrote:*   

>  *bennettp wrote:*   Also, my usb pen drive doesn't have a partition table (the 1 in sda1 refers to the partition number), so i need to mount mine using /dev/sda. If you have any trouble with sda1 (or sdb1, etc), try mounting sda (or sdb, etc). 
> 
> This is also a bug because sdax relates to a device number not a partition.  My HP printers photo card reader is sda1 where as my usb zip drive is always sda4.  BTW, the I've had the zip driver longer than the printer and it has always been sda4 so devfs somehow relates it to the device type.
> 
> EDIT:  Not getting the correct device number could also be lack of usbfs support.  I've never really messed with it enough to know if it's a bug in devfs or lack of usbfs support.
> ...

 

Are you sure about this? My pen drive has no partition table. So I need to mount /dev/sda. However, I've used a friends pen drive, that DID have a partition table, and I had to mount /dev/sda1. Edit: actually, now that I think about it, I don't know if it had a partition table...

Also, on the linux computers at uni, I need to mount my usb drive as /dev/sda, NOT /dev/sda1.

----------

## bennettp

 *seteh wrote:*   

> Ok, I finally got it to work. There was still some scsi stuff missing from the kernel. Now i have one reason less to use windows 

 

Nice one  :Smile: 

Now try udev  :Smile: 

----------

## Ox53746F6E65

maybe you would like to make a entry in your /etc/fstab file, so that you are able to mount your usb-stick with mount /mnt/usbstick or you can create a usb-link on your desktop.

see therefor the usb-stick how-to

https://forums.gentoo.org/viewtopic.php?t=53537&highlight=usb+stick

----------

## ctford0

 *bennettp wrote:*   

> 
> 
> Are you sure about this? My pen drive has no partition table. So I need to mount /dev/sda. However, I've used a friends pen drive, that DID have a partition table, and I had to mount /dev/sda1. Edit: actually, now that I think about it, I don't know if it had a partition table...
> 
> Also, on the linux computers at uni, I need to mount my usb drive as /dev/sda, NOT /dev/sda1.

 

Well I cant even get my usb zip working on my 2.4 system without a reboot  :Embarassed: .  When it does work though it is seen as sda4.  I've been pretty busy the past couple of days but I'm gonna take some time this morning and try to setup usbfs and see if that makes a difference.  I'll let you know my findings

chris

----------

## ctford0

Well, setup usbfs (aka. usbdevfs on 2.4) and there is basically no difference.  I noticed when i rebooted with the zip plugged in that it was actually setting it up as sdb  :Embarassed:  and not sda anything because of the reason mentioned previoiusly in this thread.  However, I still have the problem of needing to mount /dev/sdb before devfs creates the /dev/sdb4 device.

```

bash-2.05b# ls /dev/sd*

/dev/sda  /dev/sdb

bash-2.05b# mount /dev/sdb /mnt/zip/

mount: you must specify the filesystem type

bash-2.05b# ls /dev/sd*

/dev/sda  /dev/sdb  /dev/sdb4

```

So it must be either the "Preliminary" support in the 2.4 kernel for usbfs or devfs itself.  I do not have this behavior on my laptop running 2.6.7 gentoo and udev.  Upon pluggin in the zip drive /dev/sda4 is created for me.

Chris

----------

## flickerfly

 *seteh wrote:*   

> Ok, I finally got it to work. There was still some scsi stuff missing from the kernel. Now i have one reason less to use windows 

 

What SCSI stuff were you missing?

----------

