I've tried to come up with a line for /etc/fstab
that would allow to mount with mount /phone
(after mkdir /phone). I'm not sure what to put in column 1 (Device) and column 3 (fstype). Is this possible at all?
It’s possible, but it requires some effort.
When using
/etc/fstab
, a tool is called that is named
mount_<type>
(with device and mountpoint as arguments, as well as any -o options specified), where <type> is the 3rd column in
/etc/fstab
. The
jmtpfs
tool does not support this kind of usage, unfortunately, so you have to write a shell script that acts as a wrapper. I suggest
mount_mtpfs
as the name of the script, so you can use the device type
mtpfs
in
/etc/fstab
(3rd column). The script must be located in
/sbin
or
/usr/sbin
(unfortunately,
/usr/local
is not supported).
In the most simple case, the script just contains
exec /usr/local/bin/jmtpfs "$2"
, mounting the first Android MTP device that it finds on the mount point given in the
/etc/fstab
file (2nd column). The device name (1st column) and options (4th column) are ignored. So, this would be the script
mount_mtpfs
:
Code:
#!/bin/sh
exec /usr/local/bin/jmtpfs "$2"
and an appropriate entry for
/etc/fstab
:
Code:
mtpfs /your/mount/point mtpfs rw,noauto 0 0
Beware, this is a very simplistic solution. Most options will be ignored, e.g.
ro
(for read-only) will be ignored.
Beware #2: This is just off the top of my head, but I haven't tried it myself. I just run
jmtpfs
when I need it. I also just noticed that the script needs more work because of options passed to it, so you cannot use it directly. The least effort is probably to hardcode the mount point in the script (instead of
$2
).
Note, if you want to use this for backing up your Android device, I suggest you insert the option
-o ro
in the jmtpfs call in the script, so it always performs read-only mounts.
You can also improve the script to take the options from the command line (passed from
/etc/fstab
), this is left as an exercise to the reader.