mtp-mount
Mount MTP devices as local filesystems via FUSE.
Plug in your Android phone or camera, run mtp-mount /mnt/phone, and use
ls, cp, cat, rm, etc. on your device's storage. Built on
mtp-rs (pure Rust, no libmtp) and
fuser.
Install
Usage
Mount the first available MTP device:
Pick a specific device by serial number:
Mount read-only:
Unmount:
Run mtp-mount --help for the full list of options.
Supported operations
- Read:
cat,cp,head,less, random-access seeks (media scrubbing,tail -c, partialdd) - Write: create files, overwrite existing files
- Directories:
ls,mkdir,rmdir - Delete:
rm - Rename/move:
mv
Not supported
MTP is an object-based protocol, not a block device. Some POSIX features don't map:
- Hardlinks and symlinks
- File permissions (
chmod/chownare no-ops, everything shows as 0644/0755) - Extended attributes
- Sparse files or random-access writes (files are uploaded whole on close)
How it works
The FUSE layer translates filesystem calls into MTP operations:
- Reads are byte-range on-demand: each FUSE
read(offset, size)fetches only the missing bytes via MTP'sGetPartialObject64, writes them into a sparse tempfile, and serves the requested slice. Repeated reads of the same region hit the cache. Works with files larger than 4 GB. - Writes buffer to a temp file, then flush to the device on close
- Overwrites use a safe upload-then-delete-then-rename sequence when the device supports rename, so data is never lost if the upload fails
- Directory listings are cached and refreshed on
opendir. A background event monitor listens for device-side changes (files added, removed, or modified on the device itself) and invalidates the cache automatically
Requirements
You need a FUSE implementation:
- Linux:
sudo apt install libfuse3-dev(Debian/Ubuntu) orfuse3(Fedora/Arch) - macOS: macFUSE or FUSE-T (may need manual
pkg-configwiring)
Build from source
Testing
Unit tests run without FUSE:
Integration tests mount a virtual MTP device via FUSE (Linux only, needs libfuse3-dev):
All 63 tests (42 unit + 21 integration) pass on Linux. The integration tests
use mtp-rs's virtual device transport, so no physical device is needed.
License
MIT OR Apache-2.0