Failed login to home directory SOLVED

Sorry this is a long story can’t figure out how to shorten it so that it makes sense.

The /home and /data partitions disappeared on my laptop but mate 16.04 and windows partitions are still there. 16.04 would start booting but only give me a terminal, because it couldn’t find /home or my data partition, listed in /etc/fstab.
I’ve just installed 17.04 in the space left by the disappearing partitions, creating a new /home.
This then booted into the desktop login screen.
But the in the old 16.04 I was michael and in the new 17.04 I’m mike.

Of course 16.04 is still asking for michael to log in and there was no michael home. So I’ve created michael’s home and pasted the 16.0 home files from the PC desktop into it.

Still no joy, when I enter the password, it starts to do something, but just comes back with the login screen and no fault message.
I have a feeling it’s a permissions issue, and I don’t think michael has permission to open the home created by mike.
Any clues anybody?

I could reinstall 16.04 I guess, but I’d rather repair if possible, it’s so close now.

Could be a permission issue indeed. Root level chown trickery might make you able to take ownership.

sudo chown -R yourusername:yourusername

From within the folder you want to take ownership of, with the user obviously being the one that should take ownership.

May be the user has no /home now since you lost the original partition.
Check the passwd entry of your user.
example:

gnobt@grincheux:~$ grep gnobt /etc/passwd
gnobt:x:1000:1000:Bernard Tremblay,:/home/gnobt:/bin/bash

The home directory is just before the last parameter “the default shell” and in my case is “/home/gnobt” .

Then check permissions for your home:

gnobt@grincheux:~$ ls -ald /home/gnobt
drwx–x—+ 51 gnobt gnobt 20480 avr 24 10:30 /home/gnobt

Also, did you update your fstab to make it point to the new /home ?

Regards,
BT

Thanks guys, I’ll have to see if I can boot into a terminal, then I’ll try both your suggestions.

Yes I forgot to mention, I had to doctor fstab with the new partition number.
I believe if I hadn’t done that I’d have got the same error as before and it would have gone straight to a terminal instead of the desktop login screen.
I also tried mtab but although I could see it in the file system, nano reported it couldn’t find it.

I’ll get back later,

OK, at the desktop login I hit ctl alt f2 and got a terminal, logged into michael with my password. ls -l confirmed I’m indeed in the directory I posted into /home/michael, and root owns everything and it’s in roots group.

But the sudo chown -R michael:michael doesn’t work. it says there’s a parameter missing.
So with a bit of googling I changed this to sudo chown -R michael:michael /home/michael

And now I own everything and it;s in my group, so lets see if I’ve got the desktop back.

Woooohoooo, that worked, thanks guys, now all I have to figure out is why the monitor resolution is all wrong.