Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Under following conditions-

  1. mv within the same HDD partition
  2. mv to a different partition in the same HDD
  3. mv to a different device (e.g. USB HDD)

Is the complete file moved or is it a very small change like some pointer reassignment ?

share|improve this question
That probably depends on the source and destination file systems, and as such there's probably no one answer. If source and destination are the same exact filesystem, usually only a few bookkeeping bits are shuffled around for most common Unix/Linux file systems. – jw013 Sep 13 '12 at 17:05
@jw013 Thanks for the comment. I edited the question. I'm not clear about difference between file-system and HDD partition. – user13107 Sep 13 '12 at 17:10
Filesystem is a kind of 'description' how the file is stored on a disk. Example of filesystems can be ext3, ext4 or NTFS. A partition is a part of the disk, that can contain a filesystem. – Paweł Rumian Sep 13 '12 at 17:38
@gorkypl So it seems a single disk can contain multiple partitions with same / different file-systems. – user13107 Sep 13 '12 at 17:44
Exactly what you said. Your question is not bad, but as jw013 said, the answer depends on the filesystem, as different filesystems may implement the mv procedure in different ways. – Paweł Rumian Sep 13 '12 at 17:50
up vote 4 down vote accepted

It's up to each filesystem how to handle a move within the filesystem (also known as renaming a file), but filesystems pretty much universally handle it by updating directory entries without moving the inode or file contents.

A move between filesystems (it doesn't matter if it's on the same physical medium or not) is handled as a file copy followed by a delete. This is in fact exactly what the mv command does. Obviously that means that the destination filesystem has to make a new copy of the file.

share|improve this answer
Thanks. So if mv is interrupted before deletion, does the file remain intact at the source ? – user13107 Sep 13 '12 at 17:54
Yes, you will certainly keep the source file if mv is interrupted. Depending on whether or not mv is given a chance to clean up after itself when it gets interrupted you may find a partially copied file at the destination too! – Celada Sep 13 '12 at 17:59
What about different partition, but same filesystem case? Here also copy->delete or just updating directory entries? – user13107 Sep 13 '12 at 18:03
Filesystems usually don't span partitions, so that case can't usually happen. – Jim Paris Sep 13 '12 at 18:12
@user13107 I don't know anything about MS Windows and "drives", but it sounds like your "C:/ drive" and "D:/ drive" may contain filesystems of the same type, but certainly don't both contain the actual same filesystem! Perhaps you are thinking of filesystem types like zfs and Btrfs, which actually can span multiple block devices (e.g. partitions)? In this case the answer is the same as always when renaming a file within a filesystem: only the directory entry will move. – Celada Sep 13 '12 at 18:46

Your Answer


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.