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
MattGeek
  • 131
  • 6
  • 1
    Probably [this](https://superuser.com/q/1142904/432690), but I'm not 100% sure. – Kamil Maciorowski Dec 29 '19 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](https://www.microsoft.com/en-us/software-download/windows10), and issue: `chkdsk /x /offlinescanandfix :` – JW0914 Dec 29 '19 at 18:31
  • Thanks I'll try the recursive option on chmod and chown – MattGeek Dec 29 '19 at 19:10
  • 2
    About `chmod` and `chown`: [most likely they won't work](https://superuser.com/a/1250132/432690). – Kamil Maciorowski Dec 29 '19 at 20:05
  • The permission denied error is now gone, Directory not empty remain. – MattGeek Dec 29 '19 at 20:49
  • chmod / chown fail on some WpSystem subdirectory – MattGeek Dec 29 '19 at 20:51
  • I'll edit my fstab file to add allow_other option in mounting args. – MattGeek Dec 29 '19 at 20:53
  • The allow_other option doesn't change anything – MattGeek Dec 29 '19 at 20:59
  • 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](https://www.techspot.com/downloads/6482-q-dir.html) 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 Dec 30 '19 at 02:02
  • Thanks, I'll make a Windows bootable USB and report to you. I tried to fix ownership on a Windows system via the samba share of the server but it didn't work, due to the fact it's all virtual and Windows isn't in charge of managing permission, but Ubuntu is. – MattGeek Dec 31 '19 at 10:28
  • Booting into Windows and fixing ownership makes it possible to delete the directories, thanks. – MattGeek Jan 05 '20 at 11:38

1 Answers1

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!

MattGeek
  • 131
  • 6