PDA

View Full Version : Auto-mount USB devices?


cyberwizzard
2008-12-14, 18:24
When testing XBMC I noticed the HAL device detection in the logs, I therefor assumed that simply plugging in a USB stick or HD would be automatically mounted.

When testing, this worked because I ran XBMC in a full Ubuntu environment.

After removing the usual bootup scripts and skipping GDM and Gnome, XBMC has been working like a charm.... except drives aren't auto-mounted anymore :(

After some investigating, it seems that I mistakenly took Gnome's built-in HAL magic for XBMC magic. Manually mounting the drive will make it show up in the source listing in non-library mode.

Does XBMC have no logic to mount USB devices on its own? If so, I still could write my own scripts to mount devices read-only so they would mount fine and still be able to just yank em out of the system when I feel like it (mounting read/write on a drive you are planning on disconnecting any time is bad practice :)).

topfs2
2008-12-14, 19:11
XBMC Can mount devices its disabled by default not to mess with the os.
Start xbmc with "xbmc --standalone" and it will work.

cyberwizzard
2008-12-14, 19:14
Looking into it further, I see that XBMC is issueing a 'pmount /dev/sdc1 STICKNAME' to the system. I am in the plugdev group so that shouldn't be the problem.

After looking into it further, /sys/block/sdc1/removable was '1' but calling pmount by hand gave me "Device is not removable". I even tried to use pmount-hal as I read somewhere that it ignores the sysfs data and asks HAL directly (lshal showed that indeed it detected the drive as being removable) and still it wouldn't work (it used pmount behind the scene and it did not override the removable command so ofcourse it did not work).

After finding this: https://bugs.launchpad.net/ubuntu/+source/pmount/+bug/296164 I concluded that this is a bug in Ubuntu 8.10 Intrepid which won't be solved for a long time. Because the problem seems to be related to the default kernel or (most likely in my opinion) to pmount itself, I discovered the following workaround:

Add this to '/etc/pmount.allow':
/dev/sd[a-z]?

This will whitelist the device as being removable even if the kernel and pmount as fighting over the details. Note that this will work for other linux distributions with the same issue (make sure the removable file in /sys contains '1' and 'pmount -d /dev/sd*1' tells you it is not) while upstream figures out what to do with it.

Tip: if you are running SATA or SCSI or even SAS you will probably have one or more /dev/sd* devices already. In my case I have '/dev/sda*' and '/dev/sdb*' so I exclude those drives from pmount:
/dev/sd[c-z]?

Technical remark: normally the hard drives in you PC will not trigger a HAL event of getting added as they are simply there. However I saw that repartitioning or modifying the partition layout sometimes will trigger HAL. If you did not exclude your hard drives from the pmount whitelist, they WILL be added as removable drives - something I don't want as rebooting my HTPC is the only option to get rid of them in XBMC.

cyberwizzard
2008-12-14, 19:17
XBMC Can mount devices its disabled by default not to mess with the os.
Start xbmc with "xbmc --standalone" and it will work.
Forgot to mention that I am running it already with the 'standalone' flag as I removed the window manager already :nod:

But as I posted a minute ago, I sort of figured out what went wrong and its not an XBMC issue (unless switching to pmount-hal and forcing the removable flag to create a workaround for the pmount/sysfs/kernel-bug in XBMC self is an option, which is not my idea of a solution).

topfs2
2008-12-15, 12:49
That explains why my interpid machine fails to mount with XBMC aswell. I only plugged in a USB drive once and just ssh and sudo mounted it and didnt think more of it. But then we are gonna have looots of users with this problem the following half year :)

Anyway, the weird thing is that it seems that gnome can mount them and I though they used pmount aswell?

EDIT: Just noticed your new to the forum, Welcome to the forum!

cyberwizzard
2008-12-15, 15:49
Cheers :grin:

