Bug 115137

Summary: HAL 'missdetect' main devices with broken file systems
Product: [openSUSE] SUSE Linux 10.1 Reporter: Alexey Eremenko <al4321>
Component: HotplugAssignee: Danny Kukawka <dkukawka>
Status: RESOLVED WONTFIX QA Contact: E-mail List <qa-bugs>
Severity: Major    
Priority: P3 - Medium CC: alex.loes, dkukawka, ihno
Version: Alpha 1   
Target Milestone: ---   
Hardware: PC   
OS: All   
Whiteboard:
Found By: Customer Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: "lshal --monitor" log file
KDE Konqueror showing 2 USB flash disks.
My HAL log (it's huge, over 3MB!!) - so it's compressed
my "fdisk -l" log, when USB flash inserted
my "ls -lha /media > /tmp/media.log" when USB flash inserted
My "cat /proc/mounts" log, when USB flash inserted

Description Alexey Eremenko 2005-09-03 14:33:10 UTC
When I insert my USB flash disk, it detects it but very often can't automatcally
mount it in KDE Konqueror, which results in errors.

on average, that auto-mounting of USB flash disk fails 80% of the time.
Comment 1 Danny Al-Gaaf 2005-09-03 15:02:48 UTC
please try to reproduce with beta4 and definde "USB flash disk"
Comment 2 Alexey Eremenko 2005-09-03 15:55:07 UTC
USB flash disk - M-systems 256MB, USB2 interface. (as far as I know, not sure)

linux:~ # lsusb
Duplicate product spec at line 2453 product 0846:4240 WG111 WiFi
Bus 004 Device 001: ID 0000:0000
Bus 003 Device 001: ID 0000:0000
Bus 002 Device 009: ID 08ec:0011 M-Systems Flash Disk Pioneers
Bus 002 Device 002: ID 045e:0059 Microsoft Corp. Wireless IntelliMouse Explorer
Bus 002 Device 001: ID 0000:0000
Bus 001 Device 003: ID 046d:c216 Logitech, Inc.
Bus 001 Device 001: ID 0000:0000

Is there any way that the system defines me that USB disk better? (i.e. USB 1 or
USB 2 interface?)

My hardware: AMD Sempron CPU, 1GB RAM, VIA KM400 chipset.

=========================
Currently downloading BETA4, once done, I will post it here.
Comment 3 Alexey Eremenko 2005-09-03 18:42:50 UTC
OK, so now I have BETA4. 
Still USB flash doesn't work !
Comment 4 Hannes Reinecke 2005-09-05 10:19:41 UTC
Coolo, could there be a race condition?
When is kde being notified for a new device?
Is it possible that KDE acknowledges the new device _before_ submount has
handled it?
Comment 5 Stephan Kulow 2005-09-05 11:00:54 UTC
I would like to know what you're doing exactly. KDE gets the device unmounted  
first and then updates its status to mounted (signalled by a green triangle at  
the edge within media:/). As it works for me, I see no general problem. Please  
describe _exactly_ what you're seeing and what you're doing there.  
 
Also provide the output of lshal --monitor (only the end) when you attach the 
key. 
Comment 6 Alexey Eremenko 2005-09-05 15:40:06 UTC
Exactly? huh... OK:
1) Take my USB flash disk.
2) Remove the plastic part so that I can plug it inside.
3) Plug it inside
4) Green led on my USB flash disk activated.
5) Open KDE Konqueror 3.4.2 (from SuSE 10.0 , BETA 4)
6) Click on storage media
7) For a totally mysterious reason I see 2 (!!) USB flash disks, through I have
only one.
8) Click on the first USB disk image - Konqueror goes to state "media:/sda" but
neither files nor directories are shown.
9) Press back button
10) Click on the second USB disk image - Konqueror goes to state "media:/sda1"
but neither files nor directories are shown.
11) trying to do that manually, failing again;
linux:~ # mkdir -p /mnt/removable/
linux:~ # mount -t auto /dev/sda /mnt/removable/
linux:~ # cd /mnt/removable/
linux:/mnt/removable # ls
/bin/ls: reading directory .: Input/output error

============================================================================
Mount command:
.....
/dev/sda on /media/usbdisk type subfs (rw,nosuid,nodev,sync,fs=ext2)
/dev/sda1 on /media/usbdisk_1 type subfs
(rw,nosuid,nodev,sync,fs=floppyfss,procuid,utf8=true)
/dev/sda on /mnt/removable type ext2 (rw)
linux:~ #      

