Linux – share /usr/local between multiple Linux distributions

directory-structuredual-bootlinux

I tried Ubuntu 12.04 and based on my understanding I made the following partitions:

  • 2GB Swap (I have 2GB of RAM)
  • 1GB /boot, since I'll be installing different kernel versions (I'm starting kernel development)
  • 35GB /var
  • 40GB /usr/local
  • 407GB /home
  • 15GB / (root)

Now I want to install OpenSUSE 12.2 alongside Ubuntu 12.04. Can I share /var and /usr/local among the two OSes? I know they are two different distros with different packages, but is there any way I can share the disk space? So that both OSes can have their own /usr/local in the same partition or something like that?

Best Answer

You can share /usr/local. Sometimes the two distributions will have different versions of libraries available, so you may need to install a few libraries on one side or the other or in /usr/local itself. The burden of installing the odd extra library is likely to be compensated by not having to maintain two installations of each program in /usr/local.

If there are programs that you only want on /usr/local for one of the systems, you can make a different arrangement: don't share /usr/local, but share a stow repository, and make symlinks into the /usr/local of both systems.

You don't need to put /usr/local on a separate partition to share it. You can store it on one system's system partition, mount it wherever you want on the other system, and create a symbolic link.

You cannot share /var. There are minor differences in how the directories are arranged, and each distribution has its own user IDs. You may be able to share parts of /var, for example the mail spool.

35GB for /var is huge. You don't need that for a basic system. If you're going to put a lot of data there (e.g. because that's where your web server root is), size the filesystem according to your data. There's no point in splitting /var from the root partition, so combine them. You don't mention /usr in your list: this too needn't be split from the root partition. Just make one system partition for each OS, plus a shared /home. You do need more than 15GB for the system partition, unless you're going to be very conservative in the programs you'll install. Make a 50GB system partition and you'll be fine.

There's no need for a separate /boot partition unless you have additional requirements such as encrypting the system partition.