Use single-user-mode to access files from a mac without login

On May 23, 2019. I accidentally drop my MacBook, which looses the connection between the motherboard and hard drive. After I reconnect the SATA cable and restart my computer, I found that my laptop stuck after I enter the login password.

##First try:
In recovery mode, reset the password.

See instruction at:

https://www.macworld.co.uk/how-to/mac/forgotten-mac-password-3594395/

or https://support.apple.com/en-hk/HT202860

or https://jingyan.baidu.com/article/6f2f55a163030bb5b83e6c71.html

However, I failed.


##Second try:
I first try to set up a new user by using single user mode.

See instruction here: https://zhidao.baidu.com/question/528962469.html

However, after I set up the new user, I still got stuck when I try to login into the system.


##My solution
Since I have a Time Machine backup in January, I can recover my computer using Time Machine. However, I still need to backup some important information that is not in the Time machine. After doing some research, I successfully copy the important file from MacBook using single user mode.

###Copy file without login:

If your mac running a macos higher than El Capitan, you should first remove “System Integrity Protection” before entering the single user mode.

  1. Reboot your mac and press command + R, go to the recovery mode.
    IMG_2017.jpg

  2. Click on the "Utilities" menu, and then click on "Terminal" to open terminal.
    IMG_2018.jpg

  3. In the terminal type csrutil disable and enter.
    IMG_2021.jpg


If your mac running a macos lower than El Capitain, ignore the step above.

  1. reboot again, but this time press command + S to enter single user mode.

  2. Follow the instruction, type /sbin/fsck -fy and press enter (if this command does not show “The volume xxx appears to be OK”, you should run this command multiple time until it shows this message)
    IMG_2040.jpg

  3. type mount -uw / and press enter
    IMG_2041.jpg

  4. type mkdir /Volumes/usb to create a directory for external storage device (using later).
    IMG_2050.jpg

  5. type ls /dev/disk* to show current disks.

  6. plug in an external storage device (USB or other things), type ls /dev/disk* to find which is the external storage device (often the last one in the list).
    IMG_2042.jpg
    IMG_2045.jpg

  7. type fstyp /dev/disk1s3 (depends on which disk you are using) to find the system of the disk, (Interest things is that although my drive is exfat, the fstyp shows msdos).
    IMG_2048.jpg

  8. according to 7, type /sbin/mount_exfat /dev/disk1s3 /Volumes/usb to load storage device. Depending on your file system, you may choose a different command. For example, if your device is using msdos file system, you should type /sbin/mount_msdos instead of /sbin/mount_exfat. You can see all the supported file system by entering ls /sbin/mount_*
    IMG_2052.jpg

  9. if the external storage is loaded success, you can now access your external drive. Type ls /Volumes/usb to find out.
    IMG_2053.jpg

  10. Copy file to your device by using command cp. Eg: cp /User/xxx/Desktop/1.jpg /Volumes/usb
    IMG_2055.jpg