为什么“大小”和“磁盘大小”之间有很大的区别?

大多数情况下,在检查文件夹或文件的大小时,“Size”和“Size on disk”的值将非常接近匹配,但如果两者之间存在巨大差异呢?今天的超级用户问答文章将探讨这个令人困惑的问题的答案。...

为什么“大小”和“磁盘大小”之间有很大的区别?

大多数情况下,在检查文件夹或文件的大小时,“Size”和“Size on disk”的值将非常接近匹配,但如果两者之间存在巨大差异呢?今天的超级用户问答文章将探讨这个令人困惑的问题的答案。

今天的问答环节是由SuperUser提供的,SuperUser是Stack Exchange的一个分支,是一个由社区驱动的问答网站分组。

问题

超级用户读者thelastblack想知道为什么**SD卡上的文件夹的“大小”和“磁盘大小”之间有如此巨大的差别:

As you can see below, there is so much difference between the ‘Size’ and ‘Size on disk’ fields for this folder. Why is that?

007Ys3FFgy1gpfolpdaocj30ah0djq3e

I know that ‘Size on disk’ should be a little more than ‘Size’ because of allocation units in Windows, but why is there that much difference? Could it be because of the large number of files?

BTW, this folder is on my Android phone’s SD card. Inside this, my maps app stores its cached maps, and the app gets its maps from Google Maps.

从截图上看,“大小”和“磁盘大小”之间肯定存在巨大差异,那么是什么原因造成的呢?

答案

超级用户贡献者Bob为我们提供了答案:

I will be assuming that you are using the FAT/FAT32 file system here, since you mention this is an SD card. NTFS and exFAT behave similarly with regards to allocation units. Other file systems might be different, but they aren’t supported on Windows anyway.

If you have a lot of **all files, this is certainly possible. C***ider this:

  • 50,000 files
  • 32 KB cluster size (allocation units), which is the max for FAT32

Ok, now the minimum space taken is 50,000 * 32,000 = 1.6 GB (using SI prefixes, not binary, to simplify the maths). The space each file takes on the disk is always a multiple of the allocation unit size – and here we’re assuming each file is actually **all enough to fit within a single unit, with some (wasted) space left over.

If each file averaged 2 KB, you’d get about 100 MB total – but you’re also wasting 15x that (30 KB per file) on average due to the allocation unit size.

In-Depth Explanation

Why does this happen? Well, the FAT32 file system needs to keep track of where each file is stored. If it were to keep a list of every single byte, the table (like an address book) would grow at the same speed as the data – and waste a lot of space. So what they do is use “allocation units”, also known as the “cluster size”. The volume is divided into these allocation units, and as far as the file system is concerned, they cannot be subdivided – those are the **allest blocks it can address. Much like you have a house number, but your postman doesn’t care how many bedrooms you have or who lives in them.

So what happens if you have a very **all file? Well, the file system doesn’t care if the file is 0 KB, 2 KB, or even 15 KB, it’ll give it the least space it can – in the example above, that’s 32 KB. Your file is only using a **all amount of this space, and the rest is basically wasted, but still belongs to the file – much like a bedroom you leave unoccupied.

Why are there different allocation unit sizes? Well, it becomes a trade-off between having a bigger table (address book, e.g. saying John owns a house at 123 Fake Street, 124 Fake Street, 666 Satan Lane, etc.), or more wasted space in each unit (house). If you have larger files, it makes more sense to use larger allocation units – because a file doesn’t get a new unit (house) until all others are filled up. If you have lots of **all files, well, you’re going to have a big table (address book) anyway, so may as well give them **all units (houses).

Large allocation units, as a general rule, will waste a lot of space if you have lots of **all files. There usually isn’t a good reason to go above 4 KB for general use.

Fragmentation?

As for fragmentation, fragmentation shouldn’t waste space in this manner. Large files may be fragmented, i.e. split up, into multiple allocation units, but each unit should be filled before the next one is started. Defragging might save a little space in the allocation tables, but this isn’t your specific issue.

Possible Soluti***

As gladiator2345 suggested, your only real opti*** at this point are to live with it or reformat with **aller allocation units.

Your card might be formatted in FAT16, which has a **aller limit on table size and therefore requires much larger allocation units in order to address a larger volume (with an upper limit of 2 GB with 32 KB allocation units). Source courtesy of Braiam. If that is the case, you should be able to safely format as FAT32 anyway.


有什么要补充的解释吗?在评论中发出声音。想从其他精通技术的Stack Exchange用户那里了解更多答案吗?在这里查看完整的讨论主题。

  • 发表于 2021-04-11 12:15
  • 阅读 ( 232 )
  • 分类:互联网

你可能感兴趣的文章

如何使用virtualbox:用户指南

... 在这本使用VirtualBox的指南中,您将了解为什么要使用该软件,如何安装操作系统,以及如何让它为您工作的建议。我们会解释一切,并在途中分享技巧,这样你就不会迷路。我们跳进去吧! ...

  • 发布于 2021-03-12 18:26
  • 阅读 ( 391 )

如何在virtualbox虚拟机上安装windows 7

... 接下来,配置Windows7虚拟机磁盘大小。Microsoft建议Windows 7的存储空间至少为16GB。分配您想要或需要的数量,但请确保它大于16GB。将硬盘文件类型保留为VDI(您可以将此虚拟机磁盘类型移动到其他虚拟机...

  • 发布于 2021-03-20 07:33
  • 阅读 ( 377 )

双启动与虚拟机:哪一个适合你?

...拟机,请先看看我们的指南,了解什么是虚拟机以及它们为什么有用,然后再继续阅读。 ...

  • 发布于 2021-03-25 01:47
  • 阅读 ( 248 )

如何缩小vmware虚拟机并释放磁盘空间

...可增长或“稀疏”磁盘。预先分配的磁盘总是它们的最大大小。如果您有一张要压缩的预分配磁盘,则需要先将其转换为可增长磁盘,然后才能继续。 不过,您的虚拟机可能有一个可增长的磁盘。VMware Player只能创建可增长磁盘...

  • 发布于 2021-04-07 13:01
  • 阅读 ( 409 )

我的usb驱动器应该使用什么文件系统?

...化USB驱动器的最佳解决方案。 相关:什么是文件系统,为什么有这么多? 了解文件系统问题 不同的文件系统提供不同的方式来组织磁盘上的数据。由于实际上只有二进制数据写入磁盘,因此文件系统提供了一种将磁盘上的物理...

  • 发布于 2021-04-07 13:30
  • 阅读 ( 156 )

如何缩小virtualbox虚拟机并释放磁盘空间

...创建和使用虚拟机 请记住,这只会缩小磁盘,如果它的大小增长,你已经删除了数据。所以,如果你只是创建了一个动态磁盘,这不会缩小它。但是,如果您创建了一个动态磁盘,将10gb的数据下载到其中,然后删除了10gb的数据...

  • 发布于 2021-04-07 14:42
  • 阅读 ( 238 )

如何在virtualbox中转换固定磁盘和动态磁盘

...机。它的磁盘将是固定的或动态的磁盘,无论您将其转换为什么。

  • 发布于 2021-04-07 14:48
  • 阅读 ( 241 )

如何在升级到windows 10之前创建pc映像

...的详细教程:如何在一个小时内升级你现有的硬盘。 我为什么要这么做? 没有什么比对你的电脑做一个重大的改变,然后发现这个改变破坏了你的工作流程(就像你依赖的一个旧的应用程序不再工作了)或者它彻底破坏了你...

  • 发布于 2021-04-10 08:55
  • 阅读 ( 200 )

如何使用ntfs压缩以及何时使用

... 如何使用ntfs压缩 既然您了解了应该压缩哪些文件,以及为什么不应该压缩整个硬盘驱动器或Windows系统文件夹,就可以开始压缩一些文件了。Windows允许您压缩单个文件、文件夹甚至整个驱动器(尽管您不应该压缩系统驱动器)...

  • 发布于 2021-04-12 03:16
  • 阅读 ( 231 )

如何在virtualbox或vmware中扩展虚拟机的磁盘

在VirtualBox或VMware中创建虚拟硬盘时,请指定最大磁盘大小。如果你想以后在虚拟机的硬盘上有更多的空间,你必须放大虚拟硬盘和分区。 请注意,在执行这些操作之前,您可能需要备份虚拟硬盘文件—总有可能出错,因此备份...

  • 发布于 2021-04-12 06:00
  • 阅读 ( 256 )
N4019100603
N4019100603

0 篇文章

相关推荐