Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

In Ubuntu, unlike in Windows, I can rename a file while it's being written onto the hard disk (for example because it's the output of a program or the copy of another file), and I can also rename a directory containing files that are being written: the system doesn't send messages like "The file is being used, operation not allowed". Is this renaming operation 100% safe, or there's a risk of creating corrupted files? And, in the first case, what is the technical reason that makes it possible, differently from other operating systems? (maybe something related with Linux file system structure and the use of Inodes, I think...?)

Thank you very much.

share|improve this question
add comment

1 Answer 1

up vote 4 down vote accepted

Linux works on file handles and renaming or moving a file in Linux does not alter the file handle. Even deleting a file will not be a problem: the process that owns the file handle can still read and write.

The Wikipedia page on inodes will be the best read on this.

In computing, an inode (index node) is a data structure found in many Unix file systems. Each inode stores all the information about a file system object (file, device node, socket, pipe, etc.). It does not store the file's data content and file name except for certain cases in modern file systems.

Implications

A file's inode number stays the same when it is moved to another directory on the same device, or when the disk is defragmented which may change its physical location. This also implies that completely conforming inode behavior is impossible to implement with many non-Unix file systems, such as FAT and its descendants, which don't have a way of storing this invariance when both a file's directory entry and its data are moved around.


So: yes.

share|improve this answer
    
Ok, so is the answer to my main question "yes"? –  Andrew Sep 22 '13 at 9:56
    
Thank you very much Rinzwind. –  Andrew Sep 22 '13 at 11:34
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.