Cannot move locked file to trash or delete immediately

Discussion in 'OS X El Capitan (10.11)' started by Upgrader, Feb 21, 2016.

  1. Upgrader macrumors regular

    Upgrader

    Joined:
    Nov 23, 2014
    #1
    Hi,

    I upgraded to El Capitan and was left with a folder called ‘Previous System’ in the root of my SSD.

    I deleted and emptied the trash but was left with a vm folder with a locked 'sleepimage’ file inside.

    Dragged it to my desktop and tried to unlock but couldn’t.

    Now I can’t delete immediately or even move to trash it. It’s 0kb in size.

    I’ve restarted but still no luck.

    Anyone know the solution to this?

    Thanks.
     
  2. JohnDS macrumors 65816

    Joined:
    Oct 25, 2015
    #3
    Did you try to unlock it by right-clicking and choosing GetInfo?
    Have you tried holding down the option key while selecting "Empty Trash".

    If that fails, you may have disk directory corruption. Open Disk Utility and choose First Aid.

    If you still can't delete the file try this:

    1. Open Terminal. It's located in /Applications/Utilities.

      Type:
      chflags -R nouchg


      Type one space (not pictured) after nouchg in the line above, so that it ends in "nouchg ". Do not press Return yet.
    2. Double-click the Trash icon in the Dock to reveal the contents of the Trash. If necessary, arrange the Finder window so that a portion of the Terminal window is still visible.
    3. Drag the file from the Trash to the Terminal window.
      Note: This automatically enters the pathname for each file.
    4. Press Return. No special text message will be shown indicating that the command was successful.
    5. Empty the Trash.
    If the Trash does not empty or if you see a message in Terminal that says "usage: chflags [-R [-H | -L | -P]] flags file..." you most likely did not type the text in step 2 as indicated or did not leave a space. Repeat the steps if this happens.
     
  3. Upgrader thread starter macrumors regular

    Upgrader

    Joined:
    Nov 23, 2014
    #4
    Hey both,

    Thanks for those suggestions.

    Tried Batchmod. Didn’t work unfortunately. Says it’s doing it but doesn’t actually affect the file.

    Tried all your suggestions John but to no avail. The file refuses to be moved.

    Any other suggestions? I think I’m gonna sign in as guest user and try the “chflags -R nouchg ” command.
    That empties all trashes for all users whether logged in or not right?

    Thanks.
     
  4. \-V-/ Suspended

    \-V-/

    Joined:
    May 3, 2012
    #5
    Have you tried booting into repair mode and repairing the drive?

    Also ... with BatChmod you can try moving the file to the trash and then using the Force Empty Trash feature of BatChmod in the file menu options.
     
  5. Upgrader thread starter macrumors regular

    Upgrader

    Joined:
    Nov 23, 2014
    #6
    Hey

    Yes, sorry, was meant to mention, booted into the repair partition and ran first aid too.

    I also tried the force empty trash via BatChmod but to no avail.

    Also tried running the chflags -R nouchg command via the guest account but again, no good.

    I also booted into safe mode (held shift whilst booting) but no good.

    It’s sitting there in the trash still locked.

    Screen Shot 2016-02-21 at 9.15.50 pm.PNG Screen Shot 2016-02-21 at 9.15.35 pm.PNG
     

    Attached Files:

  6. \-V-/ Suspended

    \-V-/

    Joined:
    May 3, 2012
  7. Upgrader thread starter macrumors regular

    Upgrader

    Joined:
    Nov 23, 2014
    #8
    Totally the file from hell!!

    Yeah did see that but it didn’t help as this file is in the trash.

    The regular location has the actual sleep image file in there as you’d expect.

    I honestly cannot seem to find a solution to this.

    Hoping a Terminal ninja will pass through.
     
  8. JohnDS macrumors 65816

    Joined:
    Oct 25, 2015
    #9
    From the get info window you posted, the only user with Read and Write permissions is System.

    Try the terminal method in my earlier post, but use

    sudo chflags -R nouchg

    instead of

    chflags -R nouchg
     
  9. \-V-/ Suspended

    \-V-/

    Joined:
    May 3, 2012
    #10
    Can you move it back to the location it's supposed to be in and then try that terminal command? [disk drive]/private/var/vm/sleepimage

    Also this tells you how to remove it permanently after deleting it: http://www.techradar.com/us/how-to/...hogging-sleepimage-file-from-your-mac-1305738


    I've run into files like this before and I ended up having to reformat just to get rid of the friggin' thing. I gave up on solutions after a while. Hopefully John can help you.
     
  10. jbarley macrumors 68030

    jbarley

    Joined:
    Jul 1, 2006
    Location:
    Vancouver Island
    #11
    Maybe try opening a Terminal window and enter the following...

    sudo rm -Rf

    Enter a space after "-Rf" then drag the folder into the Terminal window. Press RETURN and see wha happens.
    --- Post Merged, Feb 21, 2016 ---
    This is good but I'd add the following...
    sudo chflags -R nouchg(space) then drag the file to this terminal window and press return.
     
  11. Upgrader, Feb 21, 2016
    Last edited: Feb 21, 2016

    Upgrader thread starter macrumors regular

    Upgrader

    Joined:
    Nov 23, 2014
    #12
    Thanks John - tried this but Terminal comes back with “permission denied”

    I also tried to change permissions with BatChmod but it refused.
    --- Post Merged, Feb 21, 2016 ---
    If I move it back to the desktop and try to drag it out of the folder I get a copy onto the desktop that I can then change permissions of and delete. The original file refuses to be moved from its folder.

    The original location is now deleted. It was the “previous system” folder that upgrading to El Cap left me with.

    I’ll look at the Techradar link - thanks!
    --- Post Merged, Feb 21, 2016 ---
    Thanks - tried both these options - no dice. Am I actually going to have to reformat to remove this beast?
    --- Post Merged, Feb 21, 2016 ---
    Ah ok - I think I may know what’s happened.

    I use an app called Disk Sensei by Cindori.

    It allows me to prevent the creation of a sleepimage.

    It appears to lock an empty sleepimage file in the default location (private/var/vm) to prevent the creation of a new one.

    I’m guessing that this troublesome file is a leftover file from the previous system.

    I’ll email Cindori and ask him if he knows how to manually unlock this file - maybe some kind of reverse engineering?
    --- Post Merged, Feb 21, 2016 ---
    Wow - sorted it! Oskar at Cindori pointed me to a topic on the Cindori forums: https://www.cindori.org/?p=38255

    It was to do with something called immutable flags.

    The Terminal command that unlocked it was sudo chflags noschg /pathname

    Thanks for the help everyone!!
     
  12. \-V-/ Suspended

    \-V-/

    Joined:
    May 3, 2012
  13. Upgrader thread starter macrumors regular

    Upgrader

    Joined:
    Nov 23, 2014
  14. NoBoMac macrumors 6502a

    Joined:
    Jul 1, 2014
    #15
    Deleting locked files/folders, most times, can resort to command/shell level commands to remove. From a terminal:

    rm -f <filename here minus brackets>
    or for folders
    rm -rf <folder name here minus brackets>

    If item has special characters (eg. anything not alpha-numeric), escape the name with quotes or back-slashes. For example:

    rm -f "my file to delete"
    rm -f my\ file\ to\ delete
     
  15. jbarley macrumors 68030

    jbarley

    Joined:
    Jul 1, 2006
    Location:
    Vancouver Island
    #16
    This very command was mentioned earlier in posts 9&11, surprised it did not work for you then.
    Oh well, glad all is well now.
     

Share This Page