Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Attempting to retrieve files off hard drive via terminal

I have a 2011 Macbook Pro running Mavericks. Recently it froze and upon restarting I was met with the dreaded circle with a line through it. Here is what I've tried:

The Macintosh HD is greyed out or ghosted so there is no booting from there. It appears the partition is missing. Unable in recovery mode to reinstall the OS via internet recovery nor (yes, I know…learned the hard way to not put off backing up) backup. I have taken it to Apple Genius bar and the hard drive is fine.I'm trying to recover any photos, documents, etc off the drive and Apple attempted to retrieve via their OS as well as Target Disk Mode which also was unsuccessful. Apple's advice was to wipe clean and reinstall the OS losing everything or trying an outside vendor that may be able to retrieve files. My understanding that is rather costly hence my desperate attempt at doing this myself. I thought I could run a program such as DiskDrill etc from external drive but don't know how to access/run programs off the external drive via terminal?

I'm attempting through terminal to retrieve manually any folders possible. I am not code literate yet can follow instructions well. I've been relying on code I've picked up on other Apple forum threads. I am unable to even find the main folders expected i.e. Documents, Pictures, Applications etc. My understanding is upon typing in cd / and ls that I should see all the folders which I'm not. I've attached a picture of the screen as I have no way of copying and pasting the results.

ANY suggestions or exact coding would be appreciated. I'm not even sure at this point this is feasible. Thanks in advance. User uploaded file

MacBook Pro (15-inch Early 2011), OS X Mavericks (10.9)

Posted on Mar 30, 2016 12:03 PM

Reply
17 replies

Mar 30, 2016 4:47 PM in response to hilaryfromwestlake village

Try using 'ditto' - man ditto

/usr/bin/ditto -X --rsrc −−extattr −qtn −−acl −−preserveHFSCompression  /from/directory  /destination/directory

I think this will copy the entire directory tree from whatever you specify as the from directory to the destination directory

You should do some simple experiments on small directories to make sure it is working as expected, before doing huge transfers.

Mar 31, 2016 2:21 PM in response to hilaryfromwestlake village

my options example was wrong. There should be 2 dashes before --qtn


Also there is no such directory as /from nor /destination. You have to provide REAL file path information. The / separates directory names.


Also if there are spaces in the directory names, you MUST quote them.


You can either put the path in single quotes '...' or double quotes "..." or you can put a backslash before each space this\ is\ a\ backslash\ quoted\ string


'TOSHIBA MK7559GSXF Media'

"TOSHIBA MK7559GSXF Media"

TOSHIBA\ MK7559GSXF\ Media


And


'My Backup'

"My Backup"

My\ Backup


And you need to figure out what the directories are for /from and /destination. /from/ and /destination/ are not magical. You need to put something real as the path to the starting directory and place you are transferring the data.


If the starting/from directory is in the current working directory, then you do not need to put anything in front of the first directory.

Apr 1, 2016 4:44 PM in response to BobHarris

I've been attempting to determine the proper directory with little luck. I thought using ls would give me the directories. All I get is . forward Library. I've also tried using mount and dr -h with little luck as I'm not really sure what I'm looking at. I wish I was more proficient in this. Unless you can derive a directory from the attached photos I will probably have to just wipe the drive clean and start over as I'm out out ideas. Any directories from these photos? lol User uploaded fileUser uploaded fileUser uploaded fileThanks for all your help.

Apr 1, 2016 5:24 PM in response to hilaryfromwestlake village

How are you booted? From Recovery Mode (Boot holding Command-R), or Single User Mode (Boot holding Command-S)


Looking at an earlier ls of /, I do not see 'Users' directory which is where user accounts are stored. So I'm wondering if this is Recovery Mode.


You might try

/usr/sbin/diskutil list

which should tell you what devices are out there and their volume names.


the 'mount' command tells you want is mounted, not what is unmounted.


Did your disk have FileVault whole disk encryption? If so, you may need to use get it mounted first. When I'm had to mount my FileVault encrypted boot volume from Recovery Mode, I have use Menu -> Utilities -> Disk Utility. Selected my encrypted boot disk, then gone to the Disk Utility -> Edit -> Unlock, which prompted me for my password. Then my FileVault encrypted boot disk was mounted, and I had full access to it.


And you should be able to navigate to your home directory, if you can get any part of your boot disk mounted. If you are in Single User mode, then your home directory should be /Users/<yourUnixUserNameHere>. If you are in Recovery Mode, then if you get the Boot device mounted, you would find your home folder in /Volumes/<nameOfYourBootVolume>/Users/<yourUnixNameHere>

Apr 1, 2016 6:38 PM in response to BobHarris

Here is a technique I worked out with mac os 10.4. You need to put in a formatted flash drive before starting the machine.



You may try to recover your data by booting up an installation cd/dvd and using the terminal.
You could try getting into the Unix command line interface and copy some files or directories. You can copy files on the Unix command line interface if you placed the flash drive the USB port before powering on your machine.
0) you best have the flash drive formatted for the Mac. See disk utility. It's on the pull down.
1) You can copy files on the Unix command line interface if you placed the flash drive in a USB port before powering on your machine.
2) Boot up your installation CD or DVD. To do this, place to the CD or DVD its drive. [ or boot the recovery partition via command r
3) Power off the the machine. Hold down the c key then power on your machine.
4) After you specify the language you will come to the installation panel.
5) Do not install.
6) Go to the top of the screen and click on the tools menu item.
7) Click on Terminal to use the command line interface.
Boot up your installation CD or DVD. To do this, place to the CD or DVD its drive. Power off the the machine. Hold down the c key then power on your machine. After you specify the language you will come to the installation panel. Do not install. Go to the top of the screen and click on the tools menu item. Click on Terminal to use the command line interface.
You should verify that the files have been copied correctly by trying them in another Mac before it the deleting the original.
Here is an overview of the commands. Lets assume that the problem account has a short user name of mac.
#Copy directory "/Applications/Applescript files" to
# directory "/Volumes/Spotless/Applescript files".
# "Spotless" is my flash drive.
ditto -X -rsrc /Applications/Applescript\ files /Volumes/Spotless/Applescript\ files
#cd is change directory
cd /Volumes/COPYIT/answers/
# pwd is print working directory
pwd
#the ls command is for list
# l is long
# a to show hidden files. not shown in this example.
# F is type of file where / is directory
sh-2.05b# # Please note ls is the list command. l is a lower case L
sh-2.05b# ls -lF
Here is what these commands mean:
cd is change directory
pwd is a print working directory
ls is list
sudo is Super user do
# The sudo command will ask for your administration password. No characters will appear when typing your password. Press return when done typing.
cp is copy
copy a file example:
sh-2.05b#
sh-2.05b# cd /Volumes/Macintosh-HD/Users/mac/desktop
sh-2.05b# pwd
/Volumes/Macintosh-HD/Users/mac/desktop
sh-2.05b# cp -i answers.txt /Volumes/SpotMore
Will copy the file answers.txt in the directory SpotMore.

  1. Some files have a space in the name. You need to escape. see example:
    mac $ ls -l ~/"see it"
    -rw-r--r-- 1 mac staff 3171 Oct 26 23:38 /Users/mac/see it
    mac $
    mac $ cd /Users/mac/Desktop/ttt\ html\ copy/
  2. Do you know about tabing? Type in a few letters of a name then press the tab key. The computer will type out the rest of the name if it is unique.
  3. The up arrow key will retrive the previous command. You the left arror and right arror keys to move around. Use the delete key to delete a character to the left.



*More examples and moving around*

