# stuck on USB drives [SOLVED]

## zebrapad

This problem has kept me googl'ing for a solution for a long time   :Confused: 

- can mount any USB drive

- can umount

- can do some basic file operations

But:

- after a lot of data traffic, USB drive will simply not respond anymore

- at that point, I cannot umount it anymore

- umount will be stuck and cannot stop it (ctrl+c) anymore

- any application trying to access it will freeze

- in the end, I have to reboot my systeem (reboot linux ?? NOOOOOO)

Can anyone point me in the right direction ?

----------

## rlittle

I have no idea, and will probably continue to have no idea, but you should post an "emerge --info".

...then some name-taking, ass-kicking l33t might wander by fix it by blinking hard.   :Laughing: 

----------

## Akkara

Is it a hard-disk USB drive?

Some hard-disk USB drives auto spin-down after a period of idle time and the kernel doesn't know to spin it back up.  The Seagate Freeagent series seems especially troublesome in this regard.

Creating the following udev rule seems to have helped me, at least with the Freeagents.  Tweak it as needed for your own device.

In /etc/udev/rules.d/99-freeagent.rules

```
ACTION=="add", SUBSYSTEM=="scsi_device", ATTRS{vendor}=="Seagate*", ATTRS{model}=="FreeAgent*", \

        RUN+="/bin/sh -c 'echo 1 > /sys/class/scsi_disk/%k/allow_restart'"
```

(Addendum: if this does not solve your problem, please post the output of dmesg | tail -50 )

----------

## zebrapad

It happens with pen-drives also.

I found that it must have something to do with the cache/buffer. If I unmount and remount each minute, I can keep using the thing. As you know, umount flushes the drive.

Maybe I should try some mount options, like :

```

async  All I/O to the file system should be done asynchronously.

atime  Update inode access time for each access. This is the default.

```

----------

## zebrapad

This is what dmesg says after I plugged in my USB stick :

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

usb 1-7: configuration #1 chosen from 1 choice

scsi5 : SCSI emulation for USB Mass Storage devices

usb-storage: device found at 6

usb-storage: waiting for device to settle before scanning

  Vendor: Ut163     Model: USB2FlashStorage  Rev: 0.00

  Type:   Direct-Access                      ANSI SCSI revision: 02

SCSI device sdb: 7897087 512-byte hdwr sectors (4043 MB)

sdb: Write Protect is off

sdb: Mode Sense: 00 00 00 00

sdb: assuming drive cache: write through

SCSI device sdb: 7897087 512-byte hdwr sectors (4043 MB)

sdb: Write Protect is off

sdb: Mode Sense: 00 00 00 00

sdb: assuming drive cache: write through

 sdb: sdb1

sd 5:0:0:0: Attached scsi removable disk sdb

sd 5:0:0:0: Attached scsi generic sg1 type 0

usb-storage: device scan complete
```

things that look suspicious to me:

sdb: assuming drive cache: write through

sdb: Write Protect is off

----------

## JeliJami

 *zebrapad wrote:*   

> I found that it must have something to do with the cache/buffer. If I unmount and remount each minute, I can keep using the thing. As you know, umount flushes the drive.
> 
> 

 

a simple 'sync' would do the same

 *zebrapad wrote:*   

> things that look suspicious to me:
> 
> sdb: assuming drive cache: write through
> 
> sdb: Write Protect is off

 

I always see those messages, but I never experienced the problem you mention.

----------

## Lawrence Gold

 *zebrapad wrote:*   

> This problem has kept me googl'ing for a solution for a long time  
> 
> - can mount any USB drive
> 
> - can umount
> ...

 

I've had the same thing happen with USB hard drives since upgrading to gentoo-sources-2.6.24, with the additional problem that my USB keyboard stops working when a write operation gets stuck. Yesterday I booted into a gentoo-sources-2.6.23-r6 kernel, and everything worked fine.

Interestingly, I was able to copy large files successfully to my thumb drive. I don't know if that's because it's slower, or because it's formatted with FAT32 while my hard drives are formatted with NTFS (and accessed via ntfs-3g).

When I get a chance, I'll try a vanilla 2.6.24 kernel.

----------

## Lawrence Gold

 *Lawrence Gold wrote:*   

> 
> 
> I've had the same thing happen with USB hard drives since upgrading to gentoo-sources-2.6.24, with the additional problem that my USB keyboard stops working when a write operation gets stuck. Yesterday I booted into a gentoo-sources-2.6.23-r6 kernel, and everything worked fine.
> 
> Interestingly, I was able to copy large files successfully to my thumb drive. I don't know if that's because it's slower, or because it's formatted with FAT32 while my hard drives are formatted with NTFS (and accessed via ntfs-3g).
> ...

 

In case it's helpful to anyone, here's my emerge --info:

```

