9

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 05 '18 at 05: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 05 '18 at 06: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 05 '18 at 07: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 05 '18 at 07:53
  • I have extra empty flashdrive here. but I don't know what should be the process? – Marvin Acosta Apr 05 '18 at 08:05
  • Okay, do you know 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? – Monomeeth Apr 05 '18 at 08:14
  • Check the system.log for any shutdown causes. If it's a kernel crash, please find the stack trace. – kenorb Apr 10 '18 at 00:52
  • hello @kenorb thank you for the message. but how could I check the system log if I don't even log in on the home screen? is there's a way to check the system log on the terminal view? – Marvin Acosta Apr 10 '18 at 01:07
  • In the single mode, you can run: less /var/log/system.log, or grep crash /var/log/system.log, also try dmesg. See also: Where can I find my crash logs? (~/Library/Logs/DiagnosticReports). – kenorb Apr 10 '18 at 01:22
  • In a single mode, you can also change your password, e.g. sudo passwd myuser, if it doesn't work. – kenorb Apr 10 '18 at 01:23
  • Also try to run fsck -y to fix any errors. – kenorb Apr 10 '18 at 01:25
  • @kenorb ok I will try your method ^^ but How could I know if there's unsual or error on the system log? – Marvin Acosta Apr 10 '18 at 01:39
  • If you grep the system.log file by shutdown, it normally should give you a shutdown cause. If you grep by crash, it may point you to the crash log. – kenorb Apr 10 '18 at 01:43
  • I tried the "less /var/log/system.log" and I don't understand the output. and now I don't even know how to get out on from the terminal? – Marvin Acosta Apr 10 '18 at 02:02

3 Answers3

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!

Monomeeth
  • 64,558
  • thank you. I will try this method. will let you know the result after. – Marvin Acosta Apr 05 '18 at 08: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 09 '18 at 06: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 09 '18 at 09: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 00: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 08:39
  • Good morning @Monomeeth thank you for still responding. regard to this message. yes all of my files are restored in one place only. I actually listed some folders, files, and apps that surely I need to delete it. – Marvin Acosta Apr 11 '18 at 01:35
  • Okay, but when you say all of my files are restored in one place only, where would that be? For example, if you had all this data in a folder called Recovery and that folder was on your Desktop, then what I'm asking for is something along the lines I know I have a folder on my desktop called 'Recovery' that I can delete. – Monomeeth Apr 11 '18 at 01:46
  • ok ^^. on my download and application – Marvin Acosta Apr 11 '18 at 02:51
  • Ok, I've added to my answer. If you run into problems, then follow the steps again and take photos so I can take a look at what's going. – Monomeeth Apr 11 '18 at 03:40
  • what is the meaning of "is a directory" everytime I am deleting the app? – Marvin Acosta Apr 11 '18 at 05:11
  • Many apps are actually packages that contain subfolders and files, so if you're trying to remove one such application then you may get an error along the lines of: cannot remove 'xyz': Is a directory. This is because the rm command does not remove directories by default. In this case you'd be better off using the command this way: rm xyz/* -r (where XYZ is your directory name). When I get a chance I'll update my answer to allow for this scenario. – Monomeeth Apr 11 '18 at 05:19
  • and how do I know if I've deleted successfully? – Marvin Acosta Apr 11 '18 at 05:27
1

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.
kenorb
  • 12,695
0

Just boot into safe mode by pressing the SHIFT key and Power ON button. As soon as you are logged into safe mode just delete files you dont need anymore and boot into your profile.