Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Is it possible to create a file on a disk which is full??

Does creation of the file take any space??

Basically I am seeing a case where C# has created but failed to write anything whhich I think points to a full disk.

Does anyone know whether creating a file on a full disk will fail or not??

share|improve this question
    
You might ask this question on StackOverflow instead. –  Seanchán Torpéist Jan 11 '10 at 10:06
    
Doesn't the file creation call return an error that can be trapped and read if there's a full filesystem? From your description there could also be permission errors, as it's possible to have permission to create a file but not modify it. –  Bart Silverstrim Jan 11 '10 at 12:40
add comment

2 Answers

It depends on the filesystem.

The vast majority of filesystems will allow a file of zero length to be created even if there are no free block on the disc as no blocks need to be allocated at that point, unless the directory entry's blocks are full in which case you will get a "no space" error as it tries to add a new block to the directory listing. Certainly NTFS will works way. Some filesystems allow the content of small files to be stored in the the directory entry itself or other pre-allocated structures - so you might be able to create small-but-not-zero-length file on a seemingly full filesystem.

Some older filesystems (FAT*?) will always allocate the first block of the file at creation time as their spec doesn't allow for files with no blocks allocated so these will always fail to create a file on a full device.

share|improve this answer
add comment

Yes, because when you create a file that has no data, it only resides in the Master File Table (MFT). If the file is 1 kbyte or less, it only exists in the MFT. It's possible for the disk to report no free space, but the MFT may have enough free space to create a file.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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