Mounting MTP Devices on Linux

Windows 11 原生 Linux 容器正式发布,不再需要 Docker Desktop 微软正式发布WSL容器,无需Docker Desktop即可在Windows原生运行Linux容器。通过wslc命令(替代docker)可直接构建、运行和部署容器,支持CLI与API两种方式,适用于本地AI、云应用等场景。使用上,wslc run --rm hello-world即可启动首个容器,镜像默认从DockerHub拉取,体验更轻量高效。 阅读详情

1. Overview

The Media Transfer Protocol (MTP) is a protocol that enables us to transfer data between two devices. MTP is primarily used in devices running the Android operating system.

In this article, we’ll discuss how we can mount the MTP devices under Linux. We’ll cover the gvfs-mtp package, which comes with most major Linux distributions. Afterward, we’ll take a look at the jmtpfs, which allows us to mount and unmount MTP devices using the command line.

2. GVfs

GNOME Virtual File System (GVfs) is a userspace virtual filesystem wrapper around the GNOME Input-Output (GIO) library. GVfs abstracts the inner workings of the GIO library, allowing us to access various filesystems and services without any special technical knowledge.

2.1. gvfs-mtp

GVfs comes with several backends for file systems and services like Apple Mobile Devices (AFC), Google Online Accounts (GOA), and SMB. One of these modules is gvfs-mtp.

The gvfs-mtp module is designed to work solely with MTP devices. It lets us access the MTP devices through a FUSE file system.

2.2. Installation

If we’re on the GNOME desktop environment, chances are we have gvfs-mtp already installed. However, if that’s not the case, we can install it from our distro’s official package repository using a package manager:

# Ubuntu-based
$ apt install gvfs-mtpCopy
# Fedora and RHEL
$ dnf install gvfs-mtpCopy
# Arch-based
$ pacman -S gvfs-mtpCopy

2.3. Connecting the MTP Device

Before we connect our device using MTP:

  • our device screen needs to be unlocked first for security reasons
  • our device should allow the required privileges to be mounted
  • the device should be connected via a USB data cable

Once that’s done, we’ll check whether our device is successfully connected to our machine using lsusb:

$ lsusb | grep -i smartphone
Bus 001 Device 006: ID 12d1:107e Huawei Technologies Co., Ltd. P10 smartphoneCopy

Alternatively, we can also use gio to detect our device:

$ gio mount -li | grep activation_root
activation_root=mtp://HUAWEI_HUAWEI_VNS-L21_BUC4C16523021942/Copy
  • mount is a sub-command that we can use to mount devices
  • -l lists all the mountable devices
  • -i prints out a detailed report of each mountable device

If you don’t see your device, refer to system logs to troubleshoot any issues.

2.4. Mount MTP Device Using the CLI

With the gvfs-mtp package installed, we can now mount our MTP device either using the gio utility or a graphical file manager such as GNOME Files.

We can mount our device using the path found in the activation_root field of the gio command:

$ gio mount "mtp://HUAWEI_HUAWEI_VNS-L21_BUC4C16523021942/"Copy

Now, we can access our mounted device using the directory that begins with the mtp:host= directory located in /run/user/$UUID/gvfs:

$ ls -l /run/user/1000/gvfs
2 dr-x------ 1 hey hey 0 Jan  1  1970 'mtp:host=HUAWEI_HUAWEI_VNS-L21_BUC4C16523021942'Copy

Alternatively, we can also mount our device using the Bus and Device Number found in the lsusb output:

$ gio mount "mtp://[usb:001,006]/"Copy

2.5. Unmount MTP Device

We can unmount the device using the -u or –unmount flag of the mount sub-command:

$ gio mount -u "mtp://HUAWEI_HUAWEI_VNS-L21_BUC4C16523021942/"Copy

2.6. Mounting MTP Devices in File Manager

File managers that support GVfs will try to automount the MTP device — depending on how the distro is configured.

However, we can easily mount the MTP device with a click, as we can see in the following illustration:

Similarly, we can unmount the device using the eject button shown to the right of the device label.

3. jmtpfs

jmtpfs is a lightweight utility based on libmtp, which we use to read and write data to MTP devices.

3.1. Installation

By default, Linux distros don’t come with jmtps, and it’s not available on most package repositories. Therefore, we need to build it from the source.

Before we install jmtpfs, we should install the libmtp dependency from the official package repository using a package manager.

Now, let’s clone the jmtpfs repository:

$ git clone https://github.com/JasonFerrara/jmtpfsCopy

Now, let’s configure and compile jmtpfs:

$ ./configureCopy
$ makeCopy
$ make installCopy

Once that’s successful, let’s verify it:

$ jmtpfs
jmtpfs version: 0.5Copy

