Linux remove directory resource busy

Shell cannot remove device or resource busy unix

This tutorial will fix the device or resource busy error in Linux. Alternative Method in Fixing the Device or Resource Busy Error on Linux Type the following command into that directory to see what’s there.

«Device or Resource Busy»

I had the same experience and I solved it with the aid of another thread on this same issue.

Read How to get over «device or resource busy»?

The contribution that helped me was:

ps -ef | grep name-of-busy-dir 

Showed me the process and the PID (column two).

Thereafter, delete your folder without any qualms.

Another pretty much simple answer is following:

1. Close all your terminal windows (bash, shell, etc. )

2. Start a new terminal

3. Execute your command again e.g.:

Hopefully it helps others!

Automatically solve rm cannot remove path

That will recurse through the filesystem under /path, so beware doing it on large directory trees.

Once you know which processes have files open, you can exit those apps, or kill them with the kill(1) command.

Mount — umount — device is busy, Given your «usual solution», it means that the shell you have running in your console window has a directory in a file system on that device

Fix the Device or Resource Busy Error on Linux

This tutorial will fix the device or resource busy error in Linux. But first, let’s understand what device or resource busy is.

Some directories cannot be deleted if the device or resource is busy. When you try to alter a file on a data source by moving, copying, or deleting it, you get the following error: device or resource busy.

Use lsof to Find Open Files in a Certain Directory in Linux

The program lsof , which stands for list open files , will be required. There are various ways to utilize this tool, and one of them is to find open files in a certain directory.

chrome 39483 39488 GpuMemory user mem REG 8,5 285840 11410830 /usr/lib/x86_64-linux-gnu/libfontconfig.so.1.12.0 chrome 39483 39488 GpuMemory user mem REG 8,5 678064 11411469 /usr/lib/x86_64-linux-gnu/libpixman-1.so.0.38.4 chrome 39483 39488 GpuMemory user mem REG 8,5 1065824 11411080 /usr/lib/x86_64-linux-gnu/libharfbuzz.so.0.20600.4 chrome 39483 39488 GpuMemory user mem REG 8,5 41152 11411707 /usr/lib/x86_64-linux-gnu/libthai.so.0.3.1 chrome 39483 39488 GpuMemory user mem REG 8,5 112960 11410855 /usr/lib/x86_64-linux-gnu/libfribidi.so.0.4.0 chrome 39483 39488 GpuMemory user mem REG 8,5 85448 11411836 /usr/lib/x86_64-linux-gnu/libwayland-server.so.0.1.0 chrome 39483 39488 GpuMemory user mem REG 8,5 39448 11410444 /usr/lib/x86_64-linux-gnu/libXrender.so.1.3.0 chrome 39483 39488 GpuMemory user mem REG 8,5 26800 11410422 /usr/lib/x86_64-linux-gnu/libXdmcp.so.6.0.0 chrome 39483 39488 GpuMemory user mem REG 8,5 18688 11410411 /usr/lib/x86_64-linux-gnu/libXau.so.6.0.0 chrome 39483 39488 GpuMemory user mem REG 8,5 709496 11409861 /usr/lib/x86_64-linux-gnu/libsystemd.so.0.28.0 chrome 39483 39488 GpuMemory user mem REG 8,5 101320 11411551 /usr/lib/x86_64-linux-gnu/libresolv-2.31.so 

After running this command, you will be rescued through the file system under /path , so it is best to perform it under huge directories.

Читайте также:  Найти cd rom linux

You can exit those programs or kill them with the kill command after you’re aware of the processes that have files open.

Alternative Method in Fixing the Device or Resource Busy Error on Linux

Type the following command into that directory to see what’s there.

Look into the contents of the file with vi .

" ============================================================================ " Netrw Directory Listing (netrw v165) " /home/user/user/aven/destination " Sorted by name " Sort sequence: [\/]$,\,\.h$,\.c$,\.cpp$,\~\=\*$,*,\.o$,\.obj$,\.info$,\.swp$,\.bak$,\~$ " Quick Help: :help -:go up dir D:delete R:rename s:sort-by x:special " ============================================================================== ../ ./ thanosdir/ thanosdir2/ thanosdir4/ thanos.txt thanos1.txt thanos2.txt ~ 

You’ll notice that, due to an error, the data in the eighth column was messed up. The ps-ef command can find the process PID .

user 44317 38941 0 22:10 pts/0 00:00:00 grep --color=auto thanos1.txt 

As mentioned, the output contains the PID . We can kill that process by using kill PID .

Linux Error

NFS mount: Device or resource busy, The above solution works when you are manually deleting the file. But I have a python script that deletes the files (automated process).

Nfs file can’t be removed — resource busy, but PID unknown

This question is old and I’m not sure if the circumstances I endured are similar or completely different. However, I did find the solution to my issue with the same symptom.

I was trying to clean a directory from build cruft via rm -rf build/tmp/path and a file deep in the tree named .nfs000* was throwing the «Device or resource is busy» error.

My problem was multi-faceted. The first element was the use of roaming home directories at the office. The second, was docker and the use of containers. Finally, vim and editing a file. While in the container, I was abruptly disconnected from my terminal which killed the shell and the vim program I had running, but it did not kill the container . However, because vim was dead no process did have that file open (but the container did). Finally, it wasn’t called the usual .something.swp as vim temp file would because an attempt to delete it had taken place. That’s when NFS stepped in to «save the day.» Killing the containe solved the problem.

I don’t know if this is what the OP had back then. I offer this only that, when someone else stumbles onto this, perhaps this will inspire you to think indirectly about the cause. This link actually provided me the inspiration for the problem. After cat ing the file, I found it was a VIM tmp file.

