Copy command tricks

BigFrank

New Member
Joined
Nov 9, 2024
Messages
3
Reaction score
0
Credits
30
Hi,
I am new here but hope that you can help.

I have a 6TB external usb hdd that has a few partitions on it. I am having trouble with an EXT4 partition. I was copying a bunch of important files to it. No errors reported... A bit later - I clicked back into the partition of the drive in Nautilus and I got an error:

Sorry could not display all the contents of "Parent folder": Error when getting information for file "/media/user/Ext4Partition/Parent folder/#1 important photos here/2021 Vacations": Input/output error

In CLI I can get to /media/user/Ext4Partition/Parent folder/#1 important photos here. But if I ls I get an error
ls: cannot access '2021 Vacations': Input/output error

So before I run fsck what would be the easy way to backup the other working folders from that directory. Is there such a thing as a CP command that copies all 'except'? Inside that folder is 20+ folders named with a 4 digit year and a description. Inside those folders are a number of photos and videos.

What about using Nemo or some other file manager? Nautilus gives up and crashes. Are there others that don't give up as easily or?

Thanks in advance.
 


You many have one or more bad sectors on your hard drive. Use journalctl -xe to check your system journal. I have never had good luck with badblocks to get it to mark bad blocks as being bad. Some drives should be able to map around them. Otherwise you'll need to save such files or directories aside somewhere and create them again. You might even need to partition around them. It looks like it's time to buy a new hard drive, if it's going bad like this.

Signed,

Matthew Campbell
 
You can use cp -i to interactively copy files, but that will be really show. You can use tar to exclude files or entire directories when making a tar file backup.

Signed,

Matthew Campbell
 
That really sounds like bad news. I know it can happen but the drive isn't 18mos old.

But short of one by one typing each subfolder to a new location (there has to be 30 or so) is there an easy way to cp all except?

Thanks again
 
Sorry - replies crossed in time here. cp -i huh? I will have to read up on that.
 
Also look for the recursive and preserve options.

Signed,

Matthew Campbell
 
Hi,
I am new here but hope that you can help.

I have a 6TB external usb hdd that has a few partitions on it. I am having trouble with an EXT4 partition. I was copying a bunch of important files to it. No errors reported... A bit later - I clicked back into the partition of the drive in Nautilus and I got an error:

Sorry could not display all the contents of "Parent folder": Error when getting information for file "/media/user/Ext4Partition/Parent folder/#1 important photos here/2021 Vacations": Input/output error

In CLI I can get to /media/user/Ext4Partition/Parent folder/#1 important photos here. But if I ls I get an error
ls: cannot access '2021 Vacations': Input/output error

So before I run fsck what would be the easy way to backup the other working folders from that directory. Is there such a thing as a CP command that copies all 'except'? Inside that folder is 20+ folders named with a 4 digit year and a description. Inside those folders are a number of photos and videos.

What about using Nemo or some other file manager? Nautilus gives up and crashes. Are there others that don't give up as easily or?

Thanks in advance.
If there are files that you wish to save, but cannot access, then there are some approaches that can help one's chances of doing so. These are the steps one might consider:

Stop using the computer so that no further writes are going to occur, that is, power off the machine. Don't fsck or do anything else that may alter the filesystem so that you can be in the most original possible position in relation to the inaccessible files.

Use a rescue disk, that is, boot up a rescue disk or live disk so that you can then copy, byte for byte, the relevant partition to another disk, either a usb or another external hard disk. One can use the dd command. In this case, one can then work on the copied disk with tools like photorec, testdisk or other filesystem tools to try and rescue the files.

It's possible to image the whole disk with tools like rescatux or clonezilla rather than just the partition but one needs a large enough external medium to do this.

Good luck with whatever route you take. These situations are so frustrating. BTDT :)
 
Last edited:
If there are files that you wish to save, but cannot access, then there are some approaches that can help one's chances of doing so. These are the steps one might consider:

Stop using the computer so that no further writes are going to occur, that is, power off the machine. Don't fsck or do anything else that may alter the filesystem so that you can be in the most original possible position in relation to the inaccessible files.

Use a rescue disk, that is, boot up a rescue disk or live disk so that you can then copy, byte for byte, the relevant partition to another disk, either a usb or another external hard disk. One can use the dd command. In this case, one can then work on the copied disk with tools like photorec, testdisk or other filesystem tools to try and rescue the files.

It's possible to image the whole disk with tools like rescatux or clonzilla rather than just the partition but one needs a large enough external medium to do this.

Good luck with whatever route you take. These situations are so frustrating. BTDT :)
This may fail if the partition has bad sectors. Make sure not to use a USB hub with a hard drive. Make sure the USB bus itself has enough electrical power to run everything that is connected to it. Make sure the USB bus itself is not too busy. They can and do fill up.

Signed,

Matthew Campbell
 
I would think that CP would have an option to continue copying for any file that is unable to be copied ... but then again, CP may be doing that by default. I can't reproduce your case from here, so I can't tell.

But there are some tricks to use ... which basically are using the parameters which are available anyway for CP.

-i
was already mentioned before, which makes the copying interactive. Depending on the amount of files, that coule be handy.

-v
I would enable this one anyway, as in this case it will tell you which files were copied.

-u
Only update newer files: in a case of yours, it would continue to offer the source files again and again, because it can't copy them. And the good files will be copied like normally, but only once as if the file is copied already, the source file isn't newer as the target anymore (it's the same).

So you can do this:

cp -ivu /source/* /target
 
You can also check files via the find command, example:

find /path -type f -exec ls -l {} \;

See what it says for every single file in source. If it can't read, you'll get a list of files failing to be read ... I assume, as I guess the error handling would do for your case.
 

Members online


Top