Help Center/ Server Migration Service/ FAQs/ Target Server Configuration and Launch/ Why Is the File System Size Inconsistent Before and After the Migration?
Updated on 2024-11-29 GMT+08:00

Why Is the File System Size Inconsistent Before and After the Migration?

Symptom

  • After the migration is complete, the used partition space on the target server is different from that on the source server.
  • After the migration is complete, a particular file size on the target server is different from that on the source server.

Possible Causes

If there are sparse files on the source server, the total size of the migrated files on the target server may be smaller than that on the source server. This is because rsync automatically truncates sparse files during transmission. The file system transparently converts metadata representing empty blocks into "real" blocks filled with null bytes at runtime.

You can check whether the files are consistent before and after the migration. For details, see Procedure.

In a UNIX file system, when the file displacement is greater than the file length, the next write operation will extend the file length and form a hole in the file, creating a sparse file. This is achieved by writing brief information (metadata) representing the empty blocks to disks instead of the actual "empty" space which makes up the block, thus consuming less disk space. The full block size is written to disk as the actual size only when the block contains "real" (non-empty) data.

Procedure

  1. Check the size of the file on the source server and the used disk space. The /tmp/test-data.img file is used as an example.
    1. Check the size of the /tmp/test-data.img file.

      ll /tmp/test-data.img

    2. Check the disk space occupied by /tmp/test-data.img.
      du -sh /tmp/test-data.img
      Figure 1 Checking the file size
  2. After the migration is complete, check the size of the migrated file on the target server. Figure 2 shows that the used disk space decreases after the migration.
    Figure 2 Checking target server file size
  3. Run the following command on the source server and target server to obtain the SHA256 values of the files to determine whether the files are the same.

    If the SHA256 values of the files are the same, the file content is consistent.

    sha256sum /tmp/test-data.img

    Figure 3 Obtaining the sha256 value