3

I'm trying to delete two folders on a drive on an Ubuntu server which were created by Windows (drive previously mounted on Windows and their content is just garbage now).

I've tried everything I can think of, with the errors returned being very different:

  • chmod 777 the directories (No such file or directory)
  • rm with sudo and correct options (Permission denied)
  • Tried to delete by inode number via find (Directory not empty or Permission denied)


Hierarchy structure:

  • /media/mattgeek/programmi/WindowsApps/
    - SpotifyAB.SpotifyMusic_1.112.449.0_x86__zpdnekdrzrea0/
      - Apps/
          (Unknown content not visible with ls -al)
      - AppxMetadata/
          CodeIntegrity.cat
      - Assets/
          (Unknown content not visible with ls -al)
        chrome_elf.dll
      - locales/
          (Unknown content not visible with ls -al)
      - swiftshader/
          libEGL.dll
          libDLESv2.dll
    
  • /media/mattgeek/programmi/WpSystems/S-1-5-21-2951927762-82725512-1342253419-1001/
    - AppData/
      - Local/
        - Packages/
          - SpotifyAB.SpotifyMusic_zpdnekdrzrea0/
            - Settings/
              (contains an inaccessible file with unknown inode and unknown permissions)
    


These are the outputs of the commands I've tried (in root mode):

  • rm -f /media/mattgek/programmi/WindowsApps
    
    rm: cannot remove '/media/mattgeek/programmi/WindowsApps/SpotifyAB.SpotifyMusic_1.112.449.0_x86__zpdnekdrzrea0/chrome_elf.dll': No such file or directory
    rm: cannot remove '/media/mattgeek/programmi/WindowsApps/SpotifyAB.SpotifyMusic_1.112.449.0_x86__zpdnekdrzrea0/Apps': Directory not empty
    rm: cannot remove '/media/mattgeek/programmi/WindowsApps/SpotifyAB.SpotifyMusic_1.112.449.0_x86__zpdnekdrzrea0/AppxMetadata/CodeIntegrity.cat': Permission denied
    rm: cannot remove '/media/mattgeek/programmi/WindowsApps/SpotifyAB.SpotifyMusic_1.112.449.0_x86__zpdnekdrzrea0/Assets': Directory not empty
    rm: cannot remove '/media/mattgeek/programmi/WindowsApps/SpotifyAB.SpotifyMusic_1.112.449.0_x86__zpdnekdrzrea0/locales': Directory not empty
    rm: cannot remove '/media/mattgeek/programmi/WindowsApps/SpotifyAB.SpotifyMusic_1.112.449.0_x86__zpdnekdrzrea0/swiftshader/libEGL.dll': Permission denied
    rm: cannot remove '/media/mattgeek/programmi/WindowsApps/SpotifyAB.SpotifyMusic_1.112.449.0_x86__zpdnekdrzrea0/swiftshader/libGLESv2.dll': Permission denied
    
  • rm -rvf /media/mattgek/programmi/WindowsApps
    
    rm: cannot remove '/media/mattgeek/programmi/WindowsApps/SpotifyAB.SpotifyMusic_1.112.449.0_x86__zpdnekdrzrea0/Apps': Directory not empty
    rm: cannot remove '/media/mattgeek/programmi/WindowsApps/SpotifyAB.SpotifyMusic_1.112.449.0_x86__zpdnekdrzrea0/AppxMetadata/CodeIntegrity.cat': Permission denied
    rm: cannot remove '/media/mattgeek/programmi/WindowsApps/SpotifyAB.SpotifyMusic_1.112.449.0_x86__zpdnekdrzrea0/Assets': Directory not empty
    rm: cannot remove '/media/mattgeek/programmi/WindowsApps/SpotifyAB.SpotifyMusic_1.112.449.0_x86__zpdnekdrzrea0/locales': Directory not empty
    rm: cannot remove '/media/mattgeek/programmi/WindowsApps/SpotifyAB.SpotifyMusic_1.112.449.0_x86__zpdnekdrzrea0/swiftshader/libEGL.dll': Permission denied
    rm: cannot remove '/media/mattgeek/programmi/WindowsApps/SpotifyAB.SpotifyMusic_1.112.449.0_x86__zpdnekdrzrea0/swiftshader/libGLESv2.dll': Permission denied
    
  • rm --recursive -f /media/mattgek/programmi/WindowsApps
    
    rm: cannot remove '/media/mattgeek/programmi/WindowsApps/SpotifyAB.SpotifyMusic_1.112.449.0_x86__zpdnekdrzrea0/Apps': Directory not empty
    rm: cannot remove '/media/mattgeek/programmi/WindowsApps/SpotifyAB.SpotifyMusic_1.112.449.0_x86__zpdnekdrzrea0/AppxMetadata/CodeIntegrity.cat': Permission denied
    rm: cannot remove '/media/mattgeek/programmi/WindowsApps/SpotifyAB.SpotifyMusic_1.112.449.0_x86__zpdnekdrzrea0/Assets': Directory not empty
    rm: cannot remove '/media/mattgeek/programmi/WindowsApps/SpotifyAB.SpotifyMusic_1.112.449.0_x86__zpdnekdrzrea0/locales': Directory not empty
    rm: cannot remove '/media/mattgeek/programmi/WindowsApps/SpotifyAB.SpotifyMusic_1.112.449.0_x86__zpdnekdrzrea0/swiftshader/libEGL.dll': Permission denied
    rm: cannot remove '/media/mattgeek/programmi/WindowsApps/SpotifyAB.SpotifyMusic_1.112.449.0_x86__zpdnekdrzrea0/swiftshader/libGLESv2.dll': Permission denied
    
  • # Directory inode number: 479380
    find . -inum 479380 -delete
    
    find: cannot delete './media/mattgeek/programmi/WindowsApps': Directory not empty
    
  • # Directory inode number: 479380
    find . -inum 479380 -exec rm -rf {} \;
    
    rm: cannot remove './media/mattgeek/programmi/WindowsApps/SpotifyAB.SpotifyMusic_1.112.449.0_x86__zpdnekdrzrea0/Apps': Directory not empty
    rm: cannot remove './media/mattgeek/programmi/WindowsApps/SpotifyAB.SpotifyMusic_1.112.449.0_x86__zpdnekdrzrea0/AppxMetadata/CodeIntegrity.cat': Permission denied
    rm: cannot remove './media/mattgeek/programmi/WindowsApps/SpotifyAB.SpotifyMusic_1.112.449.0_x86__zpdnekdrzrea0/Assets': Directory not empty
    rm: cannot remove './media/mattgeek/programmi/WindowsApps/SpotifyAB.SpotifyMusic_1.112.449.0_x86__zpdnekdrzrea0/locales': Directory not empty
    rm: cannot remove './media/mattgeek/programmi/WindowsApps/SpotifyAB.SpotifyMusic_1.112.449.0_x86__zpdnekdrzrea0/swiftshader/libEGL.dll': Permission denied
    rm: cannot remove './media/mattgeek/programmi/WindowsApps/SpotifyAB.SpotifyMusic_1.112.449.0_x86__zpdnekdrzrea0/swiftshader/libGLESv2.dll': Permission denied
    


