I'm trying to use an old windows NTFS drive as extra storage on a raspberry pi. I tried to delete everything on it, but came across a problem where I can't remove two broken links. I can format the drive entirely, but wanted to know if there's a solution to this before quitting.
I mounted the drive read-write to /media/pi/hdd and ran
cd /media/pi/hdd rm -v -r *
Eventually, everything deleted except two files in the following directory: Program\ Files/WindowsApps/Microsoft.MicrosoftOfficeHub_17.8830.7600.0_x86__8wekyb3d8bbwe/VFS/
Listing the contents of that directory:
ls -l lrwxrwxrwx 1 root root 26 Feb 10 2018 ProgramFilesCommonX86 -> unsupported reparse point lrwxrwxrwx 1 root root 26 Feb 10 2018 SystemX86 -> unsupported reparse point
If I do a 'touch foo', the results change:
ls: cannot access 'ProgramFilesCommonX86': Input/output error ls: cannot access 'SystemX86': Input/output error total 0 -rwxrwxrwx 1 root root 0 Aug 28 19:59 foo d????????? ? ? ? ? ? ProgramFilesCommonX86 d????????? ? ? ? ? ? SystemX86
I've tried the following commands but to no avail:
rm -rfd * # rm: cannot remove 'ProgramFilesCommonX86': Directory not empty # rm: cannot remove 'SystemX86': Directory not empty unlink ProgramFilesCommonX86 # unlink: cannot unlink 'ProgramFilesCommonX86': Directory not empty
Genius idea: Tried to overwrite link to another file but that didn't work either.
touch foo ln -sfn foo ProgramFilesCommonX86 # ln: cannot remove 'ProgramFilesCommonX86': Directory not empty
Is this a specific NTFS related issue that can't be fixed because I'm in a Linux environment? Or is there a command or switch that I'm overlooking, or something else entirely?
Edit (semi-answer): I did not find a solution in a Linux environment.
I used the Windows chkdsk command to fix any errors, then I deleted those two files/links/directories manually within Windows after changing the owner to myself.
Although this fixed the issue, the chkdsk command created another file/link under $RECYCLE.BIN that has the same problem. I was unable to remove that file because it didn't show up in the Windows File Explorer and I couldn't figure out how to change the owner through the command line.
Should have formatted it from the start.