Before re-installing Ubuntu 12.04 LTS, I unmounted the /home directory. After a clean re-install, I recreated some of the users and installed the ubuntu-desktop package, then re-mounted the old /home directory. All of the documents have been restored, and I have no problem as long as I login with the shell. However, when I try to login to the GUI, it just re-loads the login screen. This has been happening ever since I included the old /home directory in /etc/fstab
.
Trying to follow the solution here, I looked for the .Xauthority files in every user's /home
directory and noticed something weird, the users seem to have been mixed up. For example, ls -lah | grep Xauthority
in /home/bob
would show as:
-rw------- 1 emily emily 53 Nov 29 10:19 .Xauthority
and so on. My guess is that I didn't re-create the users in the same order as in the old system, so that things went weird when I mounted the old /home
directory. However! I need to be able to plug the old /home
directory files as is because they are several TB and I don't have the space to transfer them here and there freely, nor am I allowed to delete anything. What should I do to fix this?
Is it a good idea to replace all hidden files in each old /home/user
directory by the new ones?
[Additional information]
Contents of ls -l /home
(after mounting old /home
);
note: lost+found
was NOT supposed to be an user.
total 36
drwxr-xr-x 22 bob bob 4096 Mar 11 12:23 alice
drwxr-xr-x 44 marc marc 4096 Mar 11 12:21 emily
drwxr-xr-x 23 1004 1004 4096 Jul 29 2013 bob
drwxr-xr-x 4 1005 1005 4096 Jul 30 2013 ken
drwx------ 2 root root 16384 Mar 27 2012 lost+found
drwxr-xr-r 40 emily emily 4096 Mar 11 12:49 marc
Contents of cat /etc/passwd
(restricted to the users listed above):
root:x:0:0:root:/root:/bin/bash
marc:x:1000:1000:marc,,,:/home/marc:/bin/bash
emily:x:1001:1001:emily,,,:/home/emily:/bin/bash
bob:x:1002:1002:bob,,,:/home/bob:/bin/bash
ken:x:1003:1003:ken,,,:/home:ken:/bin/bash
Note: user alice
was not re-created after OS re-install because the account was no longer needed.
Output of lsblk
:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 931.5G 0 disk
+sda1 8:1 0 285M 0 part
+sda2 8:2 0 1K 0 part
+sda5 8:5 0 18.6G 0 part
+sda6 8:6 0 93.1G 0 part /home
+sda7 8:7 0 93.1G 0 part
+sda8 8:8 0 698.4G 0 part /home/marc/Data
+sda9 8:9 0 9.3G 0 part [SWAP]
+sda10 8:10 0 18.6G 0 part /
sr0 11:0 1 1024M 0 rom
sdb 8:16 0 1.8T 0 disk
+sdb1 8:17 0 1.8T 0 part /home/marc/Data2
sdc 8:32 0 1.8T 0 disk
+sdc1 8:33 0 200M 0 part
+sdc2 8:34 0 465.8G 0 part /home/marc/USB_Disk/Disk1
+sdc3 8:35 0 465.8G 0 part /home/marc/USB_Disk/Disk2
+sdc4 8:36 0 465.8G 0 part /home/emily/Data
+sdc5 8:37 0 465.6G 0 part /var/www
sdf 8:80 0 3.7T 0 disk
+sdf1 8:81 0 1.8T 0 part /home/ken
+sdf2 8:82 0 1.8T 0 part /home/bob
sde 8:64 1 29.8G 0 disk
+sde1 8:65 1 29.8G 0 part [SWAP]
As you can see, user marc
has Documents shattered over a number of different disks and partitions.
Best Answer
ln -n
will show you what the filesytem thinks the UID and GIDs for the users should be. Here's an example from my system.In this system,
oli
has the right UID of 1000 but if I did something so that it was1001
, I could simply useusermod
to punch it around. Let's say I want to swapoli
andtest
's UIDs around. This is a three-hop game as two users can't share a UID. They can share a group though.One note: If your current user is one of the users in the changearound,
sudo su
before you start and run everything as root. Just remember that the safety's off. You don't want to get halfway through this process and have your sudo privileges bug out on you.You'll need to play this sort of ballet until the usernames in /home/ line up with their UIDs (as shown in
ls -ln /home
). Alternatively you can alter all the files with a fewfind
calls but I personally think this is a big fat waste of time. It's easier, quicker and potentially less destructive to fix this centrally through the user system.Next time remember to check the UIDs beforehand. The
--uid nnn
argument onadduser
will make this painless.