Wes*_*ley 721 filesystems directory-structure lost-found
在 Linux 和 Unix 操作系统的根目录下有一个文件夹叫做 /lost+found/
它是做什么用的?在什么情况下我会与它互动?我将如何与它互动?
Gil*_*il' 638
如果您运行fsck文件系统检查和修复命令,它可能会发现文件系统中任何地方都没有引用的数据片段。特别是,fsck可能会发现看起来像一个完整文件但在系统上没有名称的数据——一个没有相应文件名的inode。此数据仍在使用空间,但无法通过任何正常方式访问。
如果您告诉fsck修复文件系统,它会将这些几乎被删除的文件恢复为文件。问题是,该文件曾经有一个名称和位置,但该信息不再可用。所以fsck将文件存放在一个特定的目录中,称为lost+found(在丢失和找到的财产之后)。
出现在lost+found中的文件通常是已经取消链接(即它们的名称已被删除)但在系统突然停止(内核崩溃或电源故障)时仍被某个进程打开(因此数据尚未删除)的文件。如果发生了这一切,这些文件无论如何都会被删除,您无需关心它们。
文件也可能出现,lost+found因为文件系统由于软件或硬件错误而处于不一致状态。如果是这种情况,它是您查找丢失但系统修复设法挽救的文件的一种方式。文件可能包含也可能不包含有用的数据,即使包含,也可能不完整或过时;这完全取决于文件系统损坏的严重程度。
在许多文件系统上,lost+found目录有点特殊,因为它预先分配了一些空间fsck来存放文件。(空间不是用于文件数据,它fsck留在原地;它用于fsck必须弥补的目录条目。)如果您不小心删除了lost+found,请不要使用 重新创建它mkdir,mklost+found如果可用,请使用。
Arc*_*ege 67
的lost+found目录(未丢失+实测)是由所使用的构建体fsck时,有到文件系统(未硬件设备,但对FS)的损坏。通常由于目录损坏而丢失的文件将lost+found通过 inode 编号链接到该文件系统的目录中。其中一些可能是丢失的目录或丢失的文件,甚至丢失的设备。每个文件系统都应该有自己的lost+found目录,但您可能正在查看只有一个文件系统的系统。一般来说,你应该希望目录是空的;但如果有损坏,请庆幸在许多情况下,文件fsck放置在这里后可以恢复。
小智 38
从“Linux Filesystem Hierarchy”,/lost+found部分:
As was explained earlier during the overview of the FSSTND, Linux should always go through a proper shutdown. Sometimes your system might crash or a power failure might take the machine down. Either way, at the next boot, a lengthy filesystem check using fsck will be done. Fsck will go through the system and try to recover any corrupt files that it finds. The result of this recovery operation will be placed in this directory. The files recovered are not likely to be complete or make much sense but there always is a chance that something worthwhile is recovered. Each partition has its own lost+found directory. If you find files in there, try to move them back to their original location. If you find something like a broken symbolic link to 'file', you have to reinstall the file/s from the corresponding RPM, since your file system got damaged so badly that the files were mutilated beyond recognition. Below is an example of a /lost+found directory. As you can see, the vast majority of files contained here are in actual fact sockets. As for the rest of the other files they were found to be damaged system files and personal files. These files were not able to be recovered.