I'm using 11.10 (ext4) and somehow I've lost /home/myuserid. /home is there, but appears empty. I can boot to the login prompt and login as Guest, but when attempting to login as myuserid, I get routed back to the login screen. I can also boot into recovery mode via Grub, then to a root prompt. As both Guest and root, /home appears empty:

root@ubuntu:~$ cd /home
root@ubuntu:/home$ ls -al
total 0
drwxr-xr-x  1 root   root    60 2012-01-13 07:42 .
drwxr-xr-x  1 root   root   240 2012-01-13 07:42 ..

However, when I boot the computer with my Ubuntu installation USB, run from USB, and open Nautilus, I can see /home/myuserid is there, and all the files in it are intact. I tried recovering it using parted as explained on the Ubuntu Data Recovery page, but the rescue START END command didn't do anything (didn't even give a return code, just a new prompt).

It seems like I've just deleted a pointer in the partition table to the location on disk or something, without deleting the actual partition and files. Anyone know how to restore /home/myuserid?

PS - I've read through many of the threads here on this topic, but they all seem oriented toward restoring lost files, rather than restoring a partition table pointer to a user folder, or fixing a problem with a user folder not mounting correctly, or whatever it is I've done here. My files really aren't lost, I can see and open them just fine when running from the USB drive, and I'm hesitant to try recovery tools like PhotoRec when 1) they don't seem 100% reliable, and 2) I suspect the solution is simpler.

Edit: /home is not mounted now. Booting with the USB drive, which is what I'm doing now, does not automount it. And yes /home is on its own partition (as are /boot, swap, /, and /home, all on separate partitions).

  • 1
    Is the /home/myuserid on an extra partition? Is it mounted? With what options? (You can use the mount command to see details about all this.) – arrange Jan 13 '12 at 8:27
  • 1
    If you are able to run Nautilus from USB and access your files, you had better be backing everything up to another drive before you try anything else. Seriously, stop all troubleshooting and focus on that first, unless you already have a complete backup. – Tom Brossman Jan 13 '12 at 8:41
  • @arrange - thanks, answered above. Not mounted right now, I'm just booting from USB while I figure out the problem, USB doesn't automount /home. Also, /home is on its own partition (as are /boot, swap, and /). – Kurtosis Jan 13 '12 at 16:57
  • give use output of mount and df /home – jet Jan 13 '12 at 19:21

We do not know why or how you lost your $HOME but from what you said it still seems there.

You can easily switch to a shell from your Guest Session by pressing Alt+Ctrl+F1. From there login with your myuserid. You may experience an error saying No directory: logging in with HOME=/. After being logged in run

cd /home/myuserid

If all files are in place and only then you may be able to restore your HOME with the following command

sudo usermod -d /home/myuserid myuserid

Log out from the guest session and login to your account as usual.

If your files are not visible from the guest session then do as comments already suggested. Backup your data or try to mount the partition where /home resides.

  • Thanks Takkat, I restarted, booted into the root recovery console, no GUI, then used 'su - myuserid' to log in. The login succeeded, but gave the error you mentioned: No directory: logging in with HOME=/. -su: cannot create temp file for here-document : Read-only file system. Also, /home/myuserid is still not visible here, either as root or myuserid. I'm afraid usermod -d might overwrite my user directory in this case. What do you think? – Kurtosis Jan 13 '12 at 17:18
  • 1
    It will not overwrite anything inyour /home but if you can't see your files then there may be something wrong with the /home partition mounting. Try with mount -a. Before you continue to play further around make a backup of your /home/myuserid directory (also include hidden dot-files!). You can always restore that later in case something goes entirely wrong. You may also want to consider posting the content of your /etc/fstab here. – Takkat Jan 13 '12 at 18:46
  • Ok, I got it restored following your advice. I logged into the recovery console as root and ran mount -a, then rebooted. Ubuntu ran the filesystem check during boot this time, and apparently repaired the missing user directory. Then I was able to log back in under myuserid and everything is back to normal. Thanks so much. I'm still not clear what was going on though. How could /home be mounted, but the sole userdir /home/myuserdir not be? I thought if /home is mounted you can see everything in it automatically, but apparently not? – Kurtosis Jan 13 '12 at 20:00
  • 1
    Glad you got it sorted out! It may be that there was a file system error. You should check your harddisk for errors (see e.g. this question) to be on the safe side. – Takkat Jan 13 '12 at 20:06

OP's own answer edited out of the question:

Solution: Boot with Ubuntu Live USB, find the missing user directory in /media, back it up, then boot into the Recovery Console Root Prompt, run mount -a to force mount everything in fstab, then reboot and try logging in again. Details:

  1. Backup /home/myuserdir using cp -ax to preserve all links and attributes:

    • Plug in an external hard drive or other backup media via USB.
    • Boot from USB startup disk. [1][1] [2][2]
    • Open a terminal, cd /media
    • Find the unmounted /home partition in /media. It may be named a long GUID string instead of /home. Just cd into it and see if the missing /home/myuserid (or /[GUID]/myuserid) partition is there. Once you've found it, then ...
    • Copy the entire user directory to backup media using [cp -ax to preserve links and attributes][3]:
    • ubuntu@ubuntu:/> cd /media/[GUID]
    • ubuntu@ubuntu:/media/[GUID]> cp -ax * /media/backupdrivename/backupdir
    • This will take a while. About 30-40m for my 117GBs, for reference.
  2. Log out, shutdown, remove the USB startup drive and the backup hard drive. Reboot into the Ubuntu Recovery Console.

    • Hold Shift down while booting to display the GRUB boot menu. Choose the Recovery Console boot option.
  3. In Recovery Console, select the option to drop into a Root Prompt.

  4. At the root prompt, run mount -a to mount everything in /etc/fstab. Now check /home with ls -al /home. With luck /home/myuserdir is now there.

  5. Reboot with sudo reboot. If Ubuntu starts the auto filesystem check during reboot, let it run, don't cancel. At the login screen, login with normal userid.

  6. After this my /home/userdir had been restored and I could log in normally and everything worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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