# Problem with USB-Stick

## koelle

Hey there,

somehow i screwed up my usb stick. I once forgot to umount it. Now it's always getting mounted "read-only". I can't copy files to it or remove files from it....;(

I don't know how to fix this. Here's my fstab-section:

/dev/sda1		/mnt/usb1	vfat		noauto,user,exec,rw		0 0

Can someone help me?

thanks, koelle

----------

## tuam

Can you

- unplug the stick

- plug it in

- mount it

- try to copy fiels to it

and then post the messages from dmesg?

FF,

 Daniel

----------

## koelle

It still says that it's a read-only device. Here's the output of dmesg:

 *Quote:*   

> 
> 
> ialized
> 
> Linux Kernel Card Services
> ...

 

----------

## plegault

emerge dosfstools

$ dosfsck -a /dev/sda1 (for automatic repair)

$ dosfsck -r /dev/sda1 (for interactive repair)

----------

## koelle

I just remember another problem with my usb-stick. (it's not really a problem, but i believe there is a better way to handle this) So i have "usb-utils" and also "hotplug" emerged. 

In /etc/fstab i have the following line:

 *Quote:*   

> 
> 
> usbfs			/proc/bus/usb	usbfs		noauto			0 0
> 
> 

 

I now want to mount my usb-stick to /mnt/usb. I could'nt find another way than writing this into /etc/fstab:

 *Quote:*   

> 
> 
> /dev/sda1		/mnt/usb1	vfat		noauto,user,exec,rw		0 0
> 
> 

 

My problem is that the stick (and also camera) is not always "sda1". Sometimes it's "sdb1" or "sdc1". So i added to more lines to /etc/fstab:

 *Quote:*   

> 
> 
> /dev/sdb1		/mnt/usb2	vfat		noauto,user,exec,rw		0 0
> 
> /dev/sdc1		/mnt/usb3	vfat		noauto,user,exec,rw	0 0
> ...

 

Is there a method to tell usb-utils and/or hutplug to automatically generate those lines in /etc/fstab and the folders and delete them after umonting the device?

Hope somebody can help me..

greetings koelle

----------

## dsd

you could use udev to create a persistent name for the device

----------

## koelle

Hi,

thanks for your help. I think it works again. I could remove files anyway.... :Wink: 

I needed to use the -r option. With the -a option it didn't work.

greetings koelle

----------

## koelle

Hi,

i got a problem creating a persistent device for my usb-stick. First i ran "udevinfo" to get the model-name. Here's my code for creating a device:

```

udev BUS="usb", SYSFS{model}="TS128MJFLASHA", KERNEL="sd?1", NAME="%k", SYMLINK="/mnt/usb"

```

I now commented all lines in my /etc/fstab which pointed to /dev/sda1 /dev/sdb1 etc.

Should not gentoo create the line in /etc/fstab automatically? In SuSe this line was added automatically, but not with Gentoo...

Can someone help me?

I want mount my usb-stick to /mnt/usb. When it's plugged in it should always be named /dev/sd?1, so sda1, sdb1 etc...

greetings koelle

----------

## dsd

no, "gentoo" doesnt really do much automatically - you have to ask it to. find out which bit of software suse uses to auto-update fstab and chances are its available in portage.

you have misunderstood how to use udev to combat this situation though. you use a udev rule to create something like "/dev/usbflashdisk" and then you put a single line in your fstab to mount /dev/usbflashdisk at /mnt/usb

----------

## mercurator

Hi!

I just got my usb flash stick. It works perfectly, but I have to mount and unmount it manually. Is there a method for the kernel to mount and unmount the flash stick automatically? In the upper posts I saw koelle used fstab, but isn't that file used only at boot for mounting drives on filesystem?

George

----------

## genstef

There is ivman, and also I have heard of gnome-volume-manager, mntd, and there should probably also be some other solutions.

----------

## koelle

Hi,

Ok i misunderstood that. So i tried it again:

```

udev BUS="usb", SYSFS{model}="TS128MJFLASHA", KERNEL="sd?1", NAME="%k", SYMLINK="usbstick"

```

I added to /etc/fstab:

/dev/usbstick   /mnt/usb   vfat   noauto,user,exec  0 0

When I tried to mount it i got the following message:

 *Quote:*   

> 
> 
> mount: special device /dev/usbstick does not exist
> 
> 

 

There wasn't a directory /dev/usbstick, so i created it and tried again. That's what i got:

 *Quote:*   

> 
> 
> mount: /dev/usbstick is not a block device
> 
> 

 

I think my usbstick is a block device since it's always mounted as /dev/sda1 sdb1 etc...

I also tried to linke it to /dev/usb (that directory already existed). I also got the message that it's not a block device. What must i do?

thanks, koelle

----------

## genstef

You should have a ymlink to  sd?1 there.

----------

## koelle

You mean i should create a symlink from /dev/usbstick to /dev/sd?1?

I tried it:

ln -s /dev/usbstick /dev/sd?1

It said: 

ln: 'dev/sda1": File exists

----------

## genstef

ln -s  /dev/sd?1  /dev/usbstick

to be correct, but the udev rule should have done that for you, so there is something wrong with that rule or the place where it is.

----------

## koelle

hmm...I still get the message that it's not a block device ;(

----------

## koelle

Hi, 

i tried udev again, but couldn't figure out, why i still get the error, that /dev/usbstick is not a block device. Here's what i last tried:

```

udev BUS="usb", SYSFS{product}="TS128MJFLASHA", KERNEL="sd?1", NAME="%k", SYMLINK="substick"
```

I also inlcude the output of "udevinfo -p -a /sys/block/sda/sda1" :

 *Quote:*   

> 
> 
> udevinfo starts with the device the node belongs to and then walks up the
> 
> device chain, to print for every device found, all possibly useful attributes
> ...

 

Maybe someone can help me. It's very strange that i get the message that my usbstick is no block device since it gets mounted on sda1 etc....

greetings koelle

----------

## mrv

```
udev BUS="usb", SYSFS{product}="TS128MJFLASHA", KERNEL="sd?1", NAME="%k", SYMLINK="substick"
```

What is substick? Shouldn't that be usbstick?

 -mrv-

----------

## koelle

yes, a mistake in my post...(when i did it, it was (usbstick)  :Wink: )

----------

## Naib

Try using the specific sticks serial number instead of the model 

```

udev BUS="usb", SYSFS{serial}="0002211600122", KERNEL="sd?1", NAME="%k", SYMLINK="usbstick"

```

If oyu look at your "model" number in your rule w.r.t. the udevinfo output, the udevinfo output has an extra whitespace at the end

----------

## koelle

Still the same error ;(

----------

## Naib

remove the usbstick and look in /dev 

do you have a usbstick shortcut in there?

a few posts up you were asked to explicitly make a link to it

```

ln -s /dev/sd?1 /dev/usbstick 

```

if that still exists you might be having problems

try deleting the /dev/usbstick (if exist with no usbstick connected)

also your rule should create  a node called /dev/sd?1 (be it sda1, sdb1... depending on what scsi dev you have connected).

is this node created?

what is the output of lsmod when you have the stick connected.

any /var/log/messages produced when you connect it

have you compile (as module or into kernel) scsi support

the udev rule, where did you put it? in /etc/udev/rules/...

--EDIT--

just read up a bit you have attached /var/log/messages

from within that your usbstick seems to be of the type that creates a /dev/sd? and not a sd?1 (ie sda not sda1)

try this rule

```

udev BUS="usb", SYSFS{serial}="0002211600122", KERNEL="sd?", NAME="%k", SYMLINK="usbstick" 

```

----------

## koelle

 *Quote:*   

> 
> 
> remove the usbstick and look in /dev
> 
> do you have a usbstick shortcut in there? 
> ...

 

Do you mean a folder? Since there was no /dev/usbstick i simply created it. There was alread a /dev/usb so this time i symlinked to "usb".  I now deleted /dev/usbstick...

 *Quote:*   

> 
> 
> if that still exists you might be having problems
> 
> 

 

not good  :Sad:  I got no errors when creating the symlink...

 *Quote:*   

> 
> 
> also your rule should create a node called /dev/sd?1 (be it sda1, sdb1... depending on what scsi dev you have connected).
> 
> is this node created?
> ...

 

There are the following nodes created: sda, sda1, sdb (At least as far as i can tell)

 *Quote:*   

> 
> 
> what is the output of lsmod when you have the stick connected. 
> 
> 

 

Only nvidia module was listed with lsmod...

 *Quote:*   

> 
> 
> any /var/log/messages produced when you connect it
> 
> 

 

Here's my /var/log/kernel/current:

usb 2-1: USB disconnected, address 6

usb 2-1: new full speed USB device using address 7

scsi7: SCSI emulation for USB Mass Storage device

Vendor: Model: TS128MJFLASHA   Rev: 1.00

SCSI device sda: 253400 512-byte hdwr sectors (130MB)

USB Mass Storage device found at 7

 *Quote:*   

> 
> 
> have you compile (as module or into kernel) scsi support
> 
> 

 

kernel

 *Quote:*   

> 
> 
> the udev rule, where did you put it? in /etc/udev/rules/...
> 
> 

 

what do you mean? I have "50-udev.rules" in /etc/udev/rules.d/. There's all kind of rules. Mine wasn't there. I always did this command in a shell...

I added it, but it didn't help? Do i might have to restart? Since there's no udev-script in /etc/init.d/

I also tried your udev-rule but it didn't work either

koelle

----------

## Naib

ok you have a sda1 device so the rule to use sd?1 is good

ahhh

 *Quote:*   

> 
> 
> I always did this command in a shell... 
> 
> 

 

are you saying that you do at a shell prompt:

jrb@~/ # udev BUS="usb", SYSFS{serial}="0002211600122", KERNEL="sd?1", NAME="%k", SYMLINK="usbstick" 

this is a udev rule and needs to go into a rules.d file

in "/etc/udev/rules.d/" create a file called

"10-udev.rules"

add into it your rule

ie 

$ cd /etc/udev/rules.d

$ vim 10-udev.rules

```

udev BUS="usb", SYSFS{serial}="0002211600122", KERNEL="sd?1", NAME="%k", SYMLINK="usbstick" 

```

then do a reboot

There wont be a /etc/init.d entry for udev. udev needs to start way before init gets to userspace. It is explicitly launched by the kernel just as it starts the init stuff BUT before it gets to the services from /etc/init.d

I am at work atm and on a w2k box, ill be home in a few hours and ill go through a more logical steps - get soo dumb to the ways of linux infront of a windows box

----------

## koelle

Hi,

somehow this doesn't work either. I tried it with the serial number and with the product name

SYSFS{product}="TS128MJFLASHA". Both times i got the same message:

"/dev/usbstick is not a block device". I did exactly as you told me.

Any suggestions?

thx koelle

[edit]

i also tried the rule without the "udev" at the beginning because in the tutorial the guy did not put it at the beginning and in the 50-udev.rules there nowhere was a udev at the beginning.

but without succes  :Sad: 

[/edit]

----------

## Naib

can you mount /dev/sda1 though?

----------

## koelle

Yes that was possible all the time..

----------

## OldTango

I have a issue like this however my flash drive was working before I updated to Gnome 2.8 using pure udev, hald and dbus.

With Gnome 2.6  I created the dir

```
/mnt/jumpdrive
```

 modifyied my fstab to add

```
/dev/jumpdrive      /mnt/jumpdrive   auto      noauto,users      0 0
```

and created a rule for udev in 10-local.rules

```
BUS="usb", SYSFS{serial}="0000064973", NAME="jumpdrive"
```

Inserting the usb jumpdrive created the proper dev/jumpdrive and added it to my computer.  I was then able to open the drive and do what ever I wanted.

After upgrading to Gnome 2.8 everything is the same except I can no longer access my drive and it no longer shows up in my computer.  Udev creates the /dev/jumpdrive but /mnt/jumpdrive is empty.

dmesg output is

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

scsi0 : SCSI emulation for USB Mass Storage devices

  Vendor: Generic   Model: STORAGE DEVICE    Rev: 0117

  Type:   Direct-Access                      ANSI SCSI revision: 02

SCSI device sda: 253888 512-byte hdwr sectors (130 MB)

sda: assuming Write Enabled

sda: assuming drive cache: write through

 sda: sda1

Attached scsi removable disk sda at scsi0, channel 0, id 0, lun 0

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

USB Mass Storage device found at 3

```

I have never had a /dev/sd or a /dev/usb anything created by udev.

Can somebody point me in the right direction to solve this new issue.

Also what is with hald and dbus adding additional lines to my fstab

```
/dev/hdd                /media/cdrw             auto    noauto,user,exec,ro 0 0

/dev/hdc                /media/cdrom            auto    noauto,user,exec,ro 0 0

/dev/hda4               /media/idedisk          reiserfs noauto,user,exec 0 0

/dev/hda2               /media/idedisk1         ext2    noauto,user,exec 0 0
```

and is there info here some place on how I should properly set up my fstab, as all these entries seem redundant and unnessary.

TIA

----------

## Naib

@ koelle

This is my rules file

```

jrb@Fluid ~ $ cat /etc/udev/rules.d/10-local.rules

############################

# Local Machine Udev rules #

############################

BUS="scsi", KERNEL="sd*", SYSFS(serial)="B8177840FE1CB499", NAME="%k", SYMLINK="usbkey"

BUS="usb", SYSFS{serial}="509DLT", NAME="usb/%k", SYMLINK="canon_i550"

KERNEL="mice",          NAME="input/%k", SYMLINK="usbmouse"

KERNEL="js*",           NAME="input/%k", SYMLINK="%k"

```

ahhh in pasting this just noticed I use scsi bus (since it is a scsi device) you are using usb. Just a thought

@ OldTango

for some dumb reason hal will only mount devices that are in the root of /dev ie /dev/foo

if it is a sub directory ie

/dev/foo/bar then it will try to find the same node/symlink in the root of /dev and mount that one. In doing so it will make a new directory /media and also append data to yr /etc/fstab

solution:

delete the /media directory (after unmounting everything)

edit /etc/fstab

    Delete the extra entried

    Edit the devices that access a sub dir in /dev and point them to devices in the root of /dev

----------

## koelle

Hey there,

i think i found the problem. (Yet i couldn't solve it... :Sad: ). Anyway it seems like my system isn't using udev but still devfsd. I found the documentation about configuring udev on the Gentoo Website. I was told to deactivate "Automatically mount at boot" in "File Systems --> Pseudo File Systems". When i reboot there came the message that the system would use udev. "Great" I thought. But, when it came to launching the Login Panel my joy was over!

The screen changed between the NVidia Logo and black!!!  :Crying or Very sad: 

Obviously my hard disks didn't get mounted!!!! Why not? Is there a way to tell udev to mount them at boot???? Help!!

Here's my fstab so that you see how my hard disk looks like:

 *Quote:*   

> 
> 
> /dev/hda1		/boot		ext3		noauto,noatime		1 1
> 
> /dev/hda3		/		reiserfs	noatime			0 0
> ...

 

koelle

----------

## Naib

lol that was going to be my next question if you came back with it now working.

have you edited /etc/conf.d/rc to change it to udev, have you disabled the tarball.

If you are happy to go forward with udev just unmerge devfs

----------

## koelle

Hi,

yes i have disabled the tarball. I tried it all over again, but still get the same error...

Yet i can boot into single user mode, so my hard disks are mounted!

There must be another problem, but what? Do you know? I don't think it's due to the graphics driver since the module is loaded and the NVidia logo appears. After that it switches between that and a black screen!   :Crying or Very sad: 

----------

## koelle

Hi,

i just found out that I can login if i disable xdm at boot. So something's wrong with the XServer, but what????

When i try to mount my usbstick i get the following error:

 *Quote:*   

> 
> 
> mount: wrong fs type, bad option, bad superblock on /dev/usb
> 
>             or too many mounted file systems
> ...

 

if i tell him to use "auto" file system on my usbstick, mount cannot determine the filesystem....

----------

## koelle

 *Naib wrote:*   

> 
> 
> have you edited /etc/conf.d/rc to change it to udev, have you disabled the tarball.
> 
> 

 

I just wonder. Do I have to change more than disabling the tarball?

koelle

----------

## Naib

ok sounds like you have two problems

1) unable to mount the usb stick

2) starting the X server

-------------------------- 1----------------------------------

from your error mesage it sounds like you dont have vfat as a module or compiled into your kernel (which one). It is for tracking down errors that I prefer modules.

Also you need a partition coding infomation as well

from the error message it says it is trying to mount /dev/usb and not /dev/sda1 or /dev/usbstick

---------------------------------- 2 --------------------------

sounds like the nvidia driver module is bombing out. What are the errors in /var/log/Xorg.log

try re-emerging the nvidia-kernel. 

Also with the module probed (you say you can get to a command login instead of an X login) see if teh nvidia module is loaded

lsmod

goto /dev and do a 

#ls -l nvidia*

to return the permission for the nvidia module

----------

## koelle

Hi,

at the end of Xorg.log i found something useful:

 *Quote:*   

> 
> 
> (WW) No  core pointer registered
> 
> ..
> ...

 

Could that be some kind of the problem "/dev/null" not found, like they mentioned in the Gentoo-documentation?

Permissions for the nvidia-driver:

crw-rw---- 1 root video 195, 0 Nov 22 20:53 vidia0

crw-rw---- 1 root video 195, 255 Nov 22 20:53 nvidiactl

I didn't quite understand what i shall do with my usbstick. How do i create a module? What's a partition coding?

thx koelle

--Edit---

I have vfat support compiled in the kernel

----------

## koelle

Hi,

i just re-emerged nvidia-kernel and noticed something really BAD!!

 *Quote:*   

> 
> 
> This module will not work correctly under udev, you do not need to manually create the device anymore
> 
> 

 

That's somehow weird, because the version should be OK:

nvidia-kenel-1.0.6111-r3

In the documentation they write it must be newer than:

nvidia-kernel-1.0.5336-r2

My nvidia driver should be a stabel version since I accept only x86 Keywords...

What do suggest me to do?

----------

## OldTango

Thanks for the info Naid.

I changed my udev rule slightly to

```
BUS="usb", KERNEL="sd*",  SYSFS{serial}="0000064973", NAME="%k", SYMLINK="jumpdrive"
```

I didn't change the bus location because I couldn't find a reference to my jumpdrive on the scsi bus in the sys direcroty.  Every time I plug it in, it gets referenced in /sys/bus/usb.  So I decided to leave the bus location alone as it seems to mount ok at this point.

I remember reading someplace that there are issues with the newer usb drivers in the kernels and some recomendation that they not be used.  I am sure I am atempting to use them because it would have made sense to me during the kernel compile.  But for the life of me I can't recall the exact issue, so I will leave thigs as they are till I can resolve them completely.

Your advise on the fstab thing seems to work ok and I only have 2 added entries in /media right now as it seems that hald is mounting every drive on my system.  I am not sure I wan't this to happen because I don't need or desire my other drives that also contain a gentoo installtion to be mountable from this drive.

Can anybody explain to me why udev is creating a lot more devices than seems necessary.  It seems like every time there is an update to udev and I upgrade I find more devices in /dev.

By the way I am running a pure udev system and do not even have devfs compiled into the kernel and all settings in the tarball set to no. 

Thanks for the help

----------

## koelle

Hi,

how can i get this stupid nvidia driver to work? Is it impossible?!?! It should work, at least if the documentation on gentoo.org is correct!

greetings koelle

----------

## OldTango

Koelle

Tell me what you have done up to this point and what your errors are.  What kernel are you using and maybe I can help.  I have delt with nvidia problems a lot and as a result I have a regiment of things I do to get nvidia functioning.  

If you are using a 2.6 kernel and udev. you need to install the 6111 drivers for both nvidia-kernel and nvidia-glx.  These drivers will need the =>opengl-update-1.8.1-r1 package to work right.  Also make real sure you haven't configured a driver for nvidia in your kernel.  You can see what is currantly installed by doing

```
qpkg -I -v | grep nvidia-kernel

qpkg -I -v | grep nvidia-glx

qpkg -I -v | grep opengl-update
```

This will give you info on the currantly installed packages.  Make sure you have emerged the gentoolkit package or you won't be able to use these commands.

----------

## koelle

Hey there,

it's been some time now since i last posted something. I had all kind of other stuff to do, but now i want to take on my old problem again.

Here's my versions for nvidia-kernel, nvidia-glx and opengl-update:

media-video/nvidia-kernel-1.0.6111-r3 *

media-video/nvidia-glx-1.0.6.111 *

x11-base/opengl-update-1.8.2

I'm using kernel 2.6.9. Before i installed the nvidia driver i had opengl-update-1.8.2 installed. I couldn't find any nvidia driver compiled into the kernel. In what section would it be? (just to be sure).

Still I can't use udev. My XServer crashes...

Can anyone help me?

greetings koelle

----------

## koelle

Hey,

i solved the problem. I had to change my mouse section in xorg.conf:

Option "Device" "dev/mouse" to Option "Device" "dev/input/mice"

Yet i couldn't manage to create a persistent device for my usbstick. Here's my udev-rule (located in /etc/udev/rules.d/10-udev.rules):

```

BUS="usb", SYSFS{serial}="0002211600122", KERNEL="sd?1", NAME="%k", SYMLINK="usbstick"

```

Serial number is correct. Kernel parameter also (my usbstick gets mounted under sda1, sdb1 etc.... and there's is a folder called "usbstick" under dev/

I get the following message, when i try to mount the stick:

 *Quote:*   

> 
> 
> mount:/dev/usbstick is not a block device
> 
> 

 

What's wrong? greetings,

koelle

----------

## OldTango

I guess it is safe to conclude you have X running at this point...............great.

I am still having difficulties understanding UDEV completley but you may try to change the

```
KERNEL="sd?1"
```

to

```
KERNEL="sd*"
```

the rest is the same as mine, and mine mounts ok.  You may have to add a line to your fstab for it and create a mount point in /mnt.

Something like this should be fine.

```
dev/usbstick     /mnt/usbstick    auto     noauto,users,exec   0 0     
```

Mine gets auto mounted when inserted but I access it in the computer icon or the /mnt dir in the file manager, and not the desktop icon.

Hope this helps...............................  :Smile: 

----------

## koelle

Hi,

it works now. Somehow there was a bug or something....

Thanks for your help.

greetings koelle

----------

