7

When I restart my computer I usually type my password to log me in. However, when I try to do this now it shows me the following message:

"Your computer restarted because of a problem"

So I restart my laptop and enter my password again but I still get the same error message. This happens repeatedly if I reboot, so I can't login anymore.

After researching this problem I found out that my computer is suffering a kernel panic. I tried the following 3 possible solutions I found to fix this problem:

  1. I used the cmd + option + P + R shortcut during startup to reset the NVRAM.
  2. I booted into Safe Mode by holding the shift key down while rebooting.
  3. I booted into Recovery with the cmd + R keys to get me into OS X Utilities to run First Aid on the Startup Disk.

None of the above resolved the issue.

Can anyone help me fix this problem?

  • Welcome to Ask Different! :) I've edited your question to make it easier to read and get down to the core issue you're having. Please let me know if there's anything you feel needs to be added back. However, it would be good to know what version of macOS you're running and whether you have a backup of your data (i.e. a Time Machine backup or something similar)? – Monomeeth Apr 5 '18 at 5:49
  • Thank you, my macOS is High Sierra. and I don't have any backup. can you help me to solve this issue? – Marvin Acosta Apr 5 '18 at 6:32
  • because I accidentally filled up my memory. I am wondering to delete some of files and apps, but how could I do if I can't login? is there a solution? thank you – Marvin Acosta Apr 5 '18 at 7:15
  • Do you have access to another Mac? Or, do you have another bootable drive (e.g. an external USB hard drive) you can boot from? – Monomeeth Apr 5 '18 at 7:53
  • I have extra empty flashdrive here. but I don't know what should be the process? – Marvin Acosta Apr 5 '18 at 8:05
6

This answer assumes:

  • your internal drive is full and this is why you can't log in
  • you do not have access to another Mac
  • you do not have another drive you can boot from.

The following steps will allow you to delete what we call a sleepimage file. These are usually quite large and should free up enough space for you to be able to log back in.

Note that while this can be done in much fewer steps (steps 4 to 10 could be removed and step 11 could contain a much longer file path), I've deliberately split this up to reduce the risk of making a typo and to make it easier to understand.

