dotfiles icon indicating copy to clipboard operation
dotfiles copied to clipboard

Can't delete the sleepimage on high sierra

Open hdoria opened this issue 7 years ago • 17 comments

sudo rm /private/var/vm/sleepimage override rw------T root/wheel for /private/var/vm/sleepimage? yes rm: /private/var/vm/sleepimage: Operation not permitted

The same command works for macOS Sierra

hdoria avatar Oct 21 '17 14:10 hdoria

I have the same problem here. Anyone knows how to fix it?

jesusmonterob avatar Nov 17 '17 09:11 jesusmonterob

Hi, I am also having this problem, for example:

sudo rm:

Justin:vm justinbagley$ sudo rm -rf /var/vm/sleepimage rm: /var/vm/sleepimage: Operation not permitted

OR

rm:

Justin:~ justinbagley$ cd /var/vm/ Justin:vm justinbagley$ ls sleepimage swapfile0 Justin:vm justinbagley$ rm ./sleepimage override rw------T root/wheel for ./sleepimage? y rm: ./sleepimage: Operation not permitted

Permissions on sleepimage are read and write:

Justin:~ justinbagley$ ls -lod sleepimage -rw------T 1 root 1073741824 Nov 21 08:02 sleepimage

Could someone please explain how to fix this issue and allow sudo access to not just read and write in var, but also remove files? I worry this may affect other files that I will need to sudo rm. ~ J

justincbagley avatar Nov 22 '17 15:11 justincbagley

Anyone get a solution on this one? I'm getting the same in Sierra 10.12.6 also.

DeadWriter avatar Nov 24 '17 21:11 DeadWriter

I'm guessing that probably in High Sierra the sleepimage was put under SIP control. If that's the case, there's nothing you can do unless you disable SIP.

chdiza avatar Nov 27 '17 21:11 chdiza

Excuse my ignorance, but what is SIP?

justincbagley avatar Nov 27 '17 21:11 justincbagley

System Integrity Protection.

chdiza avatar Nov 27 '17 22:11 chdiza

  1. reboot into Recovery mode
  2. open terminal
  3. type: csrutil disable
  4. reboot
  5. try to remove the image again with SIP disabled

Read: https://www.imore.com/el-capitan-system-integrity-protection-helps-keep-malware-away

markstachowski avatar Nov 28 '17 12:11 markstachowski

@chdiza is right. In High Sierra the sleepimage was put under SIP control. Just follow @markstachowski instructions.

hdoria avatar Nov 28 '17 12:11 hdoria

I was able to select "EJECT" it (just as dmg or drive). Hope this helps someone!

sandeepkalra avatar Dec 12 '17 05:12 sandeepkalra

Thanks worked like a champ 😊

mikedvzo avatar Dec 17 '17 23:12 mikedvzo

Only temporarily and now it is back again. Looks like there is no way to stop it that I can tell.

mikedvzo avatar Jan 07 '18 01:01 mikedvzo

You must first disable hibernation by executing:

sudo pmset -a hibernatemode 0

starast avatar Feb 28 '18 09:02 starast

The problem I ran into on a MacBook Pro is every time you reboot with 10.13 the system resets the Hibernation mode to 3. In addition the swapfile is also in the VM mount and if you force eject and the swapfile is being utilized the system sill probably crash.

mikedvzo avatar Feb 28 '18 15:02 mikedvzo

on a MacBook Pro is every time you reboot with 10.13 the system resets the Hibernation mode to 3.

It doesn't do that on mine. It does recreate a sleepimage upon startup despite being in hibernate mode 0. I reported this to Apple and they haven't done anything about it.

chdiza avatar Feb 28 '18 15:02 chdiza

I'm late to the party... It's probably the SIP. Almost each time the shell returns '${command}: ${path}: Operation not permitted', the SIP prevents writing. See more here, there, here and there, and here also.

ktgvv avatar Mar 04 '18 20:03 ktgvv

It seems like in normal circumstances the sleepimage is deleted on reboot. Or at least I couldn't find it back in /Volumes/Macintosh HD/private/var/vm during a recovery mode boot (hold CMD+R during bootup). The sleepimage was there while booted into normal macOS mode.

It might be wise to do a filesystem scan with Disk Utility (or just /sbin/fsck -fy from single user mode, hold CMD+S during bootup). And to do the usual SMC + PRAM reset dance.

HenkPoley avatar Aug 15 '18 07:08 HenkPoley

I think it worked for me. I did sudo pmset -a hibernatemode 0 and now it says the file doesn’t exist.

chopshopstore avatar Oct 09 '20 16:10 chopshopstore