3.2. Mounting

By default, MTP devices are only readable/writable by root users. Therefore, we should first allow other users to read and write to the MTP devices.

So, uncomment the user_allow_other option in the /etc/fuse.conf file:

$ sed -i '/user_allow_other/s/^#//g' /etc/fuse.confCopy

Now, we’re going to mount our MTP device on a directory that has read and write permissions:

$ jmtpfs ~/mtpCopy

3.3. Unmounting

Similarly, we can unmount our device using fusermount:

$ fusermount -u ~/mtpCopy

3.4. Coherence with the Rest of Linux

Additionally, we can make this mount process cohere with the rest of Linux — allowing us to use the regular mount and unmount commands.

First, we’ll create a soft symbolic link of jmtpfs. The link’s name is going to be consistent with the Linux mount conventions like mount.jmtpfs:

$ ln -s /usr/local/bin/jmtpfs /usr/local/bin/mount.jmtpfsCopy

Then, we’ll add an entry for our MTP device in the fstab file:

jmtpfs /home/user/mtp fuse nodev,allow_other,rw,user,noauto,noatime,uid=1000,gid=1000    0    0Copy

Now, we’re ready to mount our device using mount:

$ mount /home/user/mtpCopy

Similarly, we can now unmount our device with umount:

$ umount /home/user/mtpCopy

4. Conclusion

In this article, we covered how we can mount and unmount MTP devices under Linux. We briefly went over what GVfs is and how we can use its gvfs-mtp module to mount and unmount MTP devices in the CLI and File managers.

Finally, we covered the alternative jmtpfs utility to mount and unmount MTP devices and how we can make this utility blend with the Linux mounting convention.

防火墙断网后Adobe软件还弹窗“THIS APP HAS BEEN DISABLED”?原来是科学上网导致的问题!用这个简单方法一键解决! 很多小伙伴在使用上网工具的时候时,突然遇到Adobe弹出“THIS APP HAS BEEN DISABLED”的烦人提示,这个非正版弹窗真的让人头疼!即使你之前尝试过,有时也不奏效,究其原因,原来是因为你使用了代理网络,这时Adobe的流量并不是走本地,而是走代理,导致防火墙的拦截无效。不用慌!今天我来教大家如何通过上网工具,轻松禁用Adobe验证的联网流量,彻底解决这个问题! 阅读详情

相关推荐

开发者的避坑指南:在Apple Silicon Mac上构建RocketMQ Python客户端的完整心路历程

本文详细记录了在Apple Silicon Mac上构建RocketMQ Python客户端的完整过程,重点解决了架构兼容性问题。通过源码编译rocketmq-client-cpp库,修复构建脚本和CMake配置,最终成功在M2芯片MacBook Pro上部署RocketMQ Python客户端,为开发者提供了实用的避坑指南。

Pepper的专栏 697

linux下挂载mtp设备(nexus7)

在Ubuntu挂载使用MTP设备步骤如下: 1.将MTP设备连接至PC机 2.如果是第一次使用MTP设备需要安装以下软件,否则可以跳过此步骤: $ sudo apt-get install mtpfs libfuse-dev libmad0-dev 建立挂载点 $ sudo mkdir /media/nexus7  修改权限 $ sudo chmo

chyxwzn的专栏 7042

新手小白 必须精进的 “ FLASH分区管理Code and Data ” !!!最强文章解析!!!

FLASH“代码区”和“数据区”不是每个项目都必须显式管理,但只要你的产品功能越来越丰富,对可靠性和扩展性要求提高,就一定要学会科学划分和使用。这也是嵌入式工程师进阶路上的必修课!

qq_75157958的博客 938

安卓手机用USB连接电脑,ADB报错:No devices/emulators found,大白话详细分析、解决全过程

摘要: 安卓手机通过USB连接电脑使用ADB传输文件时,常见报错“no devices/emulators found”表示电脑未检测到设备。主要原因包括:1)USB线/接口故障(需更换数据线或接口);2)未开启手机开发者选项和USB调试(需连续点击版本号激活开发者模式并开启调试);3)电脑驱动或ADB环境异常(需安装对应驱动并配置ADB工具);4)连接模式错误(需选择文件传输模式);5)权限未授权(需点击手机弹窗允许连接)。解决时建议按步骤排查物理连接、手机设置、驱动安装和权限授权,并通过adb devi

本博客聚焦游戏开发技巧、创业实战心得及大学热门课程干货。这里既有技术深度,也有思维广度,无论你是开发者、创业者还是高校学子,都能在这里找到适合自己的成长之路! 5246

手把手教你用差分放大电路搭建LC振荡器(实测频率误差分析)

