What is a sparse file, and can they be identified?

Solution Verified - Updated -

Issue

  • What is a sparse file, and can they be identified?
  • There's an inconsistent between the values reported by commands such as ls and df.
  • Found a file reporting a size larger than the space used in the filesystem where it is located. How can this be possible?

    # ls -l /templates/disk.img
    -rw------- 1 root root  40G Oct 18 10:05 /templates/disk.img
    
    # df -h /data
    Filesystem            Size  Used Avail Use% Mounted on
    /dev/vdb1              20G  9.8G  9.0G  53% /templates
    

Environment

  • Red Hat Enterprise Linux 10
  • Red Hat Enterprise Linux 9
  • Red Hat Enterprise Linux 8
  • Red Hat Enterprise Linux 7
  • Sparse files

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content