Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
My usb stick is formatted in ext4 (the command mount -t vfat wasn't found at that moment). But when I want to copy everything from it, the cp command fails because of the lost+found directory.
Is there a way to bypass the error? For example, I tried
The lost+found directory is used by the fsck utility to copy corrupted and orphaned files. It is owned by root and a regular user does not have permissions to access the directory. When an ext filesystem is created the lost+found directory is also created in the filesystems "root" directory.
There is no need to copy the lost+found directory but everything else should still copy ok.
Could you post the outputs of mount and cp?
Of course without the 2 > /dev/null
lost+found should be hidden as far as I know and hidden files are not copied by cp
I think that you will find this applies to lost+found everywhere.
drwx------. 2 root root 16384 Feb 23 2018 lost+found
It is not hidden and cannot be copied by anyone except root. It should not ever be needed unless a device is failing. It only applies to the device/filesystem where found so should never be needed in any other form.
Last edited by computersavvy; 01-03-2021 at 12:01 PM.
The lost+found directory is used by the fsck utility to copy corrupted and orphaned files. It is owned by root and a regular user does not have permissions to access the directory. When an ext filesystem is created the lost+found directory is also created in the filesystems "root" directory.
There is no need to copy the lost+found directory but everything else should still copy ok.
The command cp /mnt/* ~/mydir stops after copying the first file, but if I try to copy the files one by one it works
Quote:
Originally Posted by aiszisz
Could you post the outputs of mount and cp?
Of course without the 2 > /dev/null
lost+found should be hidden as far as I know and hidden files are not copied by cp
It's on another computer I just turned off... Maybe tomorrow I answer your question
Quote:
Originally Posted by computersavvy
I think that you will find this applies to lost+found everywhere.
drwx------. 2 root root 16384 Feb 23 2018 lost+found
It is not hidden and cannot be copied by anyone except root. It should not ever be needed unless a device is failing. It only applies to the device/filesystem where found so should never be needed in any other form.
Maybe it's because the user is in the wheel group?
2>/dev/null does not bypass any error, just suppresses the error message.
You ought to try rsync instead of cp, if you wish to skip/ignore directories (like lost+found).
The command cp /mnt/* ~/mydir stops after copying the first file, but if I try to copy the files one by one it works
Then you might have permission and/or other problems.
As a quick test I created a disk image formatted as ext4 and created a few files owned by my user.
A cp /mnt/test/* /destination copied everything except the lost+found directory and the output was just a warning
cp: omitting directory ‘/mnt/test/lost+found’
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.