本文通过一个差分放大电路搭建LC振荡器的实践案例,深入分析了实测频率与理论值产生显著误差的原因。核心在于共模电感的互感效应改变了谐振回路的等效电感,导致频率偏差。文章提供了从电路搭建、误差根源剖析到波形优化与稳定性提升的完整解决方案,帮助电子爱好者深入理解模拟电路的实际行为。

svm4gardener的博客 550

【强化学习】强化学习中,训练过程的稳定性是什么?该如何进行衡量?请详细进行解释

在强化学习中,训练过程的稳定性指的是算法在训练过程中表现出一致的行为,并且能够稳定地收敛到一个好的策略。收敛性:算法是否能够在有限的时间内收敛到一个近似最优的策略。鲁棒性:算法在不同的初始条件或环境扰动下的表现是否稳定。方差:算法在多次运行中表现出的变异程度。稳定的训练过程意味着算法的训练曲线平滑奖励信号变化小,且策略或价值函数的变化是渐进的。

wq6qeg88的博客 1632

FastAPI实战指南:构建企业级博客平台的技术精髓

在众多FastAPI学习资源中,fastapi-realworld-example-app以其完整性和实用性脱颖而出。这个项目不是简单的"Hello World"示例,而是一个功能完备的博客平台后端实现,完全遵循RealWorld API规范。这意味着你学到的不仅是FastAPI语法,更是构建生产级应用的全套方法论。 **核心价值点**: - 🚀 **完整API规范实现**:覆盖用户认证、文章

gitblog_00843的博客 700

手把手教你设计T型和Π型衰减器:从分贝计算到电阻选型全攻略

本文提供了一份T型和Π型衰减器的详细设计指南,涵盖从分贝计算到电阻选型的全过程。文章以50欧姆系统为例,通过公式推导和实例演示,手把手教你计算两种经典拓扑的电阻值,并深入探讨了电阻选型、误差控制及高频应用等关键实践技巧,帮助工程师和爱好者精准实现信号衰减与阻抗匹配。

blue42的博客 1350

linux下device识别不了,ADB不识别device not found

ADB不识别device not found,以下是5条简单方法:1.手机usb 数据线连接pc咯,在设备管理器里看看有没的黄色的未安装驱动的设备,有的话就把手机驱动拿过来装下(尽量多刷新几次)。2.在cmd里直接adb shell,有问题的话会出现"device notfound",我呢,参考网上的说法“adbkill-server”再"adbstart-server"..算是一种方式吧。3....

weixin_28778341的博客 1819

Unity GameObject 核心机制深度解析:从底层结构到工程实践

从底层机制讲透 Unity GameObject:托管壳加原生芯的双层对象模型如何制造假 null 陷阱、Transform 层级与组件通信的原理、生命周期回调的确切顺序。文章同时给出 Instantiate 成本分析与对象池等高频场景的工程实践。

游戏人生 44

AUTOSAR知识点 之 XCP (二):XCP基础概念

学习XCP的过程中,对XCP的基本概念要做一个全面的认知,因为里面有很多缩写以及难以理解的点,假设对此模模糊糊一知半解,那么对整个协议栈的认知会遇到极大的障碍。XCP的信号流传输图示如下XCP 标准主要分为 5 个部分:这部分提供了对于协议的一个概况介绍,包括 XCP 的功能和基础性内容。这部分内容对协议层进行了详细的规范和说明。

梦想技术家 2774

ubuntu下面挂载mtp设备的目录位置

/run/user/1000/gvfs/mtp:host=%5Busb%3A003%2C029%5D/内部存储设备/我的手机是没有SD卡的,每次都找不到,记录一下这个位置

嵌入式Linux 3421

多思计组实验实验三、存储器读写实验

实验三、存储器读写实验

qq_53089329的博客 3656

linux挂手机mtp下载,ubuntu下挂载mtp

该楼层疑似违规已被系统折叠隐藏此楼查看此楼参考:http://bbs.anzhi.com/thread-9058321-1-1.html1.检查安装依赖库$ sudo apt-get udpate$ sudo apt-get install libmtp-common mtp-tools libmtp-dev libmtp-runtime libmtp9$ sudo dist-upgrade2....

weixin_36245958的博客 690

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

全球国家地区城市数据

MySQL全球国家地区城市数据报。。。。。。。。。。。。

魅蓝note2在ubuntu14.04下mtp模式无法自动mount的解决方法

是因为新机型没在列表里的原因。 处理方法如下: As far as I know, MTP works fine in Trusty. You can try this: Uncomment #user_allow_other in /etc/fuse.conf. Run lsusb and see your device's vendor ID. It will be so...

weixin_30920853的博客 151

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

Linux mtp路径,Ubuntu挂载使用Android 3.0+ MTP设备

