-2

As a follow up of my related question, is it possible to create a file without metadata? Or alternatively, can I remove all metadata of a given file?

This is quite a "philosophical issue". If this were possible, then, given my previous question, it would be possible to create an "infinite" number of files within a finite space disk. This is surely an experiment worth trying.

For example, creating 100 empty files in my 3 year old system:

lucho@lucho-HP:~test/$ time seq -f "%04.0f" 100 | xargs -I "{}" touch test"{}".txt 
real    0m0.231s
user    0m0.000s
sys 0m0.032s

Thus, in one second, I can create roughly 400 files. So, in 8 hours (say, whilst sleeping), I can create 11 million files. Not much but you get the idea.

2 Answers2

3

The information-theoretical answer to your previous question answers this too: if you’re creating files, even reduced to their minimum representation, and you want to be able to retrieve something about them, then the creation consumes some disk space, so you’ll eventually run out (however the allocation works). Thus you can’t create an infinite number of files within a finite amount of disk space.

To answer your stated question, file systems I know don’t allow you to remove file metadata, but there’s nothing preventing you from writing your own file system that ignores whatever metadata you want — I guess the minimum you need is a file name and some way of tracking the file’s contents on disk (and perhaps not even the latter, if your file system can only store empty files).

Stephen Kitt
  • 434,908
3

A file must have, at the very least a location for the first block on disk that it consumes. This limits, based on the filesystem in question, how many files can be created regardless of how much space on disk they consume. Most filesystems have limits for the number of files that can be contained (i. e. the number of entries in the "table of contents", so to speak, is capped).

The POSIX specification mandates a filesystem in which each file must have an inode on the filesystem describing it, which must have:

  • The size of the file
  • An identifier for the device containing the file
  • The UID of the file owner
  • The GID of the file
  • The file's permission set
  • Additional system and user flags (e. g. ACLs)
  • Timestamps (e. g. ctime, mtime, atime)
  • A count of the number of hard links to the inode
  • Pointers to the disk blocks that store the file's contents

These data consume space, which limits the number of files that can be stored no matter how small the actual files are.

DopeGhoti
  • 76,081
  • No, Unix files don't have names but just inodes. Names are in directories (a special kind of file). A given inode could have no name at all (e.g. temporary files, still opened by some process) or several different names -all having an equivalent role, i.e. no name is more important- (thru link(2) syscall). – Basile Starynkevitch Jul 24 '17 at 17:45
  • The reference to a name was in an early draft of the answer that I did not fix. It's been edited out; thanks for the catch. – DopeGhoti Jul 24 '17 at 18:36