Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
    
You should try to ask one question at a time; I removed the part about /var –  Michael Mrozek May 3 '13 at 4:00

4 Answers 4

up vote 3 down vote accepted

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.

share|improve this answer
    
this was another nice answer, thanks really helpful. if you could just be a little more clear on the first paragraph of your answer becoz i am little confused there. if i am installing Ubuntu and openSUSE on the same system, i may face "two installation of each program".. what difficulties may arise out of it? –  Arun Kumar May 4 '13 at 3:45
    
i did some internet research on your solution and got a better understanding of it. so what i understand is that i can share /usr/local/ as the files inside are not OS dependent but i may have to install new libraries in the new OS (say openSUSE) that i will be installing. i am thinking of reducing the size of /var to install the new OS. what would you suggest the size of / (root) be.. if i am going to share /usr/local and /home directories also i was planning to share /boot would this pose any problem sonsidering i will be doing some kernel development later. –  Arun Kumar May 4 '13 at 4:21
1  
@ArunKumar Sharing /boot doesn't always work smoothly, because different distributions maintain their bootloader and kernels in different ways. If you're going to fiddle with kernel installation scripts anyway, you can share /boot. Again, for the root partition, I suggest 50GB, with no separate /var or /usr. –  Gilles May 4 '13 at 10:07
    
is there any way i can implement your suggestion on the current system, i have many applications installed already and i don't want to format the partition.. any utility to merge and/or resize the partitions. –  Arun Kumar May 4 '13 at 12:35
    
@ArunKumar It's definitely possible. How difficult this is depends on your partition layout. Post a separate question, mentioning your current partition layout (e.g. output of fdisk -l) and how full each partition is (output of df). –  Gilles May 4 '13 at 13:02

In addition to symlinks, you could also use bind mounts: http://docs.1h.com/Bind_mounts

Basically, you can have one partition with one filesystem (similar to Anthon's setup). In this case, assuming you have the filesystem mounted on /mnt/local you would just do mount --bind /mnt/local/ubuntu /usr/local on your ubuntu install and mount --bind /mnt/local/suse /usr/local on your suse install.

One benefit of doing this is that you can do it over an existing /usr/local without destroying/moving the actual /usr/local directory.

Here's an example:

# mkdir foo
# touch foo/nowyouseeme
# mkdir bar
# touch bar/nowyoudont
# ls foo
nowyouseeme
# mount --bind ./bar ./foo
# ls foo
nowyoudont
# umount foo
# ls foo
nowyouseeme
share|improve this answer
    
This looks like a very good solution... will surely try this @zestrada –  Arun Kumar May 3 '13 at 20:31
    
will it be safe to share the boot partition, overwriting the bootloader of one installation with the another. –  Arun Kumar May 4 '13 at 3:49
1  
If you're doing a bind mount of /boot, I don't believe that would affect the bootloader unless you try running grub-install or update-grub (depending on the version) and it reads from the newly mounted one. (see linux.die.net/man/8/grub-install). But overall, I believe I have gotten away with running one /boot partition. You will probably want to look at this guide: garron.me/en/linux/… or something similar for dual-booting two Linux installations. –  zje May 4 '13 at 3:55

/usr/local (i.e., locally compiled/installed software) should work fine, as long as the system libraries used by whatever is there are compatible. This means that you might get away with this with rougly contemporaneous "for desktop use" distributions. If you try to mix and match say Fedora and RHEL/CentOS do all building on the distribution with the older libraries (RHEL/CentOS in this case), as the base libraries (glibc mostly) are reasonably backwards compatible. You will run into problems with C++ (the C++ runtime tends to change quite a bit between versions), some graphics libraries do change interfaces willy-nilly. Anything desktop environment related (be it KDE or Gnome or whatever) is probably right out of the question.

share|improve this answer

How to set up multiple installations on a machine is something that depends on your style of working with these installations. Another to keep in mind is that unless you are going to do some nifty virtual machine work using real partitions these two installation will not work at the same time.

In my experience the /home partion should be shareable without to much of a problem. Any users that are specifically made for applications (dovecot, fetchmail) but either of the systems normally do not have real directories under /home like the 'normal users'. I do share login names between different Ubuntu versions but that sometimes gives problems going back to an older installation, because configuration files in your home directory were automatically converted. To solve such issues, I have the same login with different home directories under /home, but with the same user id and group id to share the data. You can always make a link between specific subdirectory (e.g. those with your Music) for which there is no risk of incompatible/irreversible upgrades.

I have not have a separate partition since working on a PDP 11/70 in the mid-80's so I don't know why your friend recommended that. Moreover several programs will default to installing to /usr/local if you install from source and e.g. pip installs for python modules do the same. To prevent problems there I would make a /mnt/local on each machine mount the partition designated for /usr/local there, make directories ubuntu and suse in that partition and soft link ( ln -s /usr/local /mnt/local/ubuntu ) for each resp. machine. That way you share the space on that partition without running risk of accidental overwriting. You can always make links later between stuff that you explicitly want to share.

An additional thing I can recommend is keeping some kind of log for what you installed for each installation ( I use emacs in changelog mode with a file for each machine-distro-revision combination ), so you can redo the installation if you upgrade and you don't have to remember what extra stuff you installed. I nowadays have a setupnewsystem script that does all the extra stuff for me, including putting /etc under revision control after installing mercurial

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.