Locked out of /home directory

Q I'm having a problem accessing my /home/stuart directory under Red Hat 8.0 and Debian Sarge, and was hoping you could help. I'm using three hard disk drives. Two hard disks (40GB and 20GB respectively) have been fitted into a removable caddy and take it in turn to be hda. (I'm swapping drives in order to familiarise myself with several distros.) Each holds /, /boot, / swap, /tmp, /var and /usr partitions and has been formatted as ext3 while the fixed hard disk (hdb, 6.4 GB) has only the /home/stuart partition and has been left with its old ext2 formatting as it contains files and programs which I want to retain. One removable hard disk holds Mandrake 10.1 and can access /home/stuart just fine either as root or as user 'stuart'. The other removable hard disk holds RH 8.0 and this is where the problem lies. When using RH and logging in as root, I can access files and programs in my home directory, /home/stuart, without any difficulty. However, when I try to log in as 'stuart' the system displays the following error dialog:

'Please contact your
system administrator to
resolve the following
problem: Could not open or
create the file
"/home/stuart/.gconf-test
locking file"; this indicates
that there may be a problem
with your configuration, as
many programs will need to
create files in your home
directory.

The error was"Permission denied" (errno=13)'. I've also replaced Red Hat 8.0 with Debian Sarge (which installed without a hitch). But I now get error messages such as:

'Could not set mode 0700 on private per-user gnome configuration directory
'/home/stuart/.gnome2_private/': Operation not permitted.'

During installs, I'm always careful to ensure that the fixed hard disk is recognised (by the installer) and mounted but not formatted. The permissions are 711 on /home/stuart and 700 on /home/stuart/.gnome2_private/.

A This is a permissions problem. Although you are using the same user name with both distros, they will have different numeric IDs - and the filesystem uses the numeric IDs to track user privileges. This is quite simple to fix, but you will then run into further problems. You should have a separate home directory for each distro, although all on the same /home partition. To fix the ID issue, you need to tell Debian to use the same numeric ID for 'stuart' as you do in Mandrake. The process is made a little more difficult, because you cannot access the Debian and Mandrake files at the same time. So boot Debian and type

grep stuart /etc/passwd

You should see something like this.

stuart:x:1000:1000:Stuart Elliott,,,:/home/stuart:/bin/bash

Make a note of the first number: this is your user ID (UID). Now boot into Mandrake, log in as root and load /etc/passwd into your favourite text editor. Find the line for 'stuart' and change the UID to the same as in Debian. The reason for doing it this way round is that Mandrake is unusual in starting user UIDs at 501, whereas most start at 1000. Save the modified passwd file and type

chown stuart: -R ~stuart

to change all files to the new UID. Now reboot into either distro and you should be able to access your files. You may still face problems, however, because you are using the same home directory to store config files for two different distros. If, for example, you have different versions of Gnome on each distro, the last one you use will overwrite the config files with potentially incompatible data. The safest approach is to have a separate home directory for each user, say /home/stuart-mdk, /home/stuart-deb and so on. To do this, you need to mount the partition on hda as /home instead of /home/stuart, and put all the contents in the directories into it. Edit /etc/passwd on each computer to set the appropriate home directory. I would then create a /home/stuart-common directory for all the data you wish to share and link the directories in here to your distro-dependent directories. For example:

ln -s /home/stuart-common/Mail/home/stuart-deb/Mail
ln -s /home/stuart-common/Mail/home/stuart-mdk/Mail

will allow you to access the same email in both systems. Use your existing /home/stuart directory as the basis for this directory. I have successfully used this method to run a multi-boot system without any of the corruption of desktop or personal settings that happened with a single home directory.

Back to the list