A teacher told that in my Unix course and I would like to know how a 10GB partition can handle a 1TB file ?

  • 1
    What is a "To"? Presumably you mean Terabyte / TB? – Attie Mar 11 '18 at 22:50

What your teacher is most likely referring to is something called "sparse files". These are files which grow as they are written to, with the underlying disk holding the magic - thus, provided that the filesystem is empty (and specifically writing 0's is not empty) its possible to create a 10 gig sparse file/block device using only a fraction of that on disk.

Look at this superuser link for more details on sparse files - especially the first response which explains how to do it in DD.

  • oh okay that's what i was thinking it's like a having "1000 m² of void in 10m²" in some way ? – Henley n Mar 11 '18 at 22:49
  • 2
    The filesystem doesn't record the zeroes, but rather records the seek() (which can skip forward or backward in a file)... It's sort of like holding an IOU for n apples, rather than a bucket of n apples. – Attie Mar 11 '18 at 22:52
  • 2
    Its a bit similar to those fake USB disks you get out of China which claim to be 128GIG, but are actually 4 gig - they just tell the OS they have more space then they do - but when you run out of actual space, bad things happen. (Of-course, sparse files are designed to grow as needed, so you don't have problems until its more then the underlying disk, and they probably won't silently drop all your data) – davidgo Mar 11 '18 at 22:55
  • lmao fanks for the explaination – Henley n Mar 11 '18 at 23:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.