Why delete is fast but copying takes time




 In Operating System, Files are stored and tracked using file systems. A file system represents a file by a structure called inode. It includes information like file attributes and the blocks it occupies on the hard disk.

In order to copy a file, a new file need to be created and it need to be freshly copied in different available location which takes a lot time causing expensive disk writes with an additional overhead of buffers in memory.


 the operating system only needs to delete the reference and mark the blocks used

Many operating systems do a soft delete when you ask it to delete a file, hence it is fast. When you copy, the file needs to be physically stored on the disk which takes a lot time, as many disk accesses as big the file is.


In order to delete a file, Operating system do a soft delete. They only delete the reference and mark the blocks used by the deleted file as free for future use which is significantly more quicker.

Deleting a reference is much faster and does not involve lot of disk and memory write operations.

On the other hand time required for copying a file to hard disk will be directly proportional to the size of the file. Consecutive block writes would be faster.

Next Post Previous Post
No Comment
Add Comment
comment url