Deleting your sleepimage file via Single User Mode

  1. Boot into Single User Mode by restarting your Mac and pressing and holding + S as soon as you hear the startup chime
  2. Keep these keys down until you see a black screen with white text
  3. Mount your drive by typing in exactly: /sbin/mount -uw / (note there is a space after the 't' and again after the 'w') and then pressing the enter key
  4. Now list what's there by typing in ls and pressing the enter key
  5. You should see a list of files and directories
  6. Now type in cd private (note there is a space after 'cd') and press the enter key
  7. Now type in cd var (note there is a space after 'cd') and press the enter key
  8. Now type in cd vm (note there is a space after 'cd') and press the enter key
  9. Now type in ls and press the enter key
  10. Hopefully you will see that you have a sleepimage file located here (this is what we're going to remove)
  11. Now type in rm sleepimage (note there is a space after 'rm') and press the enter key
  12. Now reboot your Mac by typing in reboot and then pressing the enter key

Hopefully this will free enough space for you to be able to login. If so, then take the time to remove any other data you don't need. If not, message me and we'll go from there.

NOTE: If your Mac doesn't reboot after Step 12, feel free to switch it off with the power button.

IMPORTANT: - You really should have a backup regime in place! Buy yourself an external USB hard drive and start using Time Machine for backups!


Deleting downloads via Single User Mode

Since you know you have items in your Downloads you can delete, these steps will help you do that from Single User Mode.

  1. Follow Steps 1 to 5 from Deleting your sleepimage file via Single User Mode above
  2. Now type in cd users (note there is a space after 'cd') and press the enter key
  3. Now type in ls and press the enter key
  4. You should see a list of users for your Mac.
  5. Now, if we assume your username is Marvin, type in cd marvin (note there is a space after 'cd'). Obviously, if your username is something else, then use that instead of marvin!
  6. Press the enter key
  7. Now type in ls and press the enter key
  8. You should see a number of folders listed. Type in cd downloads (note there is a space after 'cd') and press the enter key
  9. Now type in ls and press the enter key
  10. You should see a list of files and folders. Now use the rm command to remove items you don't want.
  11. For example, if you have an item called Installer.dmg, you would remove it by typing in rm Installer.dmg (note there is a space after 'rm') and pressing the enter key
  12. Once you've removed enough items to free up space, reboot your Mac by typing in reboot and then pressing the enter key

Note: If an item has a space in its name (e.g. Install XYZ.dmg), then the command you would need to enter is rm Install\ XYZ.app. That is, I have used a backslash \ before the space!

Deleting Applications via Single User Mode

If you want to remove applications, then follow these steps:

  1. Follow Steps 1 to 5 from Deleting your sleepimage file via Single User Mode above
  2. Now type in cd applications (note there is a space after 'cd') and press the enter key
  3. Now type in ls and press the enter key
  4. You should see a list of applications and folders. Now use the rm command to remove items you don't want.
  5. For example, if you have an item called XYZ.app, you would remove it by typing in rm XYZ.app (note there is a space after 'rm') and pressing the enter key
  6. Once you've removed enough items to free up space, reboot your Mac by typing in reboot and then pressing the enter key

Note: If an item has a space in its name (e.g. Microsoft Word.app), then the command you would need to enter is rm Microsoft\ Word.app. That is, I have used a backslash \ before the space!

  • thank you. I will try this method. will let you know the result after. – Marvin Acosta Apr 5 '18 at 8:56
  • Hello @Monomeeth good afternoon. I've followed your method but unfortunately there is no sleepimage "No such file or directory". please see the Picture on my updated post. can you teach me the 2nd options? – Marvin Acosta Apr 9 '18 at 6:28
  • Hmm, interesting. Can you follow my steps again, but this time I want you to skip Steps 6 and 7 and see whether you have any joy that way. – Monomeeth Apr 9 '18 at 9:16
  • Good morning @Monomeeth I've followed the method now but this time when I typed the /sbin/mount/ -uw / its says "Not a directory". then I continue the method and skipping the #6 and 7 but still same output "No such file or directory". please see the updated picture above. ^^ – Marvin Acosta Apr 10 '18 at 0:43
  • Okay, what I was trying to do with my steps was get you to delete the sleepimage file as it's usually large enough to make a difference. However, we don't have to delete that, we can delete something else. One of my earlier comments asked you if you knew of somewhere on your Mac's hard drive where you've got a large file (or some files) we can delete to make room? For example, do you know if you have some large downloads in your Downloads folder, or some videos in your Videos folder, or stuff on your Desktop you're happy to delete? If you can think of something I can slightly amend my steps. – Monomeeth Apr 10 '18 at 8:39
0

If verbose mode won't show anything useful (-V after restart), run your macOS into single-user mode (-S after restart).

In this mode, try the following commands (as root):

  • fsck -f - to run filesystem consistency check and interactive repair.
  • dmesg - to display the system messages.
  • egrep "crash|shutdown" /var/log/system.log - to check for crash and shutdown logs.

    Note: See list of shutdown causes.

  • find /Library/Logs ~/Library/Logs | grep crash$ to find the crash files.

  • passwd myuser - to change the user password in case it doesn't work.
  • mount - to list mounted devices.
  • mount -uw / - to mount the root partition with write access.
  • df -h - to check for the free space which may cause of the kernel panic.

    Note: In case of out-of-space issue, look for large files which can be removed.
    For example, go to some folder like /Users and run du -ah . | sort -rh | head -40.

  • diskutil list - to list the disks.

  • kextstat | grep -v com.apple - to list non-Apple kernel extensions (consider disabling).
  • launchctl list | grep -v com.apple - to list non-Apple services (consider disabling).
  • nvram boot-args - to check custom boot arguments, remove if any.
  • reboot - to exit this mode and start up normally.

If your Mac has recovery partition, after restart you may try to boot from it by holding -R.

You may also run Apple Hardware Test on your Mac (hold the D key during on reboot).


If above won't help, you may also:

  • Recover your macOS using a Time Machine to the working point.
  • Reinstall macOS from the recovery partition, netboot or a boot drive (download or purchase).
  • Use a professional recovery software such as DiskWarrior.
  • Book an appointment at Genius Bar and ask them to run the full hardware test using their macOS NetBoot Triage Image.
  • 1
    thank you for this. actually I know what the problem is. I need to delete some of my files and apps through its Terminal to give me more space in my startup disc to get rid the Kernel Panic and be able to login again. Question how could I delete specific files and apps using Terminal? – Marvin Acosta Apr 10 '18 at 2:44
  • You can remove anything in /cores and /var/vm dirs. For anything else, see: Finding all large files in the root filesystem. – kenorb Apr 10 '18 at 10:10

You must log in to answer this question.

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