5

I ran mv a-folder /home/me on a machine and half way through the move the destination device filled up.

a-folder was made up of folders and files in various subdirectories.

Does mv leave the source folder intact until the move has successfully completed?

The source and destination folders were on different filesystems.

The reason I ask is that I ran this command on the wrong machine, so if the source folder is intact then that makes my life a lot easier :)

2 Answers 2

4

No your source folder is not intact... On the same file system all mv does is add and remove directory entries. But on a different filesystem... I'm not sure at what point it unlinks the file, and whether it removes data as it goes... but once a file is moved, it is unlinked.

This is unless of course you used a special option to mv. Some of which are mentioned in this question which might interest you in the future.

1
  • If moving a file to different filesystem fails, does the source file stay intact?
    – jarno
    Oct 14, 2017 at 11:58
4

xenoterracide's answer is 100% correct, I'll just add to it.

I often monitor the copy or move process of large amounts of files with:

watch -d -n 1 'du -sk dir1; du -sk dir2'

This will show you how the cumulated file size changes over time, proving to you that files are moved and removed (with mv) progressively along the way.

1
  • 3
    Thanks for that. Your username is strangely appropriate! ;)
    – Rich
    Mar 3, 2011 at 7:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .