简体   繁体   English

如何从标头的扇区起始地址估算文件大小?

[英]How to estimate a file size from header's sector start address?

Suppose I have a deleted file in my unallocated space on a linux partition and i want to retrieve it. 假设我在Linux分区上未分配的空间中有一个已删除的文件,我想检索它。

Suppose I can get the start address of the file by examining the header. 假设我可以通过检查标头来获取文件的起始地址。

Is there a way by which I can estimate the number of blocks to be analyzed hence (this depends on the size of the image.) 有没有一种方法可以估算因此要分析的块数(取决于图像的大小)。

In general, Linux/Unix does not support recovering deleted files - if it is deleted, it should be gone. 通常,Linux / Unix不支持恢复已删除的文件-如果将其删除,则应该删除它。 This is also good for security - one user should not be able to recover data in a file that was deleted by another user by creating huge empty file spanning almost all free space. 这也对安全性有好处-一个用户应该无法通过创建跨越几乎所有可用空间的巨大空文件来恢复另一用户删除的文件中的数据。

Some filesystems even support so called secure delete - that is, they can automatically wipe file blocks on delete (but this is not common). 一些文件系统甚至支持所谓的安全删除-即它们可以在删除时自动擦除文件块(但这并不常见)。

You can try to write a utility which will open whole partition that your filesystem is mounted on (say, /dev/sda2 ) as one huge file and will read it and scan for remnants of your original data, but if file was fragmented (which is highly likely), chances are very small that you will be able to recover much of the data in some usable form. 您可以尝试编写一个实用程序,该实用程序将打开挂载文件系统的整个分区(例如/dev/sda2 )作为一个大文件,并读取该文件并扫描原始数据的剩余部分,但是如果文件是碎片化的(可能性很高),那么您将能够以某种可用形式恢复许多数据的机会很小。

Having said all that, there are some utilities which are trying to be a bit smarter than simple scan and can try to be undelete your files on Linux, like extundelete . 综上所述,有些实用程序正在尝试比简单扫描更智能,并且可以尝试在Linux上取消删除文件,例如extundelete It may work for you, but success is never guaranteed. 它可能对您有用,但永远无法保证成功。 Of course, you must be root to be able to use it. 当然,您必须是root用户才能使用它。

And finally, if you want to be able to recover anything from that filesystem, you should unmount it right now, and take a backup of it using dd or pipe dd compressed through gzip to save space required. 最后,如果您希望能够从该文件系统中恢复任何内容,则应立即将其卸载,并使用通过gzip压缩的dddd管道对其进行备份,以节省所需的空间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM