Stupidly Deleted my Sparseimage File


Hello all,

I stupidly put a sparseimage file in the trash and then shut down my machine. I can't log in with that user name, so I've been unable to access the trash to undelete it. Any ideas on how to fix this boneheaded mistake?




Registered Bot
Welcome to!

Why can't you log in? You can reset your password by booting from your system CD. I believe it is one of the options in the menus. Then all you would need to do would be to restart with as that user and drag it out of the trash.

That file is saved in ".Trashes" in your user folder. You can use Terminal to navigate to that folder and recover the file. If you need help doing that, let us know.



Registered Bot
If you've forgotton your password for the user account, put your system CD in the drive and restart. Boot by holding down C. Then, reset your password. I believe it is one of the options in the menus.

If that won't solve your problem, let us know.



Staff member
If that sparseimage file is your FileVault disk image, that's your answer. It contains your _whole_ home folder, so there currently simply isn't anything to login to. I'd try to cleanly install Mac OS X on a separate device (FireWire harddrive), login there and try to move the image to its rightful place. You could also backup that image, erase the internal harddrive, reinstall OS X and get things back from the backup-image by hand. Mounting it would probably take your normal account password.

All that said: FileVault is a problem, not a solution. Try to avoid it if possible.


The Late: SuperMacMod
You could also create a new Admin account and you should be able to login and take the img out of the trash.

How to create a permanent or temporary admin account onto an Apple computer from single user mode.
Boot the computer holding ‘Command + S’ to enter single user mode.
You need to run these two commands to finish the initial boot process:
/sbin/fsck –fy
This command will force a disk check. Necessary just to be sure there are no errors. Wait a few minutes while it completes. (This step is optional so if you are in a hurry you can skip it) If an error is found run it again until they are all fixed.
/sbin/mount –uw /
This command mounts your hard drive, and must be performed.
Once in single user mode the first thing we need to do is start the system daemons. Run this command:
sh /etc/rc
This is the normal startup script, it’ll do the necessary work of getting the system (mostly) up and running, but not exit single-user mode or start the GUI. After the startup script has executed press enter to get a new prompt.
Now that we have the system loaded, we can create an administrator account using niload. To do this you need to run a command to populate the NetInfo database with the appropriate information for a user account. To do this we use the niload command to load the information directly into Netinfo. It uses the format of a standard passwd file, which is a series of fields separated by colons.
Here is the standard passwd format and what the information in the ten separate field’s means:
john::530:530::0:0:John Doe:/Users/john:/bin/bash
These fields correspond to the following template:
Field 1: The user’s short name in this case, john.
Field 2: The user’s password; we’ll set this later with another command.
Field 3: The user ID number.
Field 4: The group ID number. For Panther, this is the same as the user ID number.
Field 5: A comment field; you don’t need to enter anything here.
Field 6: The user’s class; not used by NetInfo.
Field 7: The user’s password change time; not used by NetInfo.
Field 8: The user’s full name.
Field 9: The user’s home directory path.
Field 10: The user’s default shell.
If the following command you need to use a uid that is not in use. Run this command to find out which user IDs are used: nireport . /users name uid, and choose an ID above 500.
Now let’s create that user. (this command must be all on one line):
echo ‘john::530:530::0:0:John Doe:/Users/john:/bin/bash’
| niload -v passwd /

‘1 items read from input
Netinfo /users contains 22 items
Processing input item:
_writers_passwd: john
change: 0
expire: 0
gid: 530
home: /Users/john
name: test3
realname: John Doe
shell: /bin/bash
uid: 530

writing new directory /users/john’
After you have created the new user, you need to set the users password. Run this command and enter the password twice when prompted:
passwd john
Changing password for john.
New password:
Retype new password:
Finally, you need to create a group for the user; Tiger uses individual groups for each user, which have the same GID as the user’s UID:
echo ‘john:*:530:john’ | niload -v group /

This command creates the group named john, gives it the GID of 530, and adds the user john to the group, all in one step.

Finally, let’s make this user a member of the admin group so they have administrative access. Run this command to add the user to the admin group:
niutil -appendprop / /groups/admin users john
Your new user is an administrator and has all administrative rights.