sh-2.05b# pwd
/
sh-2.05b# ls /Volumes
.Trashes Classic Macintosh-HD
._.Trashes Mac OS X Install DVD SpotMore
sh-2.05b#
sh-2.05b# df -h
Filesystem Size Used Avail Capacity Mounted on
/dev/disk4s3 2.6G 2.5G 89M 97% /
devfs 121K 121K 0B 100% /dev
fdesc 1.0K 1.0K 0B 100% /dev
<volfs> 512K 512K 0B 100% /.vol
/dev/disk5 467K 9.0K 435K 2% /Volumes
/dev/disk6 95K 64K 27K 70% /private/var/tmp
/dev/disk7 95K 14K 77K 15% /private/var/run
/dev/disk3s1 3.7G 1.3G 2.5G 34% /Volumes/SpotMore
/dev/disk0s10 1.1G 1.1G 3.4M 100% /Volumes/Classic
/dev/disk0s12 70G 45G 25G 65% /Volumes/Macintosh-HD
sh-2.05b#
sh-2.05b# cd /Volumes/SpotMore/
sh-2.05b# pwd
/Volumes/SpotMore
sh-2.05b# # Please note ls is the list command. l is a lower case L
sh-2.05b# ls -l
total 880
-rw-r--r-- 1 unknown unknown 6148 Sep 10 2010 .DS_Store
drw------- 4 unknown unknown 136 Aug 25 2010 .Spotlight-V100
drwxrwxrwt 3 unknown unknown 102 Sep 3 2010 .TemporaryItems
d-wx-wx-wt 3 unknown unknown 102 Sep 10 2010 .Trashes
drwx------ 3 unknown unknown 102 Sep 3 2010 Desktop
-rw-r--r-- 1 unknown unknown 18944 Aug 27 2010 Desktop DB
-rw-r--r-- 1 unknown unknown 2 Jul 29 2010 Desktop DF
-rwxrwxrwx 1 unknown unknown 26281 Oct 27 2009 Warranty Information.PDF
drwxr-xr-x 13 unknown unknown 442 Aug 4 2010 backup
drwxr-xr-x 13 unknown unknown 442 Aug 4 2010 backupPrior
drwxr-xr-x 7 unknown unknown 238 Aug 27 2010 cons
drwxr-xr-x 65 unknown unknown 2210 Sep 4 2010 iMac-back
... clipped ...
sh-2.05b#
sh-2.05b# cd /Volumes/Macintosh-HD/Users/mac/desktop
sh-2.05b# pwd
/Volumes/Macintosh-HD/Users/mac/desktop
sh-2.05b# # Please note ls is the list command. l is a lower case L
sh-2.05b# ls
Z2300 iMac
.DS_Store move
.FBCIndex new Belward
.FBCLockFolder primary-comments-new copy.doc
Consolidate-rc primary-comments-new.doc
Downloads psc 1200
... clipped ...

sh-2.05b# ditto -X -rsrc iMac /Volumes/SpotMore/iMac-back
sh-2.05b#
sh-2.05b# # Please note ls is the list command. l is a lower case L
sh-2.05b# ls -h /Volumes/SpotMore/iMac-back/
total 2800
-rw-r--r-- 1 unknown unknown 24K Sep 12 2010 .DS_Store
-rw-r--r-- 1 unknown unknown 2K Apr 18 2010 Differentiate Between Models .html
... clipped ...

sh-2.05b# pwd
/Volumes/Macintosh-HD/Users/mac/desktop
sh-2.05b# ls
Z2300 iMac
.DS_Store move
.FBCIndex new Belward
.FBCLockFolder primary-comments-new copy.doc
... clipped ...

sh-2.05b#

Apr 2, 2016 12:56 PM in response to BobHarris

I am working in Recovery Mode. Neither Apple nor myself could get single use mode to boot. To answer your question: Did your disk have FileVault whole disk encryption? If so, you may need to use get it mounted first. went to File as Edit did not have the options you mentioned (see photos) I have no option of "Unlock" only to change password and turn off encryption which I tried and nothing happened. My understanding from all this is that it needs to be mounted for me to access it. I followed your instructions as to /usr/sbin/diskutil list but without it mounted I'm not sure I can use the info (see photo). I also tried in disk utilities to repair with no luck and also used diskutil verifyVolume "Macintosh HD"and diskutil repairVolume "Macintosh HD"and the same I was told it could not be repaired. I think I've tried everything at my 'education' level of this to obtain my files. I appreciate all of your help and patience with me. I think I'm going to just have to start over with a clean drive unfortunately. Kills me to give up lol 😐User uploaded fileUser uploaded fileUser uploaded fileUser uploaded file

Apr 2, 2016 6:33 PM in response to hilaryfromwestlake village

User uploaded file

It would seem disk0s2 is your internal disk that may or may not have all your data on it.


I think you might need to use Disk Utility to mount "Macintosh HD"

User uploaded file


Then you should see /Volumes/Macintosh HD in your system


Then this command "Might" work. I do not know if it will, just that it sounds good 🙂


/usr/bin/ditto -X --rsrc −−extattr −−qtn −−acl −−preserveHFSCompression    /Volumes/Macintosh\ HD    /Volumes/My\ Backup

Apr 2, 2016 7:02 PM in response to BobHarris

When I clicked on "Mount Macintosh HD" nothing appeared to happen and I ran the "verify" again on it after to see if anything had changed and it hadn't. It's still not showing as Mounted in Disk Utility at the bottom. Not sure if I should see anything different after clicking the Mount command???? but I will try it again and then run your last suggested code 🙂 Fingers crossed lol

Attempting to retrieve files off hard drive via terminal

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.