Why does the command mv return the message mv: cannot move Device or resource busy on Linux?

3

1

I was attempting to move files from one directory to another and was displayed the following message although the files were moved. Why does display the "error" and what does it mean? When does it occur? The directories are on the same device and partition. The device runs off Ubuntu 12.04 LTS

Error

*mv: cannot move `.' to `../new_media/press/.': Device or resource busy*

PeanutsMonkey

Posted 2012-12-28T06:12:14.943

Reputation: 7 780

Answers

3

From the rename(2) man page:

   EBUSY  The  rename fails because oldpath or newpath is a directory that
          is in use by some process (perhaps as current working directory,
          or  as root directory, or because it was open for reading) or is
          in use by the system (for example as  mount  point),  while  the
          system considers this an error.  (Note that there is no require‐
          ment to return EBUSY in such cases — there is nothing wrong with
          doing  the  rename anyway — but it is allowed to return EBUSY if
          the system cannot otherwise handle such situations.)

Ignacio Vazquez-Abrams

Posted 2012-12-28T06:12:14.943

Reputation: 100 516

Thanks. Is there a way to tell whether the said "directory" is in use by some other process? – PeanutsMonkey – 2012-12-28T07:48:18.023

2If you're trying to move . then it's your current working directory and you should move out of it. – Ignacio Vazquez-Abrams – 2012-12-28T10:43:24.677

2

Some process is using the file/s. You can find what files are open by what processes using the command 'lsof' (list open files). This will return a lot of open files. Once you've found the process, you could try killing it.

Or restarting the computer may be easier if that is an option.

askvictor

Posted 2012-12-28T06:12:14.943

Reputation: 1 450