Portage 2.1.4.1 (default-linux/amd64/2007.0/desktop, gcc-4.2.2, glibc-2.7-r1, 2.6.24-gentoo x86_64)

=================================================================

System uname: 2.6.24-gentoo x86_64 Intel(R) Core(TM)2 CPU 6400 @ 2.13GHz

Timestamp of tree: Wed, 06 Feb 2008 16:16:01 +0000

app-shells/bash:     3.2_p33

dev-java/java-config: 1.3.7, 2.1.4

dev-lang/python:     2.5.1-r5

dev-python/pycrypto: 2.0.1-r6

sys-apps/baselayout: 1.12.11.1

sys-apps/sandbox:    1.2.18.1-r2

sys-devel/autoconf:  2.13, 2.61-r1

sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10.1

sys-devel/binutils:  2.18-r1

sys-devel/gcc-config: 1.4.0-r4

sys-devel/libtool:   1.5.26

virtual/os-headers:  2.6.24

ACCEPT_KEYWORDS="amd64 ~amd64"

CBUILD="x86_64-pc-linux-gnu"

CFLAGS="-O2 -march=native -pipe"

CHOST="x86_64-pc-linux-gnu"

CONFIG_PROTECT="/etc"

CONFIG_PROTECT_MASK="/etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/php/apache2-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/cli-php5/ext-active/ /etc/revdep-rebuild /etc/terminfo /etc/texmf/web2c /etc/udev/rules.d"

CXXFLAGS="-O2 -march=native -pipe"

DISTDIR="/usr/portage/distfiles"

FEATURES="distlocks metadata-transfer sandbox sfperms strict unmerge-orphans userfetch"

GENTOO_MIRRORS="http://cudlug.cudenver.edu/gentoo/ http://mirror.usu.edu/mirrors/gentoo/ http://gentoo.mirrors.easynews.com/linux/gentoo/"

LINGUAS="en"

MAKEOPTS="-j2"

PKGDIR="/usr/portage/packages"

PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"

PORTAGE_TMPDIR="/var/tmp"

PORTDIR="/usr/portage"

PORTDIR_OVERLAY="   "

SYNC="rsync://rsync.namerica.gentoo.org/gentoo-portage"

USE="3dnow X a52 aac acl acpi alsa amd64 apache2 audiofile avahi bash-completion berkdb bitmap-fonts bonobo buttons bzip2 cairo cdparanoia cdr chroot cjk cli cracklib crypt css cups daap dbus djvu dri dv dvd dvdr dvdread dvi effects emboss encode evo fam fat ffmpeg firefox flac fortran ftp gd gdbm gif gimp gnome gnome-print gnutls gphoto2 gpm gstreamer gtk gtkhtml hal hfs howl hpn iconv icq imagemagick inkjar ipod ipv6 isdnlog jabber java javascript jfs jpeg jpeg2k kde kdeenablefinal kerberos kqemu ldap mad matroska midi mikmod mmx mmxext mng mod mono mozilla mp3 mpeg msn mudflap muine musepack ncurses nls nptl nptlonly ntfs nvidia offensive ogg openal opengl openmp oss pam pcre pdf perl plotutils png ppds pppd python qt3 qt3support qt4 quicktime readline reflection reiserfs ruby samba screen sdl session shout skins sndfile speex spell spl sse sse2 ssl startup-notification svg symlink tagwriting tcltk tcpd theora threads tiff truetype truetype-fonts type1-fonts unicode vcd vim-pager vorbis wmf wxwindows xanim xml xorg xprint xv xvid yahoo zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic auth_digest authn_anon authn_dbd authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock dbd deflate dir disk_cache env expires ext_filter file_cache filter headers ident imagemap include info log_config logio mem_cache mime mime_magic negotiation proxy proxy_ajp proxy_balancer proxy_connect proxy_http rewrite setenvif so speling status unique_id userdir usertrack vhost_alias" CAMERAS="canon" ELIBC="glibc" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="en" USERLAND="GNU" VIDEO_CARDS="i810 nv"

Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, LDFLAGS, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