I don't know why Gnome manages to mount the devices fine. They either use some custom code to detect the mount parameters from HAL or they don't use pmount at all.

I read somewhere that HAL can mount volumes as well and that gnome is using the HAL interface instead of invoking pmount under the hood; which would explain why the Intrepid bug tracker has only one mention of this instead of a ton of users complaining :)

Edit: Yup, according to the specs you can mount directly using HAL:
http://people.freedesktop.org/~david/hal-spec/hal-spec.html#interface-device-volume

topfs2
2008-12-15, 16:50
If thats the case then Ill try to alter the code to mount with hal instead of pmount, we use hal to recognise so we might aswell mount using it :)

Please feel free to open a ticket on this subject and refer to this thread and Ill try to fix it when my exams are over.

Thanx for a solid bugreport!

Cheers,
Tobias

cyberwizzard
2008-12-15, 17:17
I've created the ticket: http://xbmc.org/trac/ticket/5491

Good luck with your examns :)

topfs2
2008-12-21, 15:50
I´ve updated the code on http://xbmc.svn.sourceforge.net/viewvc/xbmc?view=rev&revision=16632

So if you could please try that on interpid that would be most wonderfull (I dont have it installed currently)

Cheers,
Tobias

cyberwizzard
2008-12-21, 17:17
I'm currently away from home but I'll test as soon as I get back or when I find the time to install Intrepid on a spare computer I have lying around.

Kudos for the quick fix btw, I tried hacking my own solution into XBMC and quickly drowned in all the docs between XBMC/C++/DBUS/HAL :cool:

topfs2
2008-12-21, 20:53
I'm currently away from home but I'll test as soon as I get back or when I find the time to install Intrepid on a spare computer I have lying around.

Kudos for the quick fix btw, I tried hacking my own solution into XBMC and quickly drowned in all the docs between XBMC/C++/DBUS/HAL :cool:

Hehe, no problem. When you get the time bump the ticket as fixed or not fixed and we will close or try again :)

XBMC source is quite big, and dbus is harsh to wrap your head around first time around. personally Im just beginning to like dbus :rolleyes:

cyberwizzard
2008-12-24, 00:58
I've updated the ticket and your HAL/DBUS patch worked :cool:

As I've stated in the ticket, the unmount caused an error - but I yanked the stick from the port so maybe that screwed it over.

Since the GUI is rendered in Mesa using a way old machine I confiscated I didn't try unmounting properly. How do I unmount the USB drive from the GUI without a mouse? I could test properly unmounting it that way.

topfs2
2008-12-24, 11:54
Ill have to dig abit deeper regarding the yanking and unmounting because pmount is able to handle this, thats why the code is in place, so we clear out any added paths in /media

Actually we cant unmount media properly in gui :sad: The addition to it in HalManager, and the dbus calls are simple. But I´ve hit a big snag adding it to the gui, mainly because Im not very read up on our guilib.

The plan is that it should be in before 9.04 atleast.

Thanx for testing and reporting such a good bugreport!

Merry Christmas,
Tobias

cyberwizzard
2008-12-24, 12:04
Ah, np :cool:

This is already a big plus AFAIK which should make the next release even better on linux.

Should you need me as a tester in the future, just ask :laugh: Kudos for the fix and merry christmas to you as well.

queeup
2009-02-24, 18:23
I want hal mount message pop upper right corner not bottom right corner. Is it possible?

queeup
2009-02-25, 00:02
nevermind i found it.
/usr/share/xbmc/skin/PM3.HD/720p/DialogKaiToast.xml:
<window id="107">
<include>dialogeffect</include>
<coordinates>
<system>1</system>
<posx>850</posx>
<posy>630</posy>
</coordinates>
to
<window id="107">
<include>dialogeffect</include>
<coordinates>
<system>1</system>
<posx>850</posx>
<posy>25</posy>
</coordinates>

<posy>630</posy> to <posy>25</posy> thats what i need.