Also I have attached a log of "lshal --monitor"
Comment 7 Alexey Eremenko 2005-09-05 15:41:07 UTC
Created attachment 48821 [details]
"lshal --monitor" log file
Comment 8 Alexey Eremenko 2005-09-05 15:42:25 UTC
Created attachment 48824 [details]
KDE Konqueror showing 2 USB flash disks.
Comment 9 Alexey Eremenko 2005-09-09 18:09:44 UTC
Tried the new RC1, same error !!!
Comment 10 Danny Al-Gaaf 2005-09-09 18:59:35 UTC
please do this:

- stop hal (with 'rchal stop')
- hald --verbose=yes --daemon=no --retain-privileges > /tmp/hal_log 2>&1
- wait 10 seconds
- plugin the USB stick
- wait 20 seconds
- stop hal with 'Ctrl + C'

Attach the file /tmp/hal_log to this bug
Comment 11 Danny Al-Gaaf 2005-09-09 19:01:07 UTC
@Kay: please take a look at this bug! HAL detects a partition/volume at /dev/sda 
this should IMO not happen. I have no time to do this.
Comment 12 Danny Al-Gaaf 2005-09-09 19:07:34 UTC
@Kay: is this at /dev/sda/ maybe the extended partition?

@Alexey: please attach also this:
 - 'fdisk -l'
 - if the device is mounted: 'ls -lha /media' 
Comment 13 Danny Al-Gaaf 2005-09-09 19:09:31 UTC
@Alexey: Sorry, but please also attach the output of 'cat /proc/mounts' if the 
device is mounted
Comment 14 Alexey Eremenko 2005-09-09 23:35:05 UTC
Created attachment 49494 [details]
My HAL log (it's huge, over 3MB!!) - so it's compressed
Comment 15 Alexey Eremenko 2005-09-09 23:36:06 UTC
Created attachment 49496 [details]
my "fdisk -l" log, when USB flash inserted
Comment 16 Alexey Eremenko 2005-09-09 23:38:21 UTC
Created attachment 49497 [details]
my "ls -lha /media > /tmp/media.log" when USB flash inserted
Comment 17 Alexey Eremenko 2005-09-09 23:39:47 UTC
Created attachment 49498 [details]
My "cat /proc/mounts" log, when USB flash inserted
Comment 18 Alexey Eremenko 2005-09-09 23:41:46 UTC
Is this information sufficient to understand the problem better?
Comment 21 Alexey Eremenko 2005-09-12 15:23:26 UTC
Hello again!

So, is there any progress ?
Comment 22 Kay Sievers 2005-09-12 16:19:23 UTC
I see:
  volume.fstype = 'ext2'
in the logfile. Did you ever format this usb stick with Linux ext format?

If yes:
That may not work if you use one of the horrible unix FAT formatting tools.
The disk needs to be invalidated with a smarter tool or at least the first 64kb
need to be invalidated with zeros, before you switch the filesystem.

If not:
The ext filesystem signature is only 2 bytes long, so it may be just coincidence
and we should add a check for that.
Comment 23 Alexey Eremenko 2005-09-13 22:30:52 UTC
well, that Flash disk was actually formatted with FAT.

After reformatting the problem disappeared.
Now USB Flash disk hot plug-in works in both Windows & Linux.

Bug rendered unreproduceable. Closing.
Comment 24 Kay Sievers 2005-09-13 22:45:22 UTC
Thanks for testing it. You never formatted that volume with any ext format, right?
Anyway, we should fix it some day, when we found out how to fix it. :)
I've put it on my TODO list and posted it to the HAL list
  http://lists.freedesktop.org/archives/hal/2005-September/003297.html
Comment 25 Danny Al-Gaaf 2005-10-11 08:58:38 UTC
*** Bug 115552 has been marked as a duplicate of this bug. ***
Comment 26 Danny Al-Gaaf 2005-10-12 09:23:33 UTC
*** Bug 127511 has been marked as a duplicate of this bug. ***
Comment 27 Danny Al-Gaaf 2005-10-12 09:24:49 UTC
Reopend the bug. We must fix this.
Comment 28 Kay Sievers 2005-10-12 12:24:57 UTC
Do you have an idea how to fix it?
Comment 29 Danny Al-Gaaf 2005-10-12 12:47:04 UTC
Is there ever a situation, where a harddisk or USB-Stick could contain a 
formated partion/volume on e.g. /dev/sdb or /dev/sda? I'm not complete sure, but 
I don't think so. Partitions should always be on e.g. /dev/sda{1,2,3...n}. 

In this case we could remove the complete device in HAL.

