Linux – FreeBSD and Linux shared partitions

dual-bootfreebsdlinuxpartition

Which directories, and how, can I share between FreeBSD and Linux? In particular, how can I deduplicate respectively /usr/home and /home?
I guess directly sharing a partition between both systems could lead to conflicting dotfiles, so that may not be the right solution.
Is union-mounting the shared partition reasonable? This way, I could move the dotfiles into the "/" partition of each OS, and share the rest of the files into the shared partition.

Which filesystem should I use for the shared home partition itself? I have under 2GB RAM so I don't think ZFS will behave, from what I've read. Maybe ext2 will do? Any better options? EDIT: is write-to-UFS kernel support in Linux stable already?

  • Linux distro is LMDE.
  • Actually using PC-BSD but as far as I've read it should behave just as FreeBSD for this. Correct me if I'm wrong.
  • Partitions would be:
OS      Mountpoint FS    Size (GiB; Total:~160GB)
Linux   /          ext4  16
FreeBSD /          ufs   16
Shared  /mnt/home/ ext2? ~124    # EDITED: See below
Shared         -   swap  4

Any other partitions I should make? It's a workstation without "persistent" servers, but I may fool around with jails in FreeBSD. Maybe I should have a partition for those?

Disclaimer: I haven't actually used union filesystems before, and am new to BSD in general; feel free to propose better solutions 🙂

EDIT:
How about adding a "dotfiles" tree in each root partition and union-mount it?

Mount points in FreeBSD:
/
/mnt/home/
/usr/home/: /usr/dotfiles/ U /mnt/home/            # /usr/dotfiles/ has priority

Example contents:
/usr/dotfiles/fchurca/: .cache .kderc
/mnt/home/fchurca/: .vimrc development/ Documents/ # .vimrc isn't platform-specific
/usr/home/fchurca: .cache .kderc .vimrc development/ Documents/

This way, it could work for all the (two at most) users of the box.

Best Answer

You should only share data partitions. Do not share any program partitions.

/home is fine but avoid bin, dev, etc, usr, var, opt, and pretty much anything other than home.

As for the filesystem, it will have to be something both kernels have drivers for. I'm not sure how good BSD's ext support is, but Linux's UFS support is good enough, which means that you probably want to stick with UFS or MSDOS. The swap partition can be shared as long as both recognize the same partition type for swap (which I believe they do, but I am not certain).

And if you're sharing partitions between operating systems don't do anything like trying to run one in a VM from the other. Operating systems need to have exclusive control over filesystems. Two different running operating systems that thing they both have exclusive control over a partition will lead to corruption real fast.

Related Question