什么是文件洞,如何使用? [英] what is file hole and how can it be used?

查看:150
本文介绍了什么是文件洞,如何使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据我的理解,hole可能作为元数据保存在inode中,但是实际的磁盘没有填充空的零。


  1. 有人可以用现实生活中的例子解释一下,文件中的漏洞可能有用吗? >

  2. 是否与 soft 预分配相同?从硬盘使用的角度来看,即使没有使用实际的磁盘空间,但该空间也不适用于其他进程。

  3. p>

    当一个程序需要访问大量的地址(偏移量)时,它们非常有用,但不太可能触及所有潜在的块。虚拟化产品通常使用这种方式来存储虚拟磁盘。假设你使用一个20 GB的磁盘来配置一个虚拟机,但是它不会很快的被数据充满。创建一个20 GB的稀疏文件要快得多,该文件在开始时只使用几个磁盘块,然后让VM创建文件系统并以低速存储文件。

    稀疏文件与预分配相反,它们是所谓的精简配置,也可能称为磁盘过度分配。这允许创建比实际硬件支持更多的虚拟磁盘空间,并且只有在必要时才添加更多的磁盘来扩展文件系统。


    To my understanding, holes are perhaps maintained as metadata at inode, but actual disk is not filled with empty zeros.

    1. Can someone explain with real life usage examples, where holes in a file can be useful?

    2. Is holes same as soft preallocation? From diskusage perspective, even though actual disk space is not used, but that space is also not available for other process.

    解决方案

    Files with holes are usually referred to as sparse files.

    They are useful when a program need to access a wide range of addresses (offset) but is unlikely to touch all of the potential blocks. This is commonly used by virtualization products to store virtual disks. Let say you configure a virtual machine with a 20 GB disk but it won't be full of data quickly. It is much faster to create a sparse file of 20 GB that will only use a couple of disk blocks at the beginning and then have the VM creating a file system and storing files at a low pace.

    Sparse files are the opposite of preallocation, they are what is called thin provisioning or might also be called disk overcommitment. This allows creating more "virtual disk space" than the actual hardware support and add more disk to grow the file system only when necessary.

    这篇关于什么是文件洞,如何使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