Knowledge Base:Sharing partitions between Linux systems

Synopsis
People that dual-boot their Linux system with another Linux system might be inclined to share file systems between the Linux systems. In this article we'll cover which file systems can be shared (and how).

Environment
This article is applicable to all systems that dual-boot with other Linux systems

Analysis
When sharing file systems (partitions usually) users must take care about
 * mixing of user ids
 * collision of files managed by the (different) package managers
 * use of extended attributes

User IDs
Each file on a file system has ownership information. On the file system itself, this is stored as the numerical value of the accounts.

When you use dual-boot between Linux systems, you must take care that the file systems you share only host files that have the same mappings (uid and gid) for the users and groups. If you don't, ownership and group-ownership will change between the systems, potentially causing disruption of services or even security issues.

Package managers
Each Linux system uses a package manager to manage software installations. These package managers keep track of the installed files (and to which package they belong). If you would share partitions between Linux systems and have the files on these partitions altered by their package managers, then the package managers' databases will host wrong data or even become corrupt.

It is therefor advisable not to share file systems whose content is managed by a package manager, or make sure that the sharing is only done on a read-only basis.

Extended attributes
Some systems use extended attributes on the files to manage more in-depth security (like with SELinux). If the other Linux system does not support these extended attributes (or ignores them) then these settings will become stale or even disappear between reboots, causing potential service malfunction.

Resolution
When sharing of partitions is wanted, the following locations can be shared as long as the Linux systems do not use services that rely on particular file metadata (like SELinux with extended attributes).


 * The /boot partition is a nice candidate which is probably already being thought off. After all, dual booting means that the boot loader is definitely shared. Make sure though that the Linux systems do not try to manage the boot loader configuration themselves. Instead, manage them manually (this is already the case for Gentoo Linux)
 * The swap partition can definitely be shared between Linux systems because the partition is always considered empty after shutdown of a Linux system. It is an extension of the memory of a booted system, and dual-booting means that the two systems never run simultaneously
 * Temporary locations like /tmp and /var/tmp can be shared between Linux systems (if they reside on separate partitions of course).

The following partition can be shared but is not recommended:


 * The /home partition can be shared between Linux systems, but only under the condition that the user ids and group ids are the same on both Linux systems. This can be verified by comparing /etc/passwd and /etc/group on both systems. However, this is not recommended since the home partition also contains the users' configuration files (for applications). When the two Linux systems use different versions of the applications, then the configuration files will become mangled or might even become corrupt.

Instead, it is better to create a dedicated data partition where users on both Linux systems have access to, and share that partition instead.