Apr 18, 2014

How to remotely run FSCK on a mac.

Have you ever had a client that had disk problems on his mac, and the only way to fix them would be to boot into single user mode, and do an /sbin/fsck thingie? Well, you really can't do that if you're not there in person, can you .... or can you?

Turns out you can!


But the article fails to tell you how you set the whole thing back after you're done, thus avoiding the user having to type in "exit" at a DOS looking prompt every time she/he wants to use his computer.

So here's my take on the manual. To enable single user, and make the Mac run fsck at boot; do the folllowing:

  1. Open up the Terminal / Utilities folder.
  2. type: cd .. and hit return a couple of times
  3. type: sudo su
  4. then type: sudo su - 
  5. then type: nvram boot-args="s" (this sets the boot type to single user boot, you can revert this by typing: nvram boot-args="")
  6. then type: sudo nano /etc/bashrc
  7. then copy paste this block of text at the end of the file

singleuser=`sysctl -n kern.singleuser`

if [[ $singleuser -eq 1 ]]; thennvram boot-args=""/sbin/fsck -fyrebootelseecho Not in single user modefi

  1.  You wanna save the changes by hitting CTLR and O to do a write out. Hit enter.
  2. And then restart.

If you wanna revert the process, then remote log in after the Mac has restarted automatically, do all the steps again, but remove the block of text you just added, and change the start up mode from single user mode, to normal by removing the S as described in step 5.