Or any other ideas?
Comment 30 Kay Sievers 2005-10-12 13:15:05 UTC
Sure, there are formatted main block devices.
A FAT filesystem on /dev/sda is a common use.
Comment 31 Hannes Reinecke 2005-10-12 13:19:12 UTC
I really do think everybody should be able to view this bug ...
Comment 32 Alex Loes 2005-10-12 14:43:27 UTC
I remarked that when I plug in the USB-stick, 2 devices (/dev/sdb and /dev/sdb1)
will be marked as mounted in the command mount, while none of them could be read
or written to.
When manually I unmount the device /dev/sdb, all goes right.

Perhaps is the mount /dev/sdb blocking the device to mount properly, showing the
kernel messages: 
submountd: unable to mount media: device or ressource busy.

How do I prevent the system to try to mount /dev/sdb?
Comment 33 Kay Sievers 2005-10-12 15:12:41 UTC
Your device has a broken layout. You need to zero-out the first blocks of the
device before you apply a new filesystem or apply a partitiontable. Your
superblock contains a valid filesystem signature, but is actually a partitiontable.

Sane formatting tools, like ones who use libparted do this. Most of the unix
formatting tools are completely broken in that area and should be avoided or
only used after at least the first and last 64 kilobytes of the device are
written with zeros.

I gave up convincing the maintainers of the filesystem formatters, they like to
stick with the middle age. :(

HAL may need a fix to invalidate a "main device" if a child arrives, but that is
not an easy fix and we are not sure abou the right fix...
Comment 34 Alex Loes 2005-10-13 06:29:21 UTC
Indeed. I partitioned the USB stick with parted and now all went fine.

Thanx for your help.
Comment 35 Alexey Eremenko 2005-10-13 16:44:39 UTC
That's OK. My IP has changed, so the opened NX session shouldn't worry you. Please 
open this bug to the public. (I can't help with this bug because my flash disk
currently works OK - but it didn't worked - it was ALWAYS formatted with FAT.
Never with ext3/reiserfs/...)
Comment 36 Alexey Eremenko 2005-10-13 16:48:05 UTC
As for your question:
I have always mounted my USB flash disk with: 
mount -t vfat /dev/sda /mnt/removable

you see: /dev/sda it's NOT /dev/sda1
Comment 37 Sebastien ROHAUT 2005-10-14 07:08:44 UTC
Just an info for you. I have at home an usb stick (in fact an MP3 player) with a
FAT filesystem in /dev/sda. Due to the fact this usb stick is also a MP3 player,
I can't create partitions on it. I tried but the MP3 player didn't recognize at
all the partition. It only works if the whole drive (/dev/sda) is formated as a
FAT filesystem.

So if I plug this usb stick on an old SUSE 9.3, all is working well and I can
copy at over 1MB/s my files on it. On SUSE 10.0, the speed is about 40 kB/s
(tested on two different hardware) !!!! Could I open a new bug report for this ?
Comment 38 Alex Loes 2005-10-14 09:44:03 UTC
Thats' thee same for me. Speed is about 30KB/s, and before I formatted thee
USB-Stick,I ahd problems to mount it, but once resolved (mounted by hand), the
speed was about 2-3MB/s.

Now the automount works, but speed is very low.

What can do now?

Comment 39 Sebastien ROHAUT 2005-10-18 20:46:08 UTC
See bug #105871
Comment 40 Kay Sievers 2005-10-21 02:54:23 UTC
Closing this bug now, cause the speed issue is on #105871.
Comment 41 Danny Al-Gaaf 2005-10-21 16:11:39 UTC
Kay: I reopen the bug. We need to fix the bug with wrong detect raw device as partition. I work on a solution as discussed to prevent this problem.

other: please don't discuss other things in the bug than in the summary.
Comment 42 Ihno Krumreich 2005-12-18 18:53:46 UTC
Still valid?
Comment 43 Danny Al-Gaaf 2005-12-18 19:17:54 UTC
ihno: yes, already valid ... we look already for a acceptable solution.
Comment 44 Danny Al-Gaaf 2006-01-30 13:51:25 UTC
I change this to RESOLVED LATER, because we have currently no well working solution.
Comment 45 Danny Al-Gaaf 2006-07-18 14:50:08 UTC
reopen to comment and close
Comment 46 Danny Al-Gaaf 2006-07-18 14:52:45 UTC
This is now [1] fixed in HAL and the kernel. This should be part of openSUSE 10.2 release. I close the bug as WONTFIX for SL10.1

[1] http://lists.freedesktop.org/archives/hal/2006-July/005563.html