在Ubuntu挂载使用MTP设备步骤如下:1.将MTP设备连接至PC机2.如果是第一次使用MTP设备需要安装以下软件,否则可以跳过此步骤:$ sudo apt-get install mtpfs libfuse-dev libmad0-dev建立挂载点$ sudo mkdir /media/mtp修改权限$ sudo chmod 775 /media/mtp3.挂载MTP设备$ sudo mtpf...

weixin_42355003的博客 1276

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

在linux下挂载android的mtp设备

mtp应该是android的4.0以上版本的新功能。取代了传统的U盘挂载方式。 以下照抄原文: http://www.miui.com/thread-960449-1-1.html Android3.x 以上使用了 MTP 协议连接移动设备的内部存储,在 Windows 上可以很方便的打开 MTP 设备,而在 Mac 上 google 提供了一个

linux内核探索 1万+

Linux 动静态库从入门到精通(一):库的制作使用与 ELF 文件基础

本文为 Linux 动静态库系列第一篇,从库的基础概念出发,讲解 Linux 下静态库 (.a) 与动态库 (.so) 的定义,手把手演示二者的制作步骤与三种场景下的使用方法,梳理编译核心参数,给出动态库运行时找不到的四种解决方案,结合 ncurses 库提供实操练习。同时引入 ELF 文件格式,讲解其四种类型、核心结构、常见节的作用,辨析节与段、链接视图与执行视图的区别,为第二篇深入底层原理打下基础。

2402_88289386的博客 223

进程间通信三大易混点辨析:管道、信号、信号量、共享内存

(欢迎来访)✨。

lihaoweiwudi_的博客 1014

【Linux】37:应用层协议HTTP

本文系统介绍了HTTP协议的核心概念与实现原理。HTTP作为应用层协议,定义了客户端与服务器间的通信规范,基于TCP传输,具有无连接、无状态特性。文章详细解析了URL结构、请求/响应格式、HTTP方法(GET、POST等)、状态码(如200、404、302)及关键报头字段(如Content-Type、Connection)。通过代码实践,展示了如何构建简易HTTP服务器,实现资源读取、路径映射、重定向与错误处理,并强调了序列化/反序列化、Content-Length校验与跨域支持的重要性,全面呈现了HTTP

qq_62473190的博客 180

把 Ghostscript 迁到鸿蒙 PC:从 Linux 命令行到 libgs + NAPI + ArkUI

Ghostscript 原本是 Linux/Unix 下的命令行程序。它没有独立 GUI,真正的核心是 PostScript/PDF 解释器、PDF writer、图像设备、字体和 Resource。本文按实际迁移顺序记录工程环境、原生库编译、NAPI 桥接、系统能力替换、应用构建和验证结果。

池央的博客 2001

Linux与Shell编程(第五章)

本章介绍Linux中常用的打包与压缩命令。使用tar -cvf打包文件或目录为.tar格式,tar -xvf解包;结合-z选项可实现gzip压缩(.tar.gz),-j选项实现bzip2压缩(.tar.bz2)。通过实例练习掌握打包、解包及指定路径操作,理解打包与压缩的区别,熟练运用tar命令完成文件管理任务。

u013699308的博客 131

Linux 使用手册

学习记录

YWX_XX的博客 209

linux快速入门 2:简单的手动命令行文件日常备份 (****)

linux快速入门 2:简单的手动命令行文件日常备份 (****)

ken2232的博客 200

Linux UDP Socket

掌握 UDP 基本收发流程;:掌握业务回调和解耦设计;InetAddr:掌握 IP、端口与网络字节序转换;客户端 bind 问题:理解“需要绑定但不显式绑定”;INADDR_ANY:理解服务器绑定所有网卡地址的意义。如果用一个公式概括:UDP 服务器 = socket + bind + recvfrom + 业务处理 + sendtoUDP 客户端 = socket + sendto + recvfrom。

Diopeng_out的博客 189

【Linux】#13 | 网络传输

作用:检测目标主机是否可达、网络是否通畅 :指定发送次数,不加会一直 ping 参数:目标 IP 或者域名 示例: 二、wget 命令下载文件 非交互式命令行下载工具 :后台下载,日志输出到 :资源下载地址 查看后台下载日志: 三、curl 发起网络请求 功能:发送 HTTP 请求、获取网页内容、下载文件 :下载文件,按远程文件名保存 :请求地址 常用示例: 等价于浏览器发起请求,可看返回内容。端口是设备对外通信的出入口,分为物理端口、虚拟端口。比

2503_92676540的博客 153
上一篇: Easily Manage Remote Filesystems with Gigolo In Linux
下一篇: 第 6 章 管理 GNOME 中的存储卷
allway2
博客等级 码龄16年 6719粉丝 8009原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值