Hi I tried your recommendation for creating another user account via single user mode, but am running into trouble. After rebooting the system in single user mode and following the your instructions (which are also on the screen before the prompt), sh /etc/rc; all that happens at this point is a blue screen. Any ideas?


Thanks for the help, all. I actually fixed the problem on my own (necessity being the mother of my new found competence) by creating a root account and then navigating to my deleted sparsedisk image. I couldn't restore my old user information, so I had to mount the image and move everything manually to a new user account. This got a bit hairy, as my old file was quite large and I didn't really have enough room to entirely duplicate it. Suffice to say, things are back to normal, but my collection of movies and music has suffered.


Registered Bot
One idea for you as a precaution for next time something bad happens is invest in an external hard drive. Preferrably a dual-format external, one that can use USB 2.0 or Firewire. Firewire is a bit faster, but USB 2 is more universal.

I got a 250 Gig drive + enclosure for about $100. There are smaller capacities available at lower prices. In fact, by now, the 250 Gigs are likely quite a bit less. You can also use your external drive with Time Machine, the backup feature in OS X 10.5 (Leopard) that is due out in October.



I did the same thing as dmggreenberg. So my sparse image file is in the trash but I did not empty it, and now I can't log in under my user name. When I try to boot from the disk it wants to install the OSX again. The problem is I only had 3 gb of free space and not enough for the entire OSX and it wouldn't let me install to an external hard drive. Is there any way to just get the system running so I can pull the sparse image out of the trash?


U.S.D.A. Prime
When you boot from the OS X Install CD/DVD and it asks you to select a language, instead select "Terminal" from the "Utilities" menu. You can then use terminal commands (mv, cp, etc.) to copy your sparseimage back to its proper location.


I have no idea how to use the terminal commands to remove somthing from the trash. Can you explain, or do you know somewhere to point me where I can learn? Thank you.


U.S.D.A. Prime
I don't know exactly where the sparseimage is supposed to go, but assuming it's supposed to be inside your home folder, the command would go something like this:
sudo mv /Users/yourusername/.Trash/yourusername.sparseimage /Users/yourusername/
...where "yourusername" is your short username.


What do you mean by "short" username?

I tried doing that and it came back saying:

mv: rename /Users/username/.Trash/username.sparseimage to /Users/username/: No such file or directory


In Geostationary Orbit
You deleted it so without data recovery software that MIGHT be able to get that file,you will have to restart the Time Machine process. Time machine uses those sparse image files for it's backup on network drives.


U.S.D.A. Prime
The sparseimage file in question is for FileVault, not Time Machine. Both use sparseimage files.

"Short" username is the name you use to log in. For example, if your name was "Joe Blow", then your short username would probably be either "jblow" or "joe."

The reason Mac OS X says that it can't find that directory is because you failed to replace all occurrences of "yourusername" in the string I quoted with your short username. So, for "Joe Blow" with a short username of "jblow" then command would be:

mv /Users/jblow/.Trash/jblow.sparseimage /Users/jblow/
The exact name of the sparseimage may vary, so to find out what it's really named, change directory to the Trash then list all the files in there like so:
cd /Users/jblow/.Trash
ls -la
...then look for a file called ".sparseimage" something or another. Of course, "jblow" in those commands would be replaced by your short username. If the sparseimage file is not named what I quoted above (yourshortusername.sparseimage), just replace the name of the file in my code to whatever the sparseimage is really named.


Hey thanks for all your help, but it keeps on saying "no such file or directory"

I put my user name in all the places, but I'm not sure I am using right short name and I'm not sure what it could be since i've tried every name I could think of. I think i'm just screwed here.

Do you know what would happen if I just installed the OSX again with the settings of: Archive and Install, and Preserve Users and Network Settings? Would I be able to recover my data, like pictures and stuff from before?


U.S.D.A. Prime
Since you basically have no users and network settings (they're in the sparseimage file in the Trash), then it would be akin to doing an "Erase and Install" procedure.

To find out your short username, do this:

cd /Users
ls -la
Look at what is listed. There should be a directory there that looks familiar to you and is similar to whatever name you used for your user account.


Even when I just do

cd /Users

it says "no such file or directory"

preceding everthing is says:


does this mean anything? or do I need to change this some how?