LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-28-2016, 01:29 PM   #1
eco_bach
Member
 
Registered: Dec 2016
Posts: 242

Rep: Reputation: Disabled
Can't delete files from MTP mounted device


Hi
Using libmtp and mtp-tools in Ubuntu-mate to copy files from an MTP device(camera) over usb.
I can copy files but when I try and delete using the following command

Code:
    sudo mtp-delfile -n <File ID>
I get the following error

Quote:
> Failed to delete file:3 Error 2: PTP Layer error 200e:
> LIBMTP_Delete_Object(): could not delete object. Error 2: Error 200e:
> PTP: Store Read Only
 
Old 12-28-2016, 02:32 PM   #2
rokytnji
LQ Veteran
 
Registered: Mar 2008
Location: Waaaaay out West Texas
Distribution: antiX 23, MX 23
Posts: 7,112
Blog Entries: 21

Rep: Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474
try

Code:
sudo rm -rf filename
filename has to be the full path eg: /media/blah/blah/blah

from https://help.ubuntu.com/community/FilePermissions

Quote:
File removal

To remove a file you cannot delete use

sudo rm -rf filename

where filename is the name and path of the file to delete.

Nota bene: Be very careful when using the command rm with the -rf option since -r makes the file removal recursive (meaning it will remove files inside of folders) and -f will force the removal even for files which aren't writable. To play it safe, please consider typing in the absolute path to the file

sudo rm -rf /path/to/file/filename

to prevent any mishaps that can/will occur. It takes longer to type but you can't put a price on peace of mind. See the rm man page for details.
 
Old 12-28-2016, 08:16 PM   #3
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
Quote:
Originally Posted by eco_bach View Post
Hi
Using libmtp and mtp-tools in Ubuntu-mate to copy files from an MTP device(camera) over usb.
I can copy files but when I try and delete using the following command

Code:
    sudo mtp-delfile -n <File ID>
I get the following error
as you are using that software you got running commands, if the prior post does not work using rm -rf

as your error message states,
Quote:
> Failed to delete file:3 Error 2: PTP Layer error 200e:
> LIBMTP_Delete_Object(): could not delete object. Error 2: Error 200e:
> PTP: Store Read Only
that your files are stored read only on your camera. you also might want to go through your camera setting and delete the files through there if it provides that option.

If it has a removable medium that you are not removing so you can use that setup you did to get this to work, then remove it, plug it in your system and try the post above mine method rm -rfv (the v is to give you feedback to have it tell you what it did for visual verification)

Last edited by BW-userx; 12-28-2016 at 08:19 PM.
 
Old 12-29-2016, 09:52 AM   #4
eco_bach
Member
 
Registered: Dec 2016
Posts: 242

Original Poster
Rep: Reputation: Disabled
thanks, will try the suggested but my first thought is that the rm command will only work with mass storage devices, not MTP or PTP devices, and that I have to use some command specific to libmtp
 
Old 12-29-2016, 10:27 AM   #5
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
Quote:
Originally Posted by eco_bach View Post
thanks, will try the suggested but my first thought is that the rm command will only work with mass storage devices, not MTP or PTP devices, and that I have to use some command specific to libmtp
That is why I stated what I did. process it is a process. If one thing does not work, then try a different way.

Seeing that you are using a Camera -- does not the storage unit within that device have a removable medium? ie SD CARD.

Another thing you have to look at is permissions and how it is used within the software you are using to perform your task.

Problem Solving 101:

As you seen the error message told you it is a "read only" file.
What knowledge should you have gained from that message?

What does read only mean?
What permission is missing from the file types that allow you to remove it?
what command can you use to override that issue?
What user type in Linux possesses the ability to override permissions of a file?

Did you check to see if you have the ability to change the permissions on the medium that you are working with before getting started?

Did you check to see if you have the ability to change the permissions on the files on the medium that you are working with before getting started?

Did you check to see if that user type that has the ability to destroy everything on the System you are using also has the same ability with the commands within the software you are using?

Last edited by BW-userx; 12-29-2016 at 10:45 AM.
 
Old 12-29-2016, 10:32 AM   #6
eco_bach
Member
 
Registered: Dec 2016
Posts: 242

Original Poster
Rep: Reputation: Disabled
The exact same command works with an LGE360 camera.
rm and cp commands cannot be used with MTP devices AFAIK. hence my use of libmtp, mtp-tools

I can only assume this has something to do with the way the SamsungGear360 implements the MTP protocol.

The actual photos, videos are not 'locked' and can be removed manually via the menu on the camera.

But this must be done from the command line.

Last edited by eco_bach; 12-29-2016 at 10:33 AM.
 