Commands give similar results for /media/mattgeek/WpSystems, its subdirectories, and files.

  • rm -rvf /media/mattgek/programmi/WpSystem
    
    Output Log
11
  • 1
    Probably this, but I'm not 100% sure. Commented Dec 29, 2019 at 16:18
  • 1
    When you issued chmod, did your include -R [recursive]? chmod -R 777 /media/mattgek/programmi/WindowsApps ; chown -R $(echo $USER):$(echo $USER) /media/mattgek/programmi/WindowsApps ; rm -Rf /media/mattgek/programmi/WindowsApps should work. My next best suggestion would be to hook the drive back up to a Windows install, or boot a Windows install USB, and issue: chkdsk /x /offlinescanandfix <drive>:
    – JW0914
    Commented Dec 29, 2019 at 18:31
  • Thanks I'll try the recursive option on chmod and chown
    – MattGeek
    Commented Dec 29, 2019 at 19:10
  • 2
    About chmod and chown: most likely they won't work. Commented Dec 29, 2019 at 20:05
  • 1
    @MattGeek Due to the directories being WindowsApps subdirectories (WpSystems path is the %LocalAppData% path where that app was allowed to save data), IIRC they contain wonky permissions to ensure the apps are sandboxed, so the quickest way to get rid of them is likely going to be booting WinPE [Windows install USB] and deleting them via CLI or via QDir within WinPE. Trying to do so while booted to Windows, versus WinPE, will likely entail more steps due to having to assign recursive ownership and full permissions prior to deletion.
    – JW0914
    Commented Dec 30, 2019 at 2:02

1 Answer 1

0

Due to corrupted ownership, to be able to delete the stated directories, it's necessary to attach the drive to a Windows system and fix ownership via the security panel of those directories.

To do so the owner of the folder must be assigned to the administrator account of the computer on which the drive is mounted. Then you must delete all the previous access rules that are corrupted and replace them with new ones. It is suggested to have a look to Auditing and Effective Access tabs.

You can finally delete the folder!

You must log in to answer this question.

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