LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   cannot delete a folder ..tried many things.. (https://www.linuxquestions.org/questions/linux-general-1/cannot-delete-a-folder-tried-many-things-4175736023/)

pedpup2 04-14-2024 03:40 PM

cannot delete a folder ..tried many things..
 
I have a 1TB backup drive. I tried to delete a directory on that drive, but one folder
would not delete.

I tried rm -rf - failed
I tried to use rsync to delete it by syncing the directory with an empty directory.
No luck.

I booted up Windows 10 and tried several tricks there. No luck.
I cannot rename the directory.

Here is a sampling of the 2 main errors I get..
"the system cannot find the file or folder specified"
"the filename syntax is incorrect"

I checked : ls shows the file/folder. Thunar ( file manager) shows them too.
But Thunar reports that the whole directory and all the folders/files under it have size 0

I tried doing this with sudo - failed.

I've read many of the forum posts about this issue, and tried their solutions.

Any suggestions?

michaelk 04-14-2024 04:37 PM

Is the drive's filesystem NTFS?
How is the drive mounted? read only or r/w?
What are the permissions of the directory?

TB0ne 04-14-2024 06:01 PM

Quote:

Originally Posted by pedpup2 (Post 6495954)
I have a 1TB backup drive. I tried to delete a directory on that drive, but one folder would not delete.

I tried rm -rf - failed
I tried to use rsync to delete it by syncing the directory with an empty directory. No luck.

I booted up Windows 10 and tried several tricks there. No luck. I cannot rename the directory. Here is a sampling of the 2 main errors I get..
"the system cannot find the file or folder specified"
"the filename syntax is incorrect"

I checked : ls shows the file/folder. Thunar ( file manager) shows them too. But Thunar reports that the whole directory and all the folders/files under it have size 0 I tried doing this with sudo - failed. I've read many of the forum posts about this issue, and tried their solutions.

Any suggestions?

Well, since the only thing you're saying is "failed", don't tell us the version/distro of Linux, file system this drive uses, how it's connected to your system, what "several tricks" you tried in Windows, not really. Without any usable information, we can't guess; you don't tell us if you can delete ANYTHING on that drive, or if it's just this one folder. These things are typically because of a permissions problem, filesystem type, or some junk in the filename that the utilities can't process.

How about what the name of this folder is?? Can you rename it??

wpeckham 04-14-2024 06:18 PM

Quote:

Originally Posted by TB0ne (Post 6495966)
Well, since the only thing you're saying is "failed", don't tell us the version/distro of Linux, file system this drive uses, how it's connected to your system, what "several tricks" you tried in Windows, not really. Without any usable information, we can't guess; you don't tell us if you can delete ANYTHING on that drive, or if it's just this one folder. These things are typically because of a permissions problem, filesystem type, or some junk in the filename that the utilities can't process.

How about what the name of this folder is?? Can you rename it??

TB0ne asked most of the important questions, but I have one more.
Is it possible that you have a process that accesses this folder and has not released it? That can stop you from deleting a folder. We would have a better idea if you provided more information.

frankbell 04-14-2024 08:23 PM

Also, what is the name of this directory? Does it have spaces or unusual characters in it?

pedpup2 04-14-2024 09:09 PM

Thanks - sorry I am such a newbie - here's the info
 
Linux Distro is SolydX 2019-09 ( Kind of a spin-off of Linux Mint Debian edition ( the developers of the older version built this)
The 1TB drive is connected to system via USB

Yes, I can delete anything else on the disk. It's just this one folder that chokes.

Filesystem of the 1TB drive ( from fdisk )
Device Boot Start End Sectors Size Id Type
/dev/sdb1 * 2048 1953525166 1953523119 931.5G 7 HPFS/NTFS/exFAT

Drive is mounted with r/w permissions for all ( Owner,group and others). I am the owner.
The folder concerned has the same permissions.

folder name is "1525-01-28-2021".
It can be renamed. It can be moved ( I put it in the .Trash-1000 folder )
It contains several other folders and files, and,yes, 2 of the files have weird characters
in their names. One has a '\' at the end, the other has a ^M embedded in it.

Here is one trick I tried in Windows 10( that failed ) :
rd /s /q "\\?\E:\<path to the drive>

One suggestion was to view the 8.3 name with dir /x. I did this - there was no 8.3 name

I went to a subfolder in this directory, which was "empty", and did ls -l and got this
ls: cannot access 'ChrisJones\': Input/output error
total 4
d????????? ? ? ? ? ? 'ChrisJones\'
drwxrwxrwx 1 phild phild 4096 Apr 13 12:01 Tulsat

Did ls -l in another sub-folder with the other screwy filename
ls: cannot access 'media[0]'$'\r''otation.dat': Input/output error
total 0
-????????? ? ? ? ? ? 'media[0]'$'\r''otation.dat'

What I get when I try to delete the directory:
[rm -rf 1525-01-28-2021/ ]
rm: cannot remove '1525-01-28-2021/Documents/MUM docs/vendors/ChrisJones\': Input/output error
rm: cannot remove '1525-01-28-2021/Documents/MUM docs/vendors/Tulsat': Directory not empty
rm: cannot remove '1525-01-28-2021/Documents/scripts/bash tutorial/backups': Directory not empty
rm: cannot remove '1525-01-28-2021/KHOE/media/media[0]'$'\r''otation.dat': Input/output error

File manager shows #2 and 3 are empty. but ls shows they are not.

Hope this is enough info..
Thanks for your patience. I've learned a lot in linux, but still a bit green in forum etiquette

fatmac 04-15-2024 04:17 AM

Look for dot files (.), ls -a, (or 'unhide' in a file manager).

Possibly need to use sudo or the root account to delete them.

MadeInGermany 04-15-2024 04:18 AM

fdisk does not report the file system type.
Correct commands are
df -T
lsblk -fp

The Input/Output errors mean the file system is corrupted.
You can try to repair it - a NTFS/exFAT on Windows, a ext3 or ext4 or xfs on Linux.
If you want to make it completely empty then you better recreate the file system.
Before repair or recreation, umount the disk on Linux and make it safe for removal on Windows.

pan64 04-15-2024 04:42 AM

yes, first those Input/Output errors should be solved. That blocks any other operation. You might want to repair the filesystem as it was already recommended and/or you can use smartctl to check your disk(s).

pedpup2 04-15-2024 12:19 PM

Thanks to all..

there are no dot files.
and I've tried sudo to delete - no dice.

[MadeInGermany]
df -T results:(sdb1 is the drive where the errant folder is located)

Filesystem Type
/dev/sdb1 fuseblk 976761556 395081460 581680096 41% /media/phild/TERA1

lsblk -fp shows

/dev/sdb

└─/dev/sdb1
ntfs TERA1 2AE8FB4AE8FB1335 554.8G 40% /media/phild/TERA1

"The Input/Output errors mean the file system is corrupted."
You can try to repair it - a NTFS/exFAT on Windows, a ext3 or ext4 or xfs on Linux."

Since it is NTFS/ExFat, must it be repaired in Windows?

Can the filesystem be repaired without deleting all the data on the drive?
I'll try smartctl on it.

IS there a way to fix I/O errors without major surgery?

pp2

TB0ne 04-15-2024 12:44 PM

Quote:

Originally Posted by pedpup2 (Post 6496146)
Thanks to all..
there are no dot files. and I've tried sudo to delete - no dice.

[MadeInGermany]
Code:

df -T results:(sdb1 is the drive where the errant folder is located)

Filesystem    Type
/dev/sdb1      fuseblk  976761556 395081460 581680096  41% /media/phild/TERA1

lsblk -fp shows
/dev/sdb
│                                                                   
└─/dev/sdb1
    ntfs  TERA1 2AE8FB4AE8FB1335                      554.8G    40% /media/phild/TERA1

"The Input/Output errors mean the file system is corrupted." You can try to repair it - a NTFS/exFAT on Windows, a ext3 or ext4 or xfs on Linux." Since it is NTFS/ExFat, must it be repaired in Windows?

Can the filesystem be repaired without deleting all the data on the drive? I'll try smartctl on it. IS there a way to fix I/O errors without major surgery?

A filesystem repair is just what it sounds like...it REPAIRS the file system, it doesn't delete/erase it. And fixing NTFS/exFAT is far better done on Windows than Linux, especially if you aren't 100% sure of what you're doing. Smartctl is for drive hardware, not fixing filesystems...read the man page on that command and what it is/does.

pan64 04-16-2024 12:27 AM

Quote:

Originally Posted by TB0ne (Post 6496149)
A filesystem repair is just what it sounds like...it REPAIRS the file system, it doesn't delete/erase it. And fixing NTFS/exFAT is far better done on Windows than Linux, especially if you aren't 100% sure of what you're doing. Smartctl is for drive hardware, not fixing filesystems...read the man page on that command and what it is/does.

Additionally, if you want to be on the safe side you can make a backup copy of the available data on that disk before trying to repair it. Just in case the disk/data is not recoverable.

business_kid 04-16-2024 12:20 PM

I'm going to disagree with some previous post and say that any I/O or Input/Output errors I have run down have damaged hardware behind them.

In the case of a disk surface, it may be only a few sectors that have failed. To verify my diagnosis, run badblocks with some logging options.

It doesn't bode well for the disk's future, though. Older IDE drives (Anyone remember those?) would clunk along happily with the surface gradually collapsing, but with newer drives, the first surface errors are really the last warning to get anything you really want off that disk.

murugesandins 04-16-2024 11:35 PM

>> I booted up Windows 10
If I am facing your issue, I used to follow:

Install procexp.exe at windows
Open procexp.exe
Press Ctrl shift f
search the directory where you are facing this error
Assume that bash.exe is using that directory
Open cmd.exe as administrator
kill those process which is using this directory using
C:\Windows\System32\taskkill.exe /f /im bash.exe
After that:
CD /D ERROR_DIRECTORY_FULL_PATH_PREVIOUS_DIRECTORY
icacls.exe "%CD%" /Setintegritylevel (OI)(CI)Medium
After this try removing rm.exe (since I have cygwin at windows) inside bash.exe

rknichols 04-17-2024 09:38 AM

Quote:

Originally Posted by business_kid (Post 6496379)
I'm going to disagree with some previous post and say that any I/O or Input/Output errors I have run down have damaged hardware behind them.

Indeed, "Input/output error" generally relates to hardware problems. There should be messages recorded in the system error log indicating what went wrong. I'm not familiar with the "SolydX" distribution and whether you can just look at /var/log/messages or have to use journalctl to see the system messages.


All times are GMT -5. The time now is 12:58 AM.