Howto mount your HTC One phone with openSUSE

HTC One is using PTP (Picture Transfer Protocol) when attached to the USB port. Some special steps are required to mount it read/write.

1. Packages to install:

**2. Add a new configuration file for udev
**
Change into directory /etc/udev/rules.d/ and add a new file. Name this file 98-htcone.rules

Use your favorite editor (joe, nano or whatever you like) and copy the following contents into 98-htcone.rules. You must be root to do so.

ACTION!="add", GOTO="htcone_rules_end"
ENV{MAJOR}!="?*", GOTO="htcone_rules_end"
SUBSYSTEM=="usb",  GOTO="htcone_usb_rules"
GOTO="htcone_rules_end"

LABEL="htcone_usb_rules"

# HTC One_M7 MTP
ATTR{idVendor}=="0bb4", ATTR{idProduct}=="0dea", SYMLINK+="libmtp-%k", MODE="0666", ENV{ID_MTP_DEVICE}="1", ENV{ID_MEDIA_PLAYER}="1"

# HTC One_M7 MTP+ADB
ATTR{idVendor}=="0bb4", ATTR{idProduct}=="0dea", SYMLINK+="libmtp-%k", MODE="0666", ENV{ID_MTP_DEVICE}="1", ENV{ID_MEDIA_PLAYER}="1"

LABEL="htcone_rules_end"

Now, still as user root, activate the new rule:

# udevadm control --reload-rules

3. Let it work

Now your HTC One should be automatically detected by the system when you plug it in. Mount it to some directory within your $HOME. No root privileges are required to do this but the directory serving as mount point must exist.

simple-mtpfs ~/mymountdirectory

To unmount the phone do:

fusermount -u ~/mymountdirectory

For convenience you can copy the following shell script to ~/bin/ and name it htcmount (make it executable with: chmod +x htcmount). Create a symbolic link to the script with the name htcumount (ln -s ~/bin/htcmount ~/bin/htcumount). Then you can just type htcmount to mount the phone and htcumount to unmount it again.

#!/bin/bash
# mount or umount HTC One phone
# Copyright (c) 2013, vodoo@vakw.ch
# Licence: 2-Clause BSD
MYNAME=$(basename "$0")
MYHOME=$(echo ~)
MNTDIR="$MYHOME/htcone"

if test "$MYNAME" == 'htcmount' ; then
        MNTMSG=$(mount | sed -e "\\|^simple-mtpfs on $MNTDIR|!d")
        if test -n "$MNTMSG" ; then
                echo "HTC One is already mounted on $MNTDIR"
                exit 1
        fi
        if ! test -d "$MNTDIR" ; then mkdir -p "$MNTDIR" ; fi
        if simple-mtpfs "$MNTDIR" 2>&1 >/dev/null | sed \
                -e '\|^Unable to open ~/\.mtpz-data|d' \
                -e '\|^fuse: warning: library too old|d' ; then
                echo "HTC One is available at $MNTDIR"
        else
                echo "Command: simple-mtpfs $MNTDIR failed"
        fi
elif test "$MYNAME" == 'htcumount' ; then
        if fusermount -u "$MNTDIR" ; then
                echo 'HTC One has been unmounted'
        else
                echo "Command: fusermount -u "$MNTDIR" failed"
        fi
else
        echo "htcmount was invoked by unknown name $MYNAME"
fi

Have a lot of fun!

After a software update of the phone I found that the udev rules as described above did no longer work. As it turned out, the idProduct number had changed. Adapting the udev file to the new number corrected the problem. I had to change ATTR{idProduct}==“0dea” to:

ATTR{idVendor}=="0bb4", ATTR{idProduct}=="0f91", SYMLINK+="libmtp-%k", MODE="0666", ENV{ID_MTP_DEVICE}="1", ENV{ID_MEDIA_PLAYER}="1"

To determine your correct settings, run **dmesg **as root after connecting your phone and look for idVendor= and idProduct=. Use the detected id numbers in your **98-htcone.rules file.

**