LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-13-2016, 07:06 AM   #1
ArthurDent
Member
 
Registered: Feb 2004
Location: London
Distribution: Fedora Core 5, Mandrake 10.0, Gentoo, Suse
Posts: 179

Rep: Reputation: 30
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...
 
Old 08-13-2016, 08:09 AM   #2
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,711

Rep: Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279
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?
 
Old 08-13-2016, 08:26 AM   #3
ArthurDent
Member
 
Registered: Feb 2004
Location: London
Distribution: Fedora Core 5, Mandrake 10.0, Gentoo, Suse
Posts: 179

Original Poster
Rep: Reputation: 30
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?
 
Old 08-13-2016, 08:57 AM   #4
hydrurga
Senior Member
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 18.2 MATE
Posts: 3,491
Blog Entries: 2

Rep: Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196
Quote:
Originally Posted by jpollard View Post
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.
 
Old 08-13-2016, 09:07 AM   #5
ArthurDent
Member
 
Registered: Feb 2004
Location: London
Distribution: Fedora Core 5, Mandrake 10.0, Gentoo, Suse
Posts: 179

Original Poster
Rep: Reputation: 30
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?
 
Old 08-13-2016, 09:20 AM   #6
hydrurga
Senior Member
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 18.2 MATE
Posts: 3,491
Blog Entries: 2

Rep: Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196
Quote:
Originally Posted by ArthurDent View Post
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.
 
Old 08-13-2016, 12:52 PM   #7
ArthurDent
Member
 
Registered: Feb 2004
Location: London
Distribution: Fedora Core 5, Mandrake 10.0, Gentoo, Suse
Posts: 179

Original Poster
Rep: Reputation: 30
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

Last edited by ArthurDent; 08-13-2016 at 12:58 PM.
 
Old 08-13-2016, 01:17 PM   #8
hydrurga
Senior Member
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 18.2 MATE
Posts: 3,491
Blog Entries: 2

Rep: Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196
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)
 
Old 08-13-2016, 01:26 PM   #9
ArthurDent
Member
 
Registered: Feb 2004
Location: London
Distribution: Fedora Core 5, Mandrake 10.0, Gentoo, Suse
Posts: 179

Original Poster
Rep: Reputation: 30
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).
 
Old 08-13-2016, 02:11 PM   #10
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,711

Rep: Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279
Well - that makes it sound like a media problem.
 
Old 08-13-2016, 04:25 PM   #11
hydrurga
Senior Member
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 18.2 MATE
Posts: 3,491
Blog Entries: 2

Rep: Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
setversion 1.4 failed: Permission denied RandomTroll Linux - Software 3 01-10-2015 07:09 AM
NFS - permission denied - very strange problem Marcin Kuk Linux - Server 4 09-21-2010 04:59 PM
udevd - rmdir(/dev/.udev/failed) failed: Permission denied pbhj Slackware 20 03-21-2008 11:46 AM
CRON problem: (rsync: Failed to exec ssh: Permission denied (13)) Fairys Fedora 6 01-16-2008 07:34 PM
Failed to send mail : Write failed : Permission denied shawnbishop Linux - Software 1 03-27-2006 02:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:32 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration