Removable drives and media do not automatically mounted at boot

Bug #1312641 reported by Alad Wenter
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Thunar Volume Manager
Confirmed
Medium
thunar-volman (Ubuntu)
New
Wishlist
Unassigned

Bug Description

Similar to:

https://bugs.launchpad.net/ubuntu/+source/thunar-volman/+bug/1210898

An update was provided with 0.8.0-4ubuntu1, but devices are still not automounted at boot or login.

ProblemType: Bug
DistroRelease: Ubuntu 14.04
Package: thunar-volman 0.8.0-4ubuntu1
ProcVersionSignature: Ubuntu 3.13.0-24.46-generic 3.13.9
Uname: Linux 3.13.0-24-generic i686
ApportVersion: 2.14.1-0ubuntu3
Architecture: i386
CurrentDesktop: XFCE
Date: Fri Apr 25 12:24:38 2014
InstallationDate: Installed on 2014-04-20 (4 days ago)
InstallationMedia: Xubuntu 14.04 LTS "Trusty Tahr" - Release i386 (20140416.2)
SourcePackage: thunar-volman
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
In , Vaxon77 (vaxon77) wrote :

I have "Mount removable drives when hot-plugged" option enabled.
However, thunar-volman fails to mount any removable media.

I've made the following script as a workaround for the issue:

cat /usr/local/bin/thunar-volman
#!/bin/sh
sleep 1
exec /usr/bin/thunar-volman $@ >/tmp/thunar-volman.log 2>&1

Mount succeeds if thunar-volman is started after a small delay.
If I comment "#sleep 1", mount fails and the output of /tmp/thunar-volman.log looks as follows:
cat /tmp/thunar-volman.log
thunar-volman: Could not detect the volume corresponding to the device.

/usr/bin/thunar-volman --version
thunar-volman 0.8.0 (Xfce 4.10)

Copyright (c) 2004-2007 Benedikt Meurer <email address hidden>
Copyright (c) 2010-2011 Jannis Pohlmann <email address hidden>

All rights reserved.

Please report bugs to <http://bugzilla.xfce.org/>.

Thanks,
Val.

Revision history for this message
In , Vaxon77 (vaxon77) wrote :

The problem seems to be in the inconsitency between thunar and thunar-volman.

Thunar seems to be using UDEV events to detect device add/remove, while thunar-volman uses GVolumeMonitor to find a volume corresponding to the added device and mount it. The problem is gvolume monitor has not set-up the new device volume by the time thunar-volman is started. Obviously UDEV events are emitted first and there's no guarantee GVolumeMonitor manages to set up a volume fast enough for thunar-volman to use it.

I'm not thunar expert, but probably the best way to fix it would be to use the the same event monitoring mechanism in both thunar and thunar-volman. For example, if thunar started thunar-volman based on GVolumeMonitor "volume-added" events AOT UDEV device add events, thunar-volman would detect the volume and mount it without any problems.

Thanks,
Val.

Revision history for this message
In , Mati86dl (mati86dl) wrote :

Confirm it.
Inspire in thunar-volman code now try to add support to remobable devices in pragha, and I found this problem.

Now I did a quick test, and adding a sleep (5) before tvm_g_volume_monitor_get_volume_for_kind, solves all the problems.

ONLY A TEST!.

Revision history for this message
In , Mati86dl (mati86dl) wrote :

Created attachment 4608
Mount devices with a timeout of 5 seconds.

Tested in Fedora 17 with xfce 4.10.
Only wait 5 seconds to make sure that glib detect the volume.

Revision history for this message
In , Andriy Yurchuk (ch00k) wrote :

Auto-mounting worked fine in 4.8. What has changed since then? Maybe

Revision history for this message
In , Peter F. Patel-Schneider (pfpschneider) wrote :

Adding a sleep at the beginning of twm_block_device_mount doesn't work for me. However, adding a sleep in main() does.

Further, adding a loop inside twm_block_device_mount with a sleep and retry of the tvm_g_volume_monitor_get_volume_for_kind doesn't help at all, even when the total delay runs into several minutes, and even when a new volume monitor is created.

I find this very strange - it is almost as if the contents of the volume monitor are fixed at thread invocation time and can't change thereafter. There is something about volume monitor not being thread-safe, but I don't understand just what this means.

Revision history for this message
In , Philipp (flashdoebi) wrote :

I have the same problem in Xubuntu 12.10 with XFCE 4.10.
With the workaround it seems to work now.

