# Usb won't mount[solved]

## Gankfest

I get this error when I try to mount my usbstick:

mount: special device /dev/sda1 does not exist

dmesg | grep USB

drivers/usb/input/hid-core.c: v2.6:USB HID core driver

scsi 2:0:0:0: Direct-Access Generic USB SD Reader 1.00 PQ: 0 ANSI: 0

scsi 2:0:0:1: Direct-Access Generic USB CF Reader 1.01 PQ: 0 ANSI: 0

scsi 2:0:0:2: Direct-Access Generic USB SM Reader 1.02 PQ: 0 ANSI: 0

scsi 2:0:0:3: Direct-Access Generic USB MS Reader 1.03 PQ: 0 ANSI: 0

usb 1-5: new high speed USB device using ehci_hcd and address 4

scsi3 : SCSI emulation for USB Mass Storage devices

lspci:

0:10.0 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 81) (prog-if 00 [UHCI])

00:10.1 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 81) (prog-if 00 [UHCI])

00:10.2 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 81) (prog-if 00 [UHCI])

00:10.3 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 81) (prog-if 00 [UHCI])

00:10.4 USB Controller: VIA Technologies, Inc. USB 2.0 (rev 86) (prog-if 20 [EHCI])

lsusb:

Bus 005 Device 002: ID 058f:9360 Alcor Micro Corp.

Bus 005 Device 001: ID 0000:0000

Bus 004 Device 001: ID 0000:0000

Bus 003 Device 001: ID 0000:0000

Bus 002 Device 002: ID 043d:0096 Lexmark International, Inc.

Bus 002 Device 001: ID 0000:0000

Bus 001 Device 004: ID 0781:5151 SanDisk Corp. Cruzer Micro 256/512MB Flash Drive

the only thing is the card is a 2g not 512mb

all the kernel arguments are loaded correctly I checked like 4-5 times. If any additional information is needed let me know and I'll post it. I really need this to work because I hate shitdows, but I need a usb stick for school. Thanx!

----------

## dusik

What if it's not /dev/sda?  See what ls /dev/sd* says.

Also, why not use automount via sys-apps/hal and sys-apps/ivman?

----------

## PaulBredbury

It's not necessarily sda. Try for starters:

```
find /dev -name sd\*
```

----------

## Gankfest

kool it mounted on /dev/sde1, but it won't read it probably because it is in windows format which I can figure out. Thanx for the find /dev -name sd\* great tool.

----------

## dusik

Which file system - FAT32 or NTFS?

----------

## Gankfest

 *dusik wrote:*   

> Which file system - FAT32 or NTFS?

 

NTFS

----------

## holytrousers

well even if its NTFS, you should be able to read it, or even write to it  (if you configure your kernel properly)

A propos, it is strange that it is possible to have write access to a proprietary file system like the ntfs in an open source project, but no write access to ext2fs on windows (i found fs-driver.org that has write access, but its not gpl), or reiserfs (the only driver  i found breaks the windows every time i try to access a file)

Maybe i will switch to ext2   :Crying or Very sad: 

----------

## dusik

Ok, all you need for NTFS read/write support is to install ntfs3g.  Just follow the instructions here: http://gentoo-wiki.com/HOWTO_NTFS_write_with_ntfs-3g

It's really matured and quite safe to use nowadays.

Aside from that, I'd also suggest installing sys-apps/ivman -- then your usb stick should be automagically mounted whenever you plug it in.

----------

## Gankfest

 *dusik wrote:*   

> Ok, all you need for NTFS read/write support is to install ntfs3g.  Just follow the instructions here: http://gentoo-wiki.com/HOWTO_NTFS_write_with_ntfs-3g
> 
> It's really matured and quite safe to use nowadays.
> 
> Aside from that, I'd also suggest installing sys-apps/ivman -- then your usb stick should be automagically mounted whenever you plug it in.

 

ok have them both installed and I followed the guide and inserted this after the emerge:

# ln -s /usr/bin/ntfs-3g /sbin/mount.ntfs

it works fine besides it dosn't automount I cp a doc from my box to my roommates shitbox no problme but

