Can I map /home to an existing /home partition without borking anything?

Hi,

I’m need to reinstall OpenSUSE and I’d like to change the partitioning. I currently have two SSD’s in my computer:

  1. A SATA SSD that’s had Mint installed for some time
  2. An M.2 NVMe which is where I’m reinstalling OpenSUSE (this SSD is recently added)

I have Mint setup with a totally separate /home partition. I don’t know whether this is a stupid question but I noticed that OpenSUSE automatically mapped /swap to the existing /swap on that other SSD which got me thinking. Is there any reason that I cannot just manually map /home to my existing /home partition that’s on the Mint SSD? Will I lose any files doing that? Will it overwrite stuff that’s there? Are there any pitfalls of doing this that I should know about?

Any info would be brilliant. This seems like a sort of simple thing but I try never to screw around with partitioning unless I’m sure it’s OK. It’s just too easy to lose data or do something dumb. :smiley:

If yo make separate users one for each OS and use the same file system. Since the different OS may have different versions of DE they may need separate configuration files.

There is a huge difference bwteen Swap and file systems.

A partition used for Swap (and NOT /swap, that is probably where your confusion starts), will only be used as long as an operating system runs. After the operating system stops there is nothing there of any interest (except for spying people). And when a new operating system (the same or another in multi-boot) starts, it can use the same partition for swap because it will only put things there of interest during the life running time of the operating system.

On a file sytem there is most probably data that you want to keep. It may be that you want to use that data (and thus the file system) on another operating system you use in multi-boot. Most easy is then to mount it at a convenient place. This is how you can use Windows file systems in a multi-boot environment by mounting them. More easy of course when you multi-boot with other Linux systems because those will use the same native file sytem types.

So two (or more) Linux system (in multi-boot) can mount file systems with data when and where that is needed.

That is basicaly also true for a file system that is mounted on /home in one of those systems. You can mount that where you need it on another of the systems. Even on /home. But then you should know very well what you are doing.

Because in /home are (normaly) the home directories of users. Users are defined by their UID (a number). So take care that home directories owned by a user on system A will not become the home of another user (person) on system B.

And when a user finds his/her home directory on as well as system A as system B, (s)he will of course see al the data on both sides, but take care, desktops (and other applications) tend to put the personal configurations of a user in home directories. Thus when a different version of of e.g. KDE is run on both systems, that can introduce problems.
A stack of programs like KDE will most probably see that the confifuration files are created by an older version and then adapt that to the present version. But such an upward compatibility and change is NOT guaranteed the owther way around.

An example might be useful to illustrate what @hcvv wrote about.
Say I have Leap installed with a single user: username=bruno UID=1000
I see my files in /home/bruno/

Now I install Tumbleweed on the same system, with a single user named Bruno, so here too username=bruno, UID=1000
During install the installer finds that a /home/bruno/ folder already exists, and asks if I want to reuse it; following what @hcvv wrote, I answer NO, so the installer creates a new home folder at /home/bruno_/ (or something like that) so that user config files for Tumbleweed are not mixed with user configs for Leap.

Nevertheless, my TW user has UID=1000, and my Leap user too has UID=1000, so when logged in in Tumbleweed my user bruno (TW) can navigate to a “foreign” folder at /home/bruno/ and work on every file there since permissions there see UID=1000 as a legitimate owner.

Long story short, you can have separate configs and still work on your files from a user on an “alien” system.

I’d create different usernames. Less error-prone.

Good example of the same UID using different home directories on different systems, but part of the same /home.

Another use case (just invented it myself :)).
There are two end-users of a system’s hardware. Both love a different distribution. But they want to be able to have access to some/much of each other’s data.
Possible solution. On distribution A there is user a with a GID of 1000. On distribution B there is user b with UID 1001.
Both have the same primary group (e.g, the infamous users). There is one /home partition used by both distributions as such.
Result. Each user can boot his preferred system, login and have access to her/his own home directory. Each user can also access the files in the home directory of the other user (when prrmiited by that user through managing the permissions, specialy the group permissions) in the same way as if both were users of the same distribution.

Sure, that’s what I actually do on a test system of mine where I have 3-4 versions or systems all using the same set of test files etc.
But I wanted to remark that the openSUSE installers ask what to do when they find an already created home folder; not sure about other distributions though.

You can do it.
I don’t remember the exact setting i configured,
But during the new installation I remember on the layout screen I selected doing an Advanced configuration and using the graphical Partitioner pointed /home to my existing.

Of course, don’t leave anything to chance.
Copy and/or backup everything valuable to external storage so if you destroy the data, it’s not lost.

TSU

Another option is to have a separate partition/filesystem for most home data, but mount it elsewhere than /home, such as /home/data. The result is that settings particular to various software versions are kept on each root filesystem, but data common to all installations is on the separate filesystem. Each OS installation can use the same username, userid and groupid, with no special configuration of permissions, other than setting the appropriate userid.groupid on the directory on which the data filesystem is mounted. Symlinks can be added from each installation’s homedir to the common directories, such as:

  • Documents
  • Downloads
  • Music
  • Pictures
  • Public
    *]Videos

File permissions and other metadata are stored in the file system objects:

karl@erlangen:~> LANG=C stat .
  File: .
  Size: 12288           Blocks: 24         IO Block: 4096   directory
Device: 10303h/66307d   Inode: 2228225     Links: 79
Access: (0755/drwxr-xr-x)  Uid: ( 1000/    karl)   Gid: (  100/   users)
Access: 2020-07-29 11:40:05.538539330 +0200
Modify: 2020-07-29 11:36:32.192139140 +0200
Change: 2020-07-29 11:36:32.192139140 +0200
 Birth: 2016-08-16 21:17:36.908000249 +0200
karl@erlangen:~> 

Any installation will use uids and gids consistently when mounting a partition. On the other hand installations have their private user and group names associated with uids and guids, which may differ. Basically that is all you need to know.