Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Here is what happened to me a few days ago. I was watching a movie in bed and when I turned I accidently pulled the electric plug from my PC and it turned off inappropriately.

When I turned it back on, it took forever trying to fix a major error, it didn't manage to fix it, I ignored the errors. It kept loading and I got to the Ubuntu login page. I entered my password and pressed enter, the screen went black and when it came back, I was where I had been: the login page asking me to enter my password again.

It is stuck in a loop, every time I write my password it goes back to asking me my password. I can't access my session. From the guest session, I tried to access my home, I was able to using console ctrl+alt+f1. Using the ls -al command, I found that my /home/ was empty except for a few folders.

The present folders are:

.cache
.ecryptfs
.face
.Private
README.txt

I suspected that through the hard shut down the eCryptfs got corrupted and is preventing me from accessing my encrypted files. I can't remember if I had configured a passphrase and if I did, I don't remember what it is. Of course I remember my login password.

At this point, I want to either retrieve my data and then I will format and reinstall or simply have the eCryptfs corrupt files fixed and avoid formatting anything.

I can provide you with any additional information if you need it to help me.

share|improve this question

2 Answers 2

For recent versions of Ubuntu, if you set your account up to use an encrypted home directory during the initial setup, it will have set up a directory called /home/.ecryptfs/[your_user_name]. This directory will have two subdirectories, .Private and .ecryptfs. The encrypted files that get mounted to your home directory will be kept in .Private; .ecryptfs has the wrapped passphrase and other configuration files used by ecryptfs.

When you login to your computer, your encrypted files in /home/.ecryptfs/[your_user_name]/.Private get mounted to /home/[your_user_name] automatically, using your login password to unwrap your ecryptfs password and use that to mount the encrypted files correctly, so you can access your home directory securely.

Since your hard drive crashed. ecryptfs has not been working correctly. This could be due to corruption of some of the encrypted data in /home/.ecryptfs/[your_user_name], or more likely, corruption to some of the system files that run linux, so that the ecryptfs system (or some related system) no longer runs correctly.

As a quick aside - a couple things to note here: first, things like this are reasons why its important to back up your data. Second, if you're using encrypted home directories, it's also a good idea to keep a copy of the unwrapped passphrase used to encrypt your home directory in a safe, secure place, not on that computer (you can see what that passphrase is by running

ecryptfs-unwrap-passphrase ~/.ecryptfs/wrapped-passphrase

...and entering your login password when prompted). This unwrapped passphrase can be of help if you need to recover the encrypted data later.

If you need to recover your encrypted data from your hard disk--you can do so with the

ecryptfs-recover-private

command. For example, if you run

ecryptfs-recover-private /home/.ecryptfs/[your_user_name]/.Private

...you will be prompted for your login password (or for the unwrapped passphrase if no wrapped-passphrase file is available). Your encrypted home directory will then be mounted at /tmp/ecryptfs.XXXXXXXX (type df to see the exact directory name). You can then access this directory to get your home directory data, and copy it to another disk.

Note that if you copy the directory /home/.ecryptfs/[your_user_name] to another computer, you can still run ecryptfs-recover-private as above on the new computer and recover the data there.

So in a case where a hard disk is damaged and an encrypted home directory can no longer be accessed, you might typically want to:

  1. Boot your system from a live CD
  2. Mount the partition with /home
  3. Copy the /home/.ecryptfs/[your_user_name] directory to the safe hard disk you want to save the data to. You could use rsync, or cp -a if the safe hard disk is also mounted.
  4. Use ecryptfs-recover-private to recover the data from the copied directory on the safe hard disk.
share|improve this answer

try ls /usr/share/xsessions/

if you see a unity.desktop or similar file there, do the following sudo apt-get install --reinstall unity

hope that fixes your log in issue.

share|improve this answer
    
Thank you for your help Geckobear. Unfortunately it didn't work. I've tried everything. I just need to copy my home to my External Hard Drive and format everything. How can I access my home from the Terminal or Root ? –  Ubuntu User Dec 16 '12 at 15:14
    
I suppose you mean cd /home/<username>/ for the home directory. You could try sudo cp -R /home/<username>/ /media/<username>/<media name> provided you copy onto a USB Drive for example. –  Dialogos Dec 16 '12 at 15:23
    
for copying to another disk, try this: tldp.org/HOWTO/Hard-Disk-Upgrade/copy.html –  Dialogos Dec 16 '12 at 16:04
    
when I access cd /home/<username>/ and type this command "ls -al" none of the folders I need to recover appear 'downloads' 'music' 'movies ... I reinstalled ecryptfs-utils as well as unity. still can't access. I need to recover the folders through .ecryptfs but I don't know how. –  Ubuntu User Dec 16 '12 at 16:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.