All Products
Search
Document Center

:Why is the size of a snapshot larger than the disk capacity that is displayed in the file system?

Last Updated:Feb 08, 2024

If you create a snapshot for a disk on an Elastic Compute Service (ECS) instance after you delete files from the disk, the size of the snapshot is larger than the disk capacity that is displayed in the relevant file system, or is not smaller than the size of a snapshot that was created for the disk before you delete the files from the disk. This topic describes the causes of this issue.

Causes

This issue may occur due to the following reasons:

  • File system metadata occupies disk space.

  • Logical Block Addressing (LBA) is used to split disks into same-sized blocks. When the file system is initialized, data is written to a large number of blocks. The write operation occupies disk space.

  • When you delete files, the file system adds a Deprecated flag to the attributes of the files without actually deleting the file content. This reduces resource consumption. The disk cannot detect the delete operation, and the data blocks remain allocated to the files and are copied to the snapshot. As a result, the size of the snapshot exceeds the disk capacity that is displayed in the file system.

  • The Kernel-based Virtual Machine (KVM) virtio-block module and Xen block-front module do not support the TRIM command. The TRIM command informs a disk of which data blocks in the LBA range are no longer in use and can be erased. In this case, the disk cannot determine whether the data can be deleted.

Relationship between a file system and a disk or snapshot

You can create a file system on a disk partition. The file system issues I/O requests to the disk to manage the disk space. The disk records the status of data blocks and copies data to Object Storage Service (OSS) buckets based on specific business requirements. Snapshots are created in this process. The following figure shows the relationship between a file system and a snapshot.

image
Note

The preceding figure shows that if data is written to data blocks, the snapshot records the blocks regardless of whether the related files are deleted from the disk. When you delete files, the file system only adds a flag as a file attribute to indicate that the files are no longer in use and the disk space that is occupied by the files is available. However, the disk space that is used by the files is not actually freed on the disk.

Relationships between data writes and disk formatting

You can use a new disk or disk partition only after it is initialized and the data structure of the disk or disk partition is recorded on the disk. The goal of formatting is to create file systems. When a file system is created on a disk, data of the file system is written to the disk. The amount of data that is written to a disk during formatting varies based on the file system.

  • For a Windows instance, you can use one of the following methods to format a data disk:

    • Quick formatting: This method allows you to allocate only file systems to partitions and rewrite the directory table. Quick formatting takes up less space than full formatting.

    • Full formatting: This method allows you to allocate file systems to partitions, rewrite the directory table, and scan for and mark damaged sectors. In addition, empty data blocks on the disk are filled during the formatting process, which is equivalent to writing the entire disk. In this case, the size of the first full snapshot is approximately equal to the disk capacity.

  • For a Linux instance, if no data is written to a disk after you format the disk, the size of the first snapshot varies based on the format of file systems on the disk.