```

----------

## zebrapad

Lawrence thanks for the info.

I'll try another kernel in the weekend. I tend to make a mess of my kernel configs  :Smile: 

Currently using 2.6.18-gentoo-r4 x86_64

----------

## rlittle

This might be related:

My swap almost filled up last night, and if that happens I usually run "swapoff -a" (followed by swapon -a) to clear the swap. Usually it takes about 10 seconds to clear swap. Now I'm using 2.6.24, and when I ran "swapoff -a" it took about 15min to clear the swap.

Now, I have no idea why this happens, but it could be that if you (ug) what long enough (i.e. 15 to 45min), your usb might finish whatever operation it's stuck in and allow you to unmount it gracefully.

I'll try messing around with a key on my home machine tonight and see if I get hit by the same thing as you have.

----------

## zebrapad

changing kernel from 2.6.18 to 2.6.23 did not help  :Sad: 

using sync in between each file however does do the trick, but is so awkward.

----------

## rlittle

I can't reproduce the prob on my machine in 2.6.24, and zebrapad isn't running it anyway, so it's probably not related.

Do you have a different brand of USB key you can try? I'm stumped.

If it helps, here's what mine looks like when I plug in a USB:

```
usb 1-4.2: new high speed USB device using ehci_hcd and address 11

usb 1-4.2: configuration #1 chosen from 1 choice

scsi 14 : SCSI emulation for USB Mass Storage devices

scsi 14:0:0:0: Direct-Access     Kingston DataTraveler 2.0 6.16 PQ: 0 ANSI: 0 CCS

sd 14:0:0:0: [sde] 2004991 512-byte hardware sectors (1027 MB)

sd 14:0:0:0: [sde] Write Protect is off

sd 14:0:0:0: [sde] 2004991 512-byte hardware sectors (1027 MB)

sd 14:0:0:0: [sde] Write Protect is off

 sde: sde1

sd 14:0:0:0: [sde] Attached SCSI removable disk

sd 14:0:0:0: Attached scsi generic sg6 type 0
```

----------

## zebrapad

[SOLVED]

JeliJami gave me the idea to use the command sync,

and it appears that it also is a mount option.

So I added an entry to my fstab and so far, I can transfer data without worries!

```
/dev/sdb1 /mnt/xsdrive vfat noauto,sync,exec,user 0 0
```

Many thanks rlittle, JeliJami and Lawrence for helping me fix this!

I LOVE GENTOO  :Exclamation: 

----------

## Lawrence Gold

 *zebrapad wrote:*   

> [SOLVED]
> 
> JeliJami gave me the idea to use the command sync,
> 
> and it appears that it also is a mount option.
> ...

 

I'm glad to hear you've solved your problem. I still have a similar problem with 2.6.24.1. I tried various 2.6.24-rc kernels to try to narrow it down, but it never occurs during testing. I can even switch back to 2.6.24 or 2.6.24.1 while I'm trying to reproduce it, and suddenly the problem won't occur.

----------

## Lawrence Gold

Just to tie up my part of this thread, I'll quote this portion of the announcement for the latest NTFS-3G:

 *Quote:*   

> Thanks to our Gentoo users and Miklos Szeredi, it was found out recently 
> 
> that the FUSE kernel module used from the FUSE software packages (Gentoo 
> 
> default) with the 2.6.24 Linux kernels can lockup the system.
> ...

 

I swear I tried this and it didn't work, but I probably just screwed something up. Now a gentoo-sources-2.6.24-r2 kernel with the built-in FUSE module works perfectly for me.

----------