How to get over «device or resource busy»?, Go into the directory and type ls -a · You will find a .xyz file · vi . · ps -ef | grep username · You will see the . · kill -9 job_ids — where job_ids is the value

Источник

Failure to remove directory due to busy resource or device

If the above solutions have not resolved the issue and you are using a Windows PC, the simplest solution is to open the run command box by pressing the Windows key + R on your keyboard. Type «resmon.exe» in the box and click OK to open the resource monitor. In the monitor, navigate to the CPU tab and search for the path to the file or folder in question under Associated Handles. Paste the path in the search box and click the search icon. You will be able to see all the programs using the file or folder. Right-click each program and select end-process. You can now continue working on the file or folder, as the problem is that the directory is in use, not that it contains files.

Why Device or resource busy whent to remove the file?

To remove the partition, it’s necessary to unmount it first as the device or resource is busy due to the partition being mounted. A solution is to open the terminal and execute the following command:

sudo umount -f /mnt/winntfs/mydoc sudo rm -rf /mnt/winntfs/* 

How to get over «device or resource busy»?, My typical solution is to rename or move the parent directory of the file, then come back later in a day or two and the file will have been removed

Cannot remove ‘external_volume’: Device or resource busy in Ubuntu

I got the following error when trying to remove volume folders : cannot remove
Duration: 1:11

Error: EBUSY: resource busy or locked, rmdir

If the solutions mentioned earlier were unsuccessful and you happen to be utilizing a Windows computer, the simplest course of action would be:

  1. Press windows key plus R on your keyboard to open the run command box and type this resmon.exe
  2. click OK to open resource monitor
  3. In the monitor, navigate to CPU tab
  4. Under Associated Handles in the search box, copy the path to the file or folder in question and paste it in there
  5. Click on the search icon
  6. You should be able to see all the programs using the file or folder
  7. right-click each and end-process

Resume your file or folder tasks without interruption. In my situation, I encountered difficulties while utilizing npm for react-create-app. You can find further details on issue #117908.

I just hope it helps someone.

The error message you are encountering is caused by a program that has locked the folder. To identify the problematic program, you can try executing the command after closing each program one by one.

An area of concern among users was related to the anti-malware software on Windows. For more information, refer to the following thread.

The link provided directs to an issue posted on the GitHub repository of npm, which is numbered as 13461.

If the link becomes inactive, the following comment with the highest number of upvotes is provided.

To fix the issue on my Windows 10 64-bit OS, I uninstalled the Anti-Malware software.

The error can also be activated when executing npm run [command] in a directory that it modifies. I encountered this issue even after closing all programs, but then noticed that I was in the dist folder, which needed to be deleted and recreated. This consistently caused the PowerShell Error: EBUSY: resource busy or locked, rmdir error.

Verify whether the directory or folder that you intend to remove is currently in use within any open terminals. It is possible that there are several terminal sessions running, so make sure to investigate thoroughly.

The issue can be resolved either by changing the directory in the current terminal session or by terminating the terminal instance.

Device or resource busy when try to delete directory from running, You mounted it? – Thorbjørn Ravn Andersen · I’d delete and recreate the container, doubly true if deleting the directory confused the main

Undeletable directory

# rm -rf /path/to/undeletable rm: cannot remove ‘/path/to/undeletable’: Is a directory 

rm invokes stat(2) to determine whether the specified /path/to/undeletable is a file or a directory that should be deleted by unlink(2) or rmdir(2) , respectively. As the stat call is unsuccessful (the reason will be explained shortly), rm resorts to utilizing unlink , which causes the error message to appear.

# rmdir /path/to/undeletable rmdir: failed to remove ‘/path/to/undeletable’: Device or resource busy 

The issue is not that the directory is not empty, but rather that it is being utilized by a device or resource, as indicated by the error message «Device or resource busy». It is highly likely that the directory is serving as a mount point.

# lsof +D /path/to/undeletable lsof: WARNING: can't stat(/path/to/undeletable): Permission denied 

Verification has been made that the stat in the directory was unsuccessful due to the limitation of FUSE. The root’s lack of permission can be attributed to this limitation. It is important to note that unless the FUSE filesystem is mounted with the allow_other option, processes with the same user ID as the FUSE driver provider are the only ones that can access it. This limitation affects even root.

You have a FUSE filesystem that’s been mounted by a user who isn’t the root. What’s your plan of action?

    Most likely you’re just annoyed by that directory and want to unmount it. Root can do that.

mkdir /elsewhere/undeletable chown bob /elsewhere/undeletable mount --move /path/to/undeletable /elsewhere/undeletable mail bob -s 'I moved your mount point' 
su bob -c 'rm -rf /path/to/undeletable' 
mount --bind /path/to /mnt rm -rf /mnt/undeletable/* /mnt/undeletable/.[!.]* /mnt/undeletable/. * umount /mnt 

Rm: cannot remove »: Device or resource busy, The filesystem driver has probably crashed, either that or it hadn’t even noticed it should’ve crashed. I would suggest rebooting the computer.

Cannot remove file, Device or resource busy

The object is still affixed. You can probably spot it by executing the mount command. In case you do, proceed with running the subsequent instructions.

# umount /var/lib/docker/aufs # rm -rf /var/lib/docker 

Undeletable directory — Unix & Linux Stack Exchange, “Device or resource busy”, not “Directory not empty”. So the problem is that the directory is used by something, not that it contains files. The

Источник

Оцените статью
Adblock
detector