In the classic Unix file systems, the answer would be "No" (that is, the data for a created and deleted file would not necessarily ever make it to the disk), though some of the directory metadata (modification time) would probably still change. Therefore, what happens does depend in part on the file system in use.
Note that even calling sync()
doesn't guarantee that they are written; it only schedules the writing of the data back to disk. Hence the ancient injunction to type the sync
command twice before bringing down the system - doing that gave the computer enough time to complete the writing because it can write to disk faster than you can type sync
twice (especially if you happen to be using a real Teletype at 110 baud).
The POSIX standard says (of the sync()
function which is used by the sync
command):
The sync() function shall cause all information in memory that updates file systems to be scheduled for writing out to all file systems.
The writing, although scheduled, is not necessarily complete upon return from sync().
If Linux has changed its definition to assure you that 'all data is written to disk', then that is a valid and useful extension. But it isn't the classic behaviour - and beware translating the Linux expertise to other systems.
There are other functions, such as fsync(), that give different, more stringent, promises:
The fsync() function shall request that all data for the open file descriptor named by fildes is to be transferred to the storage device associated with the file described by fildes. The nature of the transfer is implementation-defined. The fsync() function shall not return until the system has completed that action or until an error is detected.
And there are options to file descriptors that give other promises again: O_SYNC, O_DSYNC, O_RSYNC. Look them up in the POSIX standard (open()
).