On a Ubuntu 16.04 Desktop, I have a phone that is mounted using MTP as soon as I plug it in. I don't want this to happen, I actually just want it to charge off my computer's USB power. When I plug other devices in, I do want them to automount so I only want to stop the default action for this specific device.
How can I accomplish this?
Best Answer
First, find the VendorID and ProductID of the device using
lsusb
. For my Samsung Galaxy S7 Edge, the appropriate line is below.You also need the directory associated with where this device is plugged in. You can go hunting around
/sys/bus/usb/devices/*/idProduct
manually, or you can use this quick little script by @radu-rădeanu.Save this to ~/bin/findUSBbyID.sh and
chmod +x
it.Run it as
~/bin/findUSBbyID.sh 04e8 6860
. The output will look somthing like this:With this information you want to create a new file called
/etc/udev/rules.d/90-disable-usb-device.rules
. You'll need root permissions sosudo
orgksudo
your favorite editor as appropriate.The file should contain one line like below. Correct the VendorID and ProductID to match your device. Also correct the
/sys/bus/usb/devices/$something/authorized
path to match your product as found with the findUSBbyID.sh script.You may get another popup "Unable to mount an MTP device". That issue is being discussed here.