Thanks to vaxon77

Revision history for this message
In , programmist11180 (programmer11180) wrote :

Debian Wheezy, XFCE 4.10. When gvfs 1.16 and udisks2 2.1 is installed, Thunar mounts cd/dvd only if xfburn is launched. Mounts work normal with gvfs 1.12 and udisks 1.0.4

Revision history for this message
In , Alexander (alexkalachev) wrote :

(In reply to programmist11180 from comment #7)
> Debian Wheezy, XFCE 4.10. When gvfs 1.16 and udisks2 2.1 is installed,
> Thunar mounts cd/dvd only if xfburn is launched. Mounts work normal with
> gvfs 1.12 and udisks 1.0.4

I have experienced the same problem with the software you mentioned. Also, I couldn't mount my android phone to. When I've downgraded gvfs and udisks to debian's 'stable' branch, i.e. gvfs 1.12 and udisk 1.0.4, I've got automount worked both for cd/dvd and android phone.

Revision history for this message
In , Peter F. Patel-Schneider (pfpschneider) wrote :

Is there any further investigation of this problem?

Revision history for this message
In , programmist11180 (programmer11180) wrote :

The problem remains when using gvfs of version 1.18.2-2

Revision history for this message
In , Peter F. Patel-Schneider (pfpschneider) wrote :

I compiled the patch in comment 3, which appears to fix the problem, at the cost of a delay in mounting.

Revision history for this message
In , programmist11180 (programmer11180) wrote :

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=725978
CD/DVD/ any optical disk mount can be broken by udisks2.

Revision history for this message
In , programmist11180 (programmer11180) wrote :
Revision history for this message
In , programmist11180 (programmer11180) wrote :

A simple way to fix CD/DVD mount and others with udisks2: add to /etc/rc.local:

echo 2000 > /sys/module/block/parameters/events_dfl_poll_msecs

and reboot (Or, if you don't want to reboot now, you can execute this command from the root).

See for more details:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=725978
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=713877

Revision history for this message
In , Alejandro Perez (alejandro-perez-mendez) wrote :

I have the exact same problem, that gets fixed either with the script or the patch (setting it to 1s, instead of 5s).

Please, fix this issue :)

Besides, I detected that thunar needs to be running, either as a daemon or a window open.

Revision history for this message
In , P-willaime (p-willaime) wrote :

I'm also affected by this bug.

Why nobody fix thunar-volman? The bug report is open since 2012....

Revision history for this message
In , Alejandro Perez (alejandro-perez-mendez) wrote :

I desisted and started using udiskie instead. Never had a problem again.

Revision history for this message
In , adam jvok (ajvok1) wrote :

Still a problem

$ thunar-volman -V
thunar-volman 0.8.0 (Xfce 4.10)

$ thunar -V
Thunar 1.6.3 (Xfce 4.10)

Please fix.

Revision history for this message
Alad Wenter (the-changing-side) wrote :
summary: - Removable drives and media not automatically mounted at boot
+ Removable drives and media do not automatically mounted at boot
Revision history for this message
Thaddaeus Tintenfisch (thad-fisch-deactivatedaccount) wrote :

This seems to be the expected behavior as of now. The problem has been discussed upstream [1] and possible fixes or workarounds do exist.

[1] https://bugzilla.xfce.org/show_bug.cgi?id=3490

Pasi Lallinaho (knome)
Changed in thunar-volman (Ubuntu):
importance: Undecided → Wishlist
Changed in thunar-volman:
importance: Unknown → Medium
status: Unknown → Confirmed
Revision history for this message
In , Mati86dl (mati86dl) wrote :

Hi there.
I wrote the proposed patch, but honestly not recommend it..

This may solve the problems, but it really is not a problem of thunar!. it's definitely a problem between udev/udisk and glib!.

Please, Those who have problems, test the comented on:

https://bugzilla.xfce.org/show_bug.cgi?id=9193#c14

With it work properly, and no require changes in any code..

Revision history for this message
In , Peter F. Patel-Schneider (pfpschneider) wrote :

https://bugzilla.xfce.org/show_bug.cgi?id=9193#c14

doesn't work reliably for me. It may be that it doesn't help at all, except to cause the race condition to sometimes come out the "right" way.

The problem is still active with Thunar 1.6.6 and thunar-volman 0.8.0. I'm going to try to add some patches to the current versions.

Revision history for this message
In , Peter F. Patel-Schneider (pfpschneider) wrote :

My patch that tries to get the volume up to three times, with a 1-second delay between each time, hides the problem successfully.

However, a better solution would be to have thunar-volman only called when the volume has been set up. This is known, as the volume has to be set up for the icon to appear on the desktop.

Revision history for this message
In , Mati86dl (mati86dl) wrote :

> https://bugzilla.xfce.org/show_bug.cgi?id=9193#c14
>
> doesn't work reliably for me. It may be that it doesn't help
> at all, except to cause the race condition to sometimes come
> out the "right" way.

I honestly do not know. In the latest versions of fedora not
have problems and use this change by default.. :S

On thunar volman 0.8.1 added my patch.. :S

http://git.xfce.org/xfce/thunar-volman/commit/?id=f3f8ba9d92923492d93672676dffc5f65c068ea9

As they added to the patch, Please at least reduce the time to one or two seconds. 5 seconds is completely unnecessary.

Revision history for this message
In , Peter F. Patel-Schneider (pfpschneider) wrote :

I see that 0.8.1 has your patch.

I think that better than waiting 1 second would be to try immediately and only then wait for a bit. I modified the code accordingly, ending up with

static gboolean
tvm_block_device_mount_volume (TvmContext *context, GVolume *volume)
{
  GMountOperation *mount_operation;

  /* check if we have a volume */
  if (volume != NULL)
    {
      /* check if we can mount the volume */
      if (g_volume_can_mount (volume))
        {
          /* try to mount the volume asynchronously */
          mount_operation = gtk_mount_operation_new (NULL);
          g_volume_mount (volume, G_MOUNT_MOUNT_NONE, mount_operation,
                          NULL, (GAsyncReadyCallback) tvm_block_device_mount_finish, context);
          g_object_unref (mount_operation);
        }
      else
        {
          g_set_error (context->error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
                       _("Unable to mount the device"));

          /* finish processing the device */
          tvm_device_handler_finished (context);
        }
    }
  else
    {
      g_set_error (context->error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
                   _("Could not detect the volume corresponding to the device"));

      /* finish processing the device */
      tvm_device_handler_finished (context);
    }
    return FALSE;
}

static gboolean
tvm_block_device_mount_retry (TvmContext *context)
{
  GVolume *volume;

  volume =
    tvm_g_volume_monitor_get_volume_for_kind (context->monitor,
                                              G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE,
                                              g_udev_device_get_device_file (context->device));

  /* if no volume then call anyway to do not-found processing */
  tvm_block_device_mount_volume (context,volume);
  return FALSE;
}

static gboolean
tvm_block_device_mount (TvmContext *context)
{
  GVolume *volume;

  g_return_if_fail (context != NULL);

  /* determine the GVolume corresponding to the udev device */
  volume =
    tvm_g_volume_monitor_get_volume_for_kind (context->monitor,
                                              G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE,
                                              g_udev_device_get_device_file (context->device));
  if (volume != NULL)
    {
      tvm_block_device_mount_volume(context,volume);
    }
  else
    {
      /* clean up and try again in one second */
      g_object_unref (context->monitor);
      context->monitor = g_volume_monitor_get ();
      g_timeout_add_seconds(1, (GSourceFunc) tvm_block_device_mount_retry, context);
    }
  return FALSE;
}

What's the best way to get this put into thunar-volman?

Revision history for this message
In , Mati86dl (mati86dl) wrote :

> I see that 0.8.1 has your patch.

Yes .. Even though I recommended do it. hah :S

> I think that better than waiting 1 second would be to try
> immediately and only then wait for a bit. I modified the
> code accordingly, ending up with

Looks better.. =)

> What's the best way to get this put into thunar-volman?

Clone the repo, commit your change with a good description
and make a patch from this commit. ;)

Then attach it here.

If you doubt, do it with a graphical interface as gitg- =)

Regards.

Revision history for this message
In , Peter F. Patel-Schneider (pfpschneider) wrote :

Created attachment 6191
Try to get GVolume right away and only if that fails wait for 1 second

This should change the total delay from 5 seconds per partition to at most 1 second for an entire physical device.

Revision history for this message
In , Peter F. Patel-Schneider (pfpschneider) wrote :

OK, done.

Hopefully this will get picked up faster than your patch.

Revision history for this message
In , Peter F. Patel-Schneider (pfpschneider) wrote :

No action yet that I can see. Does anyone know how to get this patch looked at? The current setup with its 5 second delay is getting annoying.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.