PDA

View Full Version : partition label of usb device corrupted, how to use device notifier



tudju
Jul 10th 2011, 09:24 AM
I am using the "device notifier" in the system tray of KDE to mount and unmount usb devices.

I have a problem when connecting my android nexus s because the label of the partition of the sd card looks corrupted from time to time (some time it is empty and the device is mounted to "disk", some time it includes weird characters which are impossible to type on a console so the mount point is hard to reach). At some point I have been able to change the label to "android" with the "disk utility" so that it would mount to /media/ANDROID. But it has changed again. Android does not seem to let us change the label.

I have read many posts about udev (and how to make rules to rename the device name, not the mount point). I have also played with the fstab so that it would mount on a specific point using the by-uuid code, but not with the device notifier which does not seem to like it.

I am wondering if there would be a way to intercept the label name while it is being given by the device. Or about any other way to make it possible to use the device notifier to mount and umount at the right place whatever label it transmitted by android.

wizard10000
Jul 10th 2011, 09:43 AM
You could create an fstab entry and mount the disk by UUID - that's what I do with an external NTFS drive. Looks like this -

# external hd
UUID=B620FE7E20FE4541 /mnt/external ntfs-3g defaults,nofail 0 0

The 'nofail' switch keeps fstab from hanging the system on startup if the drive isn't present - when I do plug the drive in it mounts properly but on my setup you have to be root to unmount it, which isn't a problem for me. You could tweak the fstab line a little to mount the thing under your own UID if you wanted.

With this method if it didn't mount automatically when you plugged it in then

sudo mount -a

would get the drive mounted quickly.

tudju
Jul 10th 2011, 10:16 AM
Yes, wizard10000. I am using something similar. Actually, with the user flag there is no need to be root.
My problem is that the device notifier does not support this tweak. It keeps on proposing to mount on a point corresponding to the label. It even asks for the use password to mount with sudo and then fails to mount it. I can still mount is manually (mount /media/android/sdcard), of course. But I want to make this device notifier work.

My fstab entry is
UUID=35EE-1E0E /media/android/sdcard vfat noauto,user,rw,nosuid,nodev,utf8,shortname=mixed,f lush 0 0

and here is what label is transmitted:
~$ udevadm info --name=/dev/sdb --query=all | grep -i label
S: disk/by-label/\x89PNG\x0d\x0a\x1a
E: ID_FS_LABEL=_PNG__
E: ID_FS_LABEL_ENC=\x89PNG\x0d\x0a\x1a
E: DEVLINKS=/dev/block/8:16 /dev/disk/by-id/usb-Android_UMS_Composite_3135E31CBFA400EC-0:0 /dev/disk/by-path/pci-0000:00:1d.7-usb-0:3:1.0-scsi-0:0:0:0 /dev/disk/by-uuid/35EE-1E0E /dev/disk/by-label/\x89PNG\x0d\x0a\x1a

The device notifier displays _PNG and not the 0x0d0x0a0x1a characters. Without the fstab entry, once mounted by the device notifier, the mount point is /media/\x89PNG\x0d\x0a\x1a which is not very convenient!

wizard10000
Jul 10th 2011, 10:54 AM
I think maybe the 'noauto' switch might be causing you issues - as it tells fstab not to automatically mount the partition. Like I said, mine mounts when I plug it in and Device Notifier shows it in the correct location every time.

Maybe the 'nofail' switch instead? I'm not sure but it's worth a shot.

tudju
Jul 10th 2011, 08:08 PM
I have tried the "default,nofail" flags instead of the ones with "noauto" and I did not see any difference with the device notifier. It still fails to mount the device, even after prompting for my password through kdesudo.