LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Strange cp problem : cp: failed to extend ... permission denied (https://www.linuxquestions.org/questions/linux-newbie-8/strange-cp-problem-cp-failed-to-extend-permission-denied-4175586962/)

ArthurDent 08-13-2016 06:06 AM

Strange cp problem : cp: failed to extend ... permission denied
 
Hello All,

My wife has an external hard drive formatted as NTFS. I need to transfer the data on it to another drive. Most of the files are Word, PPT or PDF files and most of them copy without problem. However, several give an error (e.g.) "cp: failed to extend ‘./History Essay Outlines.docx’: Permission denied"

I have spent hours on this!

I have mounted the drive (on my Fedora 20 box). I have chmod'ed I have chown'ed. I have done this as me (user = mark) and as root. Always the same result

Code:

[root@ArthurDent ~]# ls -la /mnt/tmp/School/IB\ Resources/Cold\ War/Essay\ Plans/
total 284
drwxr-xr-x. 1 root root  4096 Aug 13 10:50 .
drwxr-xr-x. 1 root root  8192 Oct 23  2015 ..
-rwxr-xr-x. 2 root root  6148 Aug 10  2013 .DS_Store
-rwxr-xr-x. 2 root root 149810 Nov 15  2012 Essay Outlines detailed.docx
-rwxr-xr-x. 2 root root 117805 Oct 27  2012 History Essay Outlines.docx
[root@ArthurDent ~]#
[root@ArthurDent ~]# chown mark:mark /mnt/tmp/School/IB\ Resources/Cold\ War/Essay\ Plans/History\ Essay\ Outlines.docx
[root@ArthurDent ~]# ls -la /mnt/tmp/School/IB\ Resources/Cold\ War/Essay\ Plans/
total 284
drwxr-xr-x. 1 root root  4096 Aug 13 10:50 .
drwxr-xr-x. 1 root root  8192 Oct 23  2015 ..
-rwxr-xr-x. 2 root root  6148 Aug 10  2013 .DS_Store
-rwxr-xr-x. 2 root root 149810 Nov 15  2012 Essay Outlines detailed.docx
-rwxr-xr-x. 2 mark mark 117805 Oct 27  2012 History Essay Outlines.docx

[root@ArthurDent ~]# cp /mnt/tmp/School/IB\ Resources/Cold\ War/Essay\ Plans/History\ Essay\ Outlines.docx /home/mark/temp/
cp: error reading ‘/mnt/tmp/School/IB Resources/Cold War/Essay Plans/History Essay Outlines.docx’: Permission denied
cp: failed to extend ‘/home/mark/temp/History Essay Outlines.docx’: Permission denied

How can I copy these files?

Thanks in advance...

jpollard 08-13-2016 07:09 AM

The first error "cp: error reading ‘/mnt/tmp/School/IB Resources/Cold War/Essay Plans/History Essay Outlines.docx’: Permission denied" should be the culprit.

This looks odd for root... But it is possible there is a quota restriction on the "mark" account that prevents the extension as the destination file belongs to mark. Perhaps running out of disk space?

ArthurDent 08-13-2016 07:26 AM

No, Disk space is not an issue. I have tried copying this file (and others like it) to my home drive, to a USB stick (and even another directory on the same NTFS dive). All of them have plenty of space (well, certainly enough for a 147k word document).

Any other ideas?

hydrurga 08-13-2016 07:57 AM

Quote:

Originally Posted by jpollard (Post 5590241)
The first error "cp: error reading ‘/mnt/tmp/School/IB Resources/Cold War/Essay Plans/History Essay Outlines.docx’: Permission denied" should be the culprit.

This looks odd for root... But it is possible there is a quota restriction on the "mark" account that prevents the extension as the destination file belongs to mark. Perhaps running out of disk space?

Having had a look at the coreutils source code, I'm not sure where the "Permission denied" is coming from. From what I can see, the "failed to extend" error is generated by copy.c where it determines that the source file is sparse and finds a hole at the end of it, but is unable to replicate this in the destination file or truncate the destination file accordingly.

One way to avoid this would be to use the --sparse=never option with cp.

Personally, I would be slightly suspicious as to the integrity of the source disk and/or filesystem and would (i) replicate the disk in case of data loss during phase ii (although that would need a lot of space), (ii) fsck the source disk, including searching for bad blocks.

ArthurDent 08-13-2016 08:07 AM

Thanks - Some useful info that I didn't know about. Unfortunately however that does not appear to be the problem:
Code:

[root@ArthurDent ~]# cp --sparse=never /mnt/tmp/School/IB\ Resources/Cold\ War/Essay\ Plans/Essay_Outlines_detailed.docx /home/mark/temp/
cp: error reading ‘/mnt/tmp/School/IB Resources/Cold War/Essay Plans/Essay_Outlines_detailed.docx’: Permission denied
cp: failed to extend ‘/home/mark/temp/Essay_Outlines_detailed.docx’: Permission denied
[root@ArthurDent ~]#

It does however reveal an extra "error reading" error message. Is this significant?

I don't think it is a disk integrity problem. This error occurs only on certain files, but I think all those files are originally from the same source (my wife thinks she got these while attending a conference several years ago). Could it be some sort of encryption?

hydrurga 08-13-2016 08:20 AM

Quote:

Originally Posted by ArthurDent (Post 5590261)
Thanks - Some useful info that I didn't know about. Unfortunately however that does not appear to be the problem:
Code:

[root@ArthurDent ~]# cp --sparse=never /mnt/tmp/School/IB\ Resources/Cold\ War/Essay\ Plans/Essay_Outlines_detailed.docx /home/mark/temp/
cp: error reading ‘/mnt/tmp/School/IB Resources/Cold War/Essay Plans/Essay_Outlines_detailed.docx’: Permission denied
cp: failed to extend ‘/home/mark/temp/Essay_Outlines_detailed.docx’: Permission denied
[root@ArthurDent ~]#

It does however reveal an extra "error reading" error message. Is this significant?

I don't think it is a disk integrity problem. This error occurs only on certain files, but I think all those files are originally from the same source (my wife thinks she got these while attending a conference several years ago). Could it be some sort of encryption?

You had the "error reading" error in the original cp attempt as well.

Have you tried copying the file using rsync (I'm not sure whether this uses an underlying call to cp or not) or another Linux copy alternative? The idea would be to find a copy command that approaches the problem differently. Or perhaps try a Windows copy command?

If disk integrity is a problem, it might only affect a few files. I would run a filesystem and badblock check on your source disk if I were you.

An encrypted file is still just a file, so I'd wager that it isn't that.

ArthurDent 08-13-2016 11:52 AM

Ah yes - rsync - didn't think of that...

I'm not too familiar with rsync, but here goes... (is this the best syntax to use?)

Code:

[root@ArthurDent ~]# rsync -a /mnt/tmp/School/IB\ Resources/Cold\ War/Essay\ Plans/ /home/mark/temp/
rsync: read errors mapping "/mnt/tmp/School/IB Resources/Cold War/Essay Plans/.DS_Store": Permission denied (13)
rsync: read errors mapping "/mnt/tmp/School/IB Resources/Cold War/Essay Plans/Essay_Outlines_detailed.docx": Permission denied (13)
rsync: read errors mapping "/mnt/tmp/School/IB Resources/Cold War/Essay Plans/History Essay Outlines.docx": Permission denied (13)
rsync: read errors mapping "/mnt/tmp/School/IB Resources/Cold War/Essay Plans/.DS_Store": Permission denied (13)
rsync: read errors mapping "/mnt/tmp/School/IB Resources/Cold War/Essay Plans/Essay_Outlines_detailed.docx": Permission denied (13)
ERROR: .DS_Store failed verification -- update discarded.
rsync: read errors mapping "/mnt/tmp/School/IB Resources/Cold War/Essay Plans/History Essay Outlines.docx": Permission denied (13)
ERROR: Essay_Outlines_detailed.docx failed verification -- update discarded.
ERROR: History Essay Outlines.docx failed verification -- update discarded.
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1165) [sender=3.1.0]
[root@ArthurDent ~]#

Oh dear...

I'm going to try tar next...


[edit]

Nope...

Code:

[root@ArthurDent ~]# tar -cf test.tar /mnt/tmp/School/IB\ Resources/Cold\ War/Essay\ Plans/*
tar: Removing leading `/' from member names
tar: /mnt/tmp/School/IB Resources/Cold War/Essay Plans/Essay_Outlines_detailed.docx: Read error at byte 0, while reading 9728 bytes: Permission denied
tar: /mnt/tmp/School/IB Resources/Cold War/Essay Plans/History Essay Outlines.docx: Read error at byte 0, while reading 2560 bytes: Permission denied
tar: Exiting with failure status due to previous errors


hydrurga 08-13-2016 12:17 PM

Well that takes us back to the Permission Denied problem. Can you try accessing the files from a Windows machine? (they could be locked, or I may have been wrong about the encryption possibility)

ArthurDent 08-13-2016 12:26 PM

Well I don't have a Windows machine in the house, but the reason I am doing this is that yesterday I sat with my wife at her work (Windows 7) machine, trying to copy these files off the external HD and onto a USB stick.

We got the same error on the Windows machine (well, a similar error about permissions - I didn't write down the exact wording of the message).

jpollard 08-13-2016 01:11 PM

Well - that makes it sound like a media problem.

hydrurga 08-13-2016 03:25 PM

If you could find a Windows system to try the copy on, and post the exact error message here, then it may well cast light on the problem.

It may not be up your street, but running a Windows 7 VM on your Linux system is a great way to examine problems like this where a physical Windows machine isn't to hand.

Also, run a read-only fsck on the external drive.


All times are GMT -5. The time now is 06:25 PM.