the thing is it changes mount points everytime I plug it in (for ex. it was /dev/sde1 /mnt/usb now it's /dev/sdf1 /mnt/usb) is their a way to make it keep one mount point every time I plug it in and how would I add it to fstab so I can click an icon and do it that way. Thanx

----------

## PaulBredbury

Write a udev rule for it.

----------

## Gankfest

ok I just want to mek sure this is correct I have:

udev rule

SUBSYSTEM=="block", ACTION=="add", RUN+="/usr/local/bin/mount-device.sh /dev/%k"

script:

#!/bin/sh

DEVICE="$1"

GID=`grep plugdev /etc/group | cut -d: -f 3`

if [ "$DEVICE" = "" ] ; then exit 1 ; fi

# wait a moment till' hal has information about the device

sleep 2

HAL_UDI=`hal-find-by-property --key block.device --string "$DEVICE"`

function get_hal_label {

    CUR_UDI=$1

    LABEL=""

    COUNTER=0;

    while [ -z "$LABEL" -a $COUNTER -lt 4 ]; do

	LABEL=`hal-get-property --key volume.label --udi "$CUR_UDI" 2>/dev/null`

	if [ -z "$LABEL" ]; then

	    LABEL=`hal-get-property --key storage.serial --udi "$CUR_UDI" 2>/dev/null`

	fi

	CUR_UDI=`hal-get-property --key info.parent --udi "$CUR_UDI" 2>/dev/null`

	let COUNTER=COUNTER+1

    done

    if [ -z $LABEL ]; then

	LABEL=${DEVICE##/dev/}

    fi

}

function get_hal_removable {

    CUR_UDI=$1

    REMOVABLE=""

    COUNTER=0

    while [ -z "$REMOVABLE" -a $COUNTER -lt 4 ]; do

	REMOVABLE=`hal-get-property --key storage.removable --udi "$CUR_UDI" 2>/dev/null`

	if [ -z "$REMOVABLE" ]; then

	    BUS=`hal-get-property --key storage.bus --udi "$CUR_UDI" 2>/dev/null`

	    if [ "$BUS" = "usb" ]; then

		REMOVABLE="true"

	    fi

	fi

	CUR_UDI=`hal-get-property --key info.parent --udi "$CUR_UDI" 2>/dev/null`

	let COUNTER=COUNTER+1

    done

    if [ -z "$REMOVABLE" ]; then

	logger "assuming $HAL_UDI is removable for safety reasons"

	REMOVABLE="true"

    fi

}

if [ -z "$HAL_UDI" ]; then # can't find device in hal db

    logger "hald didn't know about $DEVICE"

    LABEL=${DEVICE##/dev/}

else # device found in hal db.

    get_hal_label "$HAL_UDI"

    get_hal_removable "$HAL_UDI"

fi

logger "Mounting HAL_UDI $HAL_UDI as $DEVICE to $LABEL (removable: $REMOVABLE)"

SYNC_OPT=""

if [ $REMOVABLE = "true" ]; then

    SYNC_OPT="--sync"

fi

pmount --umask 007 $SYNC_OPT "$DEVICE" "$LABEL"

# if you do not want to use pmount (why should you?)

#MOUNTPOINT=/media/${LABEL}

#mkdir -p "$MOUNTPOINT" &&

#touch "$MOUNTPOINT"/.created_by_pmount &&

#mount "$DEVICE" "$MOUNTPOINT" -o gid=$GID,umask=007 ||

#rm "$MOUNTPOINT"/.created_by_pmount &&

#rmdir "$MOUNTPOINT"

fstab:

/dev/sde1               /mnt/usb        auto            noauto,user    0 0

now when I click on the icon in system:/media it doesn't mount the device on /dev/sde1 /mnt/usb, so how can I fix it so it doe's. Thanx!

----------

## PaulBredbury

A udev rule is 1 line, not 100. There's dozens if not hundreds of previous threads about it.

----------

## Gankfest

 *PaulBredbury wrote:*   

> A udev rule is 1 line, not 100. There's dozens if not hundreds of previous threads about it.

 

The udev rule is one line here:

SUBSYSTEM=="block", ACTION=="add", RUN+="/usr/local/bin/mount-device.sh /dev/%k" 

the script to run it I guess is this:

#!/bin/sh

DEVICE="$1"

GID=`grep plugdev /etc/group | cut -d: -f 3`

if [ "$DEVICE" = "" ] ; then exit 1 ; fi

# wait a moment till' hal has information about the device

sleep 2

HAL_UDI=`hal-find-by-property --key block.device --string "$DEVICE"`

function get_hal_label {

CUR_UDI=$1

LABEL=""

COUNTER=0;

while [ -z "$LABEL" -a $COUNTER -lt 4 ]; do

LABEL=`hal-get-property --key volume.label --udi "$CUR_UDI" 2>/dev/null`

if [ -z "$LABEL" ]; then

LABEL=`hal-get-property --key storage.serial --udi "$CUR_UDI" 2>/dev/null`

fi

CUR_UDI=`hal-get-property --key info.parent --udi "$CUR_UDI" 2>/dev/null`

let COUNTER=COUNTER+1

done

if [ -z $LABEL ]; then

LABEL=${DEVICE##/dev/}

fi

}

function get_hal_removable {

CUR_UDI=$1

REMOVABLE=""

COUNTER=0

while [ -z "$REMOVABLE" -a $COUNTER -lt 4 ]; do

REMOVABLE=`hal-get-property --key storage.removable --udi "$CUR_UDI" 2>/dev/null`

if [ -z "$REMOVABLE" ]; then

BUS=`hal-get-property --key storage.bus --udi "$CUR_UDI" 2>/dev/null`

if [ "$BUS" = "usb" ]; then

REMOVABLE="true"

fi

fi

CUR_UDI=`hal-get-property --key info.parent --udi "$CUR_UDI" 2>/dev/null`

let COUNTER=COUNTER+1

done

if [ -z "$REMOVABLE" ]; then

logger "assuming $HAL_UDI is removable for safety reasons"

REMOVABLE="true"

fi

}

if [ -z "$HAL_UDI" ]; then # can't find device in hal db

logger "hald didn't know about $DEVICE"

LABEL=${DEVICE##/dev/}

else # device found in hal db.

get_hal_label "$HAL_UDI"

get_hal_removable "$HAL_UDI"

fi

logger "Mounting HAL_UDI $HAL_UDI as $DEVICE to $LABEL (removable: $REMOVABLE)"

SYNC_OPT=""

if [ $REMOVABLE = "true" ]; then

SYNC_OPT="--sync"

fi

pmount --umask 007 $SYNC_OPT "$DEVICE" "$LABEL"

# if you do not want to use pmount (why should you?)

#MOUNTPOINT=/media/${LABEL}

#mkdir -p "$MOUNTPOINT" &&

#touch "$MOUNTPOINT"/.created_by_pmount &&

#mount "$DEVICE" "$MOUNTPOINT" -o gid=$GID,umask=007 ||

#rm "$MOUNTPOINT"/.created_by_pmount &&

#rmdir "$MOUNTPOINT" 

coming from this guide here:

http://gentoo-wiki.com/UDEV

I just want to make sure it's correct in the fact that every time I plug my usbstick it it gets the same mount point so I can stick it in fstab and have an icon in system:/media. Now the icon that is their now doesn't work so I was wondering if someone knew if my fstab is correct in loading the usbstick which is here:

/dev/cdrom              /mnt/cdrom      auto            noauto,user     0 0

/dev/fd0                /mnt/floppy     auto            noauto          0 0

/dev/sde1               /mnt/usb        auto            noauto,user    0 0

----------

## Gankfest

I magically fixed it some how idk and don't care. tootles!

----------

## purpler

i have this crapy problem too,i tred ivman and it somehow mount device but not always i plug it in..

im sure that kernel is ok because automounting worked once but wont now..

is there any "automount holy grail" available?

----------

## artbody

earlier versions of udev i solved this way

http://www.reactivated.net/writing_udev_rules.html

but

since the new version of udev 

the udevrules create a few symlinks for most usb devices

so i solved this problem that way

example is a harddisk

/etc/fstab

....

/dev/disk/by-id/scsi-SATA_ST3320620AS_3QF08LR2-part1 /mnt/ext_disc1 .......

works fine

----------

## purpler

why is it so f****** hard to do such stupid thing as a usb stick and cdrom automounting?

i tried bunch of things and im getting tired of this crap allready..

::28.08.2007 edit::

it seems latest sync and emerge -NDuva world pull in new udev-115 which apperently solved the problem, usb stick and cdrom was mounted on predefined entries on fstab almost instantly so i guess i finished latest problem i had with gentoo..

thnxx all for helping out and long live gentoo  :Smile: 

----------

