1

I'm running Ubuntu 14.10 on my netbook, and connect my iPhone via USB cable so that it tethers and I can access the internet. This all works as expected.

The issue is that when the iPhone is unplugged from the USB cable, it doesn't unmount properly, so when the iPhone is next plugged in, a message box appears with the following text:

Unable to mount iPhone
Location is already mounted

Unplugging and replugging my iPhone throughout the day results in lots of these message boxes appearing.

The output of mount when the iPhone is plugged in includes the following:

gvfsd-fuse on /run/user/1000/gvfs type fuse.gvfsd-fuse

This line is still there after the iPhone is unplugged. If I manually umount that location, then the message does NOT appear when the iPhone is next plugged in:

sudo umount /run/user/1000/gvfs

Is there any way (maybe through udev) to automate this?

2

I've found a way to automate this. The issue was that gvfs-mount -l still showed a mount (afc://<iPhone_serial_number>/) even after the iPhone had been unplugged. It was this mount that triggered the Unable to mount iPhone message when the iPhone was plugged back in. This mount was provided by the gvfsd-afc gvfs backend. Killing gvfsd-afc removes the mount.

To make udev do this automatically when the iPhone is unplugged, create a file /etc/udev/rules.d/99-iphone-umount.rules and add the following:

SUBSYSTEM=="usb", ACTION=="remove", ENV{ID_MODEL}=="iPhone", RUN+="/usr/bin/killall -s SIGINT /usr/lib/gvfs/gvfsd-afc"

Then run sudo udevadm control --reload-rules to get udev to load the new rule.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.