Old 12-29-2016, 10:53 AM   #7
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
Quote:
Originally Posted by eco_bach View Post
The exact same command works with an LGE360 camera.
rm and cp commands cannot be used with MTP devices AFAIK. hence my use of libmtp, mtp-tools

I can only assume this has something to do with the way the SamsungGear360 implements the MTP protocol.

The actual photos, videos are not 'locked' and can be removed manually via the menu on the camera.

But this must be done from the command line.
Stop assuming and go find out. Dig into your device specs in how to deal with it and getting your images off it, or whatever you are doing with them. That would mean going and talking to the source, and not the third party (ie LQ) first.

LQ is not SamsungGear360 Questions.

One should not expect everyone to know everything about the devices you are dealing with and how to do everything with them but you. That is a backward thought.

I only say that because it is no longer a Linux or its software it uses issue, but your device issue.

using these key words in a search would be a good start
samsung gear 360 and MTP

Last edited by BW-userx; 12-29-2016 at 11:03 AM.
 
Old 12-29-2016, 01:56 PM   #8
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,137
Blog Entries: 6

Rep: Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826
http://www.linuxquestions.org/questi...ce-4175595940/

You can use rm and cp commands if you mount the device to the file system.
You said that you have simple-mtpfs working. Did you try to mount that camera to an empty directory? Or did you just ignore the advice you asked for? It will allow you to access that device just like any other directory of files. User will need to have permissions to the directory and files.

Example:
Code:
mount | tail -3
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=192324k,mode=700,uid=1000,gid=100)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
gvfsd-fuse on /run/user/1000/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=1000,group_id=100)
Code:
 ls ~/usb
(nothing here)
Plug in a android phone...
Code:
simple-mtpfs ~/usb
Code:
ls ~/usb
Alarms   Download              Movies         Pictures   Ringtones         obb
Android  'FM Recording'        Music          Podcasts   SMSBackupRestore  otaLogs
DCIM     Bookmarks.html  Notifications  Recording  ServeStream
Code:
mount | tail -n3
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
gvfsd-fuse on /run/user/1000/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=1000,group_id=100)
simple-mtpfs on /home/me/usb type fuse.simple-mtpfs (rw,nosuid,nodev,relatime,user_id=1000,group_id=100)
do what you want with the files...
Code:
fusermount -u ~/usb
unplug android phone...
Code:
ls ~/usb
(nothing here again)
Code:
mount | tail -n3
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=192324k,mode=700,uid=1000,gid=100)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
gvfsd-fuse on /run/user/1000/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=1000,group_id=100)
So what happens when you mount that camera's file system with simple-mtpfs? What permissions do the files mount with? Does your user have permissions to those files?

libmtp has been buggy for a while. That why I suggested simple-mtpfs.
 
Old 12-29-2016, 03:34 PM   #9
eco_bach
Member
 
Registered: Dec 2016
Posts: 242

Original Poster
Rep: Reputation: Disabled
Thanks I'm giving simple-mtpfs another try. A bit of a challenge for me getting it compiled properly.


Finally seeing the light

simple-mtpfs seems to work

forgot the step of creating a home directory first

Last edited by eco_bach; 12-29-2016 at 03:40 PM.
 
Old 12-29-2016, 03:36 PM   #10
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
Quote:
Originally Posted by eco_bach View Post
Thanks I'm giving simple-mtpfs another try. A bit of a challenge for me getting it compiled properly.

I'm stumbling a bit with the actual syntax. Could you give a few examples of simply copying and deleting a file?
Quote:
Due to MTP nature, it is necessary to use a folder, where the temporary files downloaded will be downloaded. The project can be configured to use custom directory for such files. To configure the simple-mtpfs to use desired temporary directory, add --with-tmpdir=TMPDIR option to configure script. Default value for temporary directory is /tmp.
keep this in mind
 
Old 12-29-2016, 03:49 PM   #11
eco_bach
Member
 
Registered: Dec 2016
Posts: 242

Original Poster
Rep: Reputation: Disabled
I think the only issue I am having is deleting the file after copying. will let you know if I resolve
 
Old 12-29-2016, 04:11 PM   #12
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,137
Blog Entries: 6

Rep: Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826
Look at the output of mount and see if it's mounted read only.
Look if user has permissions to delete files in folder.
When I mount a droid device here, everything is as user.
Code:
simple-mtpfs ~/usb
Code:
ls -l ~/usb
total 40
drwxrwxr-x 2 teckk users     0 Dec 31  1969 Alarms
drwxrwxr-x 2 teckk users     0 Dec 31  1969 Android
drwxrwxr-x 2 teckk users     0 Dec 31  1969 DCIM
drwxrwxr-x 2 teckk users     0 Dec 31  1969 Download
drwxrwxr-x 2 teckk users     0 Dec 31  1969 'FM Recording'
-rw-r--r-- 1 teckk users 40897 Sep 27 12:34 Bookmarks.html
drwxrwxr-x 2 teckk users     0 Dec 31  1969 Movies
drwxrwxr-x 2 teckk users     0 Dec 31  1969 Music
drwxrwxr-x 2 teckk users     0 Dec 31  1969 Notifications
drwxrwxr-x 2 teckk users     0 Dec 31  1969 Pictures
drwxrwxr-x 2 teckk users     0 Dec 31  1969 Podcasts
drwxrwxr-x 2 teckk users     0 Dec 31  1969 Recording
drwxrwxr-x 2 teckk users     0 Dec 31  1969 Ringtones
drwxrwxr-x 2 teckk users     0 Dec 31  1969 SMSBackupRestore
drwxrwxr-x 2 teckk users     0 Dec 31  1969 ServeStream
drwxrwxr-x 2 teckk users     0 Dec 31  1969 obb
drwxrwxr-x 2 teckk users     0 Dec 31  1969 otaLogs
You should be able to do what you want with it.
What is the output of:
Code:
mount | tail -n3
with the device mounted? Is it rw like in post 8? If not start there.

Also, I would not be doing all this manually every time. Use the script I gave you here. http://www.linuxquestions.org/questi...ce-4175595940/
Alter it to your liking.
 
Old 12-30-2016, 08:45 AM   #13
eco_bach
Member
 
Registered: Dec 2016
Posts: 242

Original Poster
Rep: Reputation: Disabled
Thanks again. Attempting install of simple-mtpfs on a 2nd machine I see that running ../configure can be finicky, doesn't always complete properly and I have to try several times before it completes properly. Will try all your suggestions.

Last edited by eco_bach; 12-30-2016 at 09:10 AM.
 
Old 12-30-2016, 09:12 AM   #14
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
Quote:
Originally Posted by eco_bach View Post
Thanks again. Attempting install of simple-mtpfs on a 2nd machine. I believe I've installed all necessary dependencies as listed at the end of this post.
However I am getting an error at sudo make



In my working folder I DO see makefile.am and makefile,in

Does this error mean my configure was not run correctly? I see no errors when configure is run however I DO see 1 syntax error

>


Code:
//download and extract zip
https://github.com/phatina/simple-mtpfs

//need libmtp
$ sudo apt-get install libmtp-dev

//need to install C compiler
$ sudo apt-get install build-essential
$ sudo apt-get update

//need to install latest fuse
$ sudo apt-get install libfuse-dev


//need to install autoconf
$ sudo apt install autoconf

$ sudo autoreconf -i

$ mkdir build && cd build
$ ../configure
$ sudo make
$ sudo make install
Building from source. if you see a configure file then that is what you run. If you see a makefile without a configure but a configure.ac file, run autoconf to get a configure file to run.

read the README file first if you have no idea how they set it up to compile. or the INSTALL file even.

basic tools needed to compile, are a C and or C++ compiler, make, automake, autoconf, gettext (it comes in handy for some look for it). build-essential usually covers most of it on Debian and its knock offs.
 
Old 12-30-2016, 10:53 AM   #15
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,137
Blog Entries: 6

Rep: Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826
For anyone else reading this thread there is:
libmtp
http://libmtp.sourceforge.net

mtpfs
https://www.adebenham.com/mtpfs/

jmtpfs
http://research.jacquette.com/jmtpfs...ces-and-linux/

go-mtpfs-git
https://github.com/hanwen/go-mtpfs

simple-mtpfs
https://github.com/phatina/simple-mtpfs/

android-file-transfer
https://github.com/whoozle/android-file-transfer-linux

For file managers that use gvfs
gvfs-mtp
gvfs-gphoto2
https://wiki.gnome.org/Projects/gvfs

For file managers that use KIO (KDE's Dolphin)
kio-extras
https://www.kde.org/applications/internet/

To access those obnoxious little android devices that use MTP.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Finding documentation for package to delete files on MTP device eco_bach Linux - Newbie 3 12-09-2016 08:37 AM
Mounted disk still reports 0 bytes on Rhel 5 even when files are delete boberey Linux - Newbie 4 05-09-2011 11:37 PM
Unable to delete the mounted files? your_shadow03 Linux - Newbie 3 09-05-2008 01:49 AM
USB storage device mounted and regonized in Suse but files not recognized Sarge. tuffstuff Linux - Newbie 6 02-11-2007 11:19 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:23 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration