Accessing the user space of one OS from within another.

Recently, I setup a dual boot on this PC. I can currently jump from Ubuntu 12.04 and 16.04. What I would like to be able to do is access the home directory of my 16.04 OS from within the 12.04, is that possible? I can mount the partition of the hard drive where 16.04 lives from within 12.04 but it seems like it's only allowing me access to the kernel space.

note: I believe this question fits under the unix.com umbrella but if not let me know.

EDIT: I may have pulled the trigger on asking this question a bit to early. This could be my own fault for how I setup my 16.04 system.

Isn't the target directory visible under

/<mount point>/home/username

? What do you see in the mount point's directory?

@RudiC Here in lies my problems. This is my work PC so we have an SSO active directory. I vaguely remember setting this PC up 8 months ago when i started working here and I seem to remember mucking things up a bit back then. Well I know I did because inside my 16.04 home directory there exists three folders: rob@ourdomain.com, ourdomain.com and sysadmin. The Home directory I want to access from the 12.04 OS lives inside of the ourdomain.com directory and its called 'rob'. I just don't know enough about SSO, PBIS, SSSD and all these networking protocals/tools atm to make any definitive statements about how my computer is setup. I need to spend some time figuring out how this PC is setup.

It seems you need to understand a few basics about UNIX/Linux filesystems before we can tackle your problem:

A "filesystem" in UNIX is a space where files can be stored. It is organised in a way so that it has a "top" directory in which other directories and files can be stored. The other directories can itself again contan directories and files, and so on, so that it resembles a "tree structure":

---- directory +- file1
               +- file2
               +- directory1 ----- file
               +- directory2 ---+- file1
               +- file3         +- file2
               +- file4         +- directory --+- directory
                                +- file3       +- ...

Every UNIX system has a "main" filesystem, which is located at / . Into this all the other filesystems are "mounted". To mount a filesystem you need a directory, either the "main" filesystem or in one that has already been mounted before. The mounted filesystem then shows up with its top directory being this directory.

I.e take the above example: you probably have a directory /mnt , which should be (by default) empty. If not you could create it (as root). Would you now mount the example above it would look like this (i leave out a few details):

/---- dev/....
 ---- usr/....
 ---- bin/....
 ---- mnt/ +- file1
           +- file2
           +- directory1/ ----- file
           +- directory2/ ---+- file1
           +- file3          +- file2
           +- file4          +- directory/ --+- directory/
                             +- file3       +- ...
 ---- home/....
....

In the end you end with a uniform tree-like system which consists of one or more sub-trees mounted together. This means a user does not have to care about which disk or partition a file is (physically) located on because he operates in a homogenous environment (unlike in Windows where you have to discern between directories and drive letters).

Try the command mount and the system will show you which filesystems are mounted and at which "mountpoint" (the directory they are plugged into the main tree). There is also a file describing which filesystems are mounted at system start. In Linux systems this is /etc/fstab . (Other systems have similar files which may be named differently.) For reference, here is the one of the laptop i am writing this:

/dev/mapper/rootvg-rootlv /               ext4    noatime,errors=remount-ro 0       1
/dev/mapper/rootvg-altrootlv /altroot     ext4    noatime,defaults          0       2
# /dev/sda1
UUID=4d628014-85e7-48d0-a2ad-8dde00f17748 /boot  ext4    defaults        0       2
/dev/mapper/rootvg-homelv /home           ext4    noatime,defaults        0       2
/dev/mapper/rootvg-optlv /opt              ext4    noatime,defaults        0       2
/dev/mapper/rootvg-swaplv none            swap    sw              0       0

Now to your problem: you will have to have a separate filesystem for your home. Usually you do not create a separate filesystem for your home alone but for all users. This would contain all users homes and would be mounted at /home , like you see in my fstab above. If you don't have it, log in as root, create it, mount it temorarily under /mnt and then do the following (all this has to be done as root, preferably while no other user is logged on):

mount <your new home-fs, i.e. "/dev/sda3"> /mnt
cd /home
tar cf - * | (cd /home ; tar xf -)

The last command will, depending on how much data you have in your home, take some time. It will copy all the data from your home to your newly created FS. When finished unmount the new filesystem:

umount <your new home-fs, i.e. "/dev/sda3">

and edit your file /etc/fstab by adding this line (replace "/dev/sda3" with the real device name):

/dev/sda3 /home           ext4    noatime,defaults        0       2

Then try to mount it:

mount /dev/sda3 /home

Log in now with your user and make sure all your data is there and nothing is missing. If satisfied, log out again.

You now need to re-login as root, unmount the mounted FS again and then (after you unmounted the FS!!) delete everything in /home . This is to preserve space because by mounting over the directory /home everything in there will be invisible as long as the new FS is mounted. This is why we copied everything to the new FS. You can also postpone a few days deleting the old home just to be sure.

You can now reboot and your system will come up with the new /home FS mounted automatically. Repeat the process of adding the new FS to /etc/fstab with your other OS. Notice that your user account needs to have the same user ID and group ID for that to work smoothly. If the user accounts happen to have different IDs you can correct this in /etc/passwd and /etc/groups

I hope this helps.

bakunin

2 Likes

Alright great, thanks for that guys I appreciate it. Everything seems to be in working order now. There is one thing though, for some reason, when I start up my 12.04 machine I am getting a few error reports briefly printing in the top left corner of the screen. Usually, they something about a broken pipe or an inability to communicate with this or that. Should I worry about it?