For some reasons, the place I work in is stuck with Ubuntu 12.04. As I need a lot of recent software, I wanted to use a VM with Ubuntu 14.04. I successfully setup everything with virtual box 4.3 (the Oracle Edition).

After that, I have tried to create a share of my host home directory and use that as the home directory for the user on the guest. One of the reason is that I don't want to loose everything if virtual box fails so having all the files on the real HD seems important.

Currently the directory is mounted on the guest with AutoFS. The user in guest and host have the same login, uid and main gid.

It seems to work when I use ssh to login from the guest to the guest but it doesn't work with graphical login: the user is immediately disconnected. I guess it's because graphical login on the host creates some files; graphical login tries to create those files on the guest and then fails.

Any idea?

3 Answers 3


Following @Dan Cornilescu suggestions (and comments) I solved this issue like this:

  1. Created a virtual box share for the host home directory say host_home
  2. Optionally (but very important in my case) allowed the guest to create symlinks on shared folders (see here for instance)
  3. Mount this share in the guest at boot time with the guest user uid and gid at say /mnt/host_home (see accepted answer here for instance)
  4. In the guest home, symlink folders that I want to share (works for Desktop, Downloads, etc.)

For now everything works as expected. There may be a performance drop when reading or writing files but it is fine.

  • I just run into a problem: an update of the guest kernel broke the VirtualBox extension and the mount failed. As the Desktop folder was not-accessible, the content of guest ~ was displayed. I updated VirtualBox extension: the folders are accessible but the content of home is still displayed. I have to figure that out. Enabling DKMS on the guest (and letting the extension ISO accessible) should prevent that from happening again (kernel update should update the extension). Jun 11, 2015 at 11:50
  • Among the many methods presented here, I used Ubuntu-Tweaks to bring everything back to normal. Jun 11, 2015 at 12:05

I agree with @Dan Cornilescu. This isn't a good idea, especially given how temperamental Linux can be when files/folders are being manipulated with Sudo privileges, or the lack thereof.

Although I'm sure what you're suggesting (despite the fact that you never really asked a question) is possible, I don't think it's the best solution to the initial issue that you've mentioned. "One of the reason is that I don't want to loose everything if virtual box fails..."

I understand this issue completely. On one hand you have an awesome (free) service provided by oracle, but you don't want to be completely reliant on something that isn't the "norm." However, there are several ways to counteract this issue that offer better peace of mind than "having all the files on the real HD." Here's a couple features built into VirtualBox that I use above all others.

~ "Snapshots." They do just that. Create a snapshot of the VM before/after an installation of any kind or schedule a Snapshot with CronTab. This way you always have a quick and easy way to load/boot to a previous version before a crash.

~ A simple export/import of the VM (or .VHD) as needed. I prefer this method because it's more static (for my needs) than Snapshots. Having a VHD/VM export as a backup is essentially a portable computer and/or an interactive backup. Rather than a standard (dormant) image created by a proprietary method.

~ Create your own, or use a Vagrant Box. More info Here and Here. You can either find a .box that suits your needs and use that as a backup or better yet use a basic .box in tandem with a custom .SH (BASH) script. Update this script as you install progs and alter settings so that in the event of failure you just run a simple script and violä! You're good to go, right out of the gates of a fresh install.

  • Thanks for confirming this. I didn't know Vagrant but if I understand well it will create a regular VM (for instance with VirtualBox) and create shares (with VirtualBox too). So it's similar to sharing the directories I need (and mounting them on startup), right? Jun 3, 2015 at 17:12
  • I'm not sure to get the difference between "snapshots" and "export". In "snapshot", the state of the running programs is saved and everything is restored but "export" only save the guest filesystem? Jun 3, 2015 at 17:13
  • I'm not exactly sure I'm following your comments. The suggestions I made were an alternative to sharing/mirroring directories between systems because I think that's, simply, not a good idea. The Use of a VagrantBox, SnapShot, VM Export, is intended to resolve the issue you mentioned in your question. ie: Having an easily maintainable and reliable backup that can be used as a VM and written/imaged to a physical HDD.
    – user431052
    Jun 3, 2015 at 18:01
  • By the way I think you mean voilà instead of violä at the end of the description of the last solution. Jun 9, 2015 at 8:00
  • @Dan Cornilescu proposed an interesting solution that allow to use the current setup (no reinstallation) without much trouble. Jun 9, 2015 at 8:10

In general I find it's not a good idea to share your homedir between machines with different (versions of) the X server, window manager and/or X applications because some of them often use the same home directory config files and different version can step on each other. Especially if the different software versions are used in the same time.

Often after a newer version of some software updates the files the older versions are no longer able to use those files.

It can happen in the other direction as well, typically when trying to re-use as-is a homedir from an older OS on a newer OS (while a user with a freshly created homedir on the newer OS works just fine) - your inability to login on the GUI could be such case.

A possible approach for keeping the VM homedir on the host HD in a non-conflicting way (I'm using something along these lines when I'm upgrading my OS):

  • export the host homedir via NFS and mount it on the VM, say in /mnt/host_userid.
  • create say a vm_homedir dir inside it which you'll use as homedir on the VM by linking it into the VM's /home dir:

    /home/userid -> /mnt/host_userid/vm_homedir

  • symlink dirs/files other than app dirs/config files to access them conveniently from both machines in the same place like this:

/mnt/host_userid/vm_homedir/documents -> ../documents

This way you keep everything on the host HD (accessible even if the VM is down) but each machine works with its own copy of the config files.

  • Thanks. As your answer is similar to @BiTinerary ones, I will comment under is answer. Jun 3, 2015 at 17:04
  • I updated my answer with a possible solution for storing the VM homedir on the host HD without conflict - in a manner not based on VM stuff (can be used for multiple physical machines with different OSes as well). Jun 3, 2015 at 18:11
  • Thanks for your answer: that's probably the simpler trade-off (simple mechanisms on the host and the guest, no duplication, allow to share what you want and direct backup on the host). Jun 9, 2015 at 7:57
  • Rethinking about it, I think it would be easier to create a vm_homedir somewhere in my host home dir, share it with VirtualBox and mount it as home in the VM and link (from the host) what I need to share. This way I don't have to fight with NFS. Jun 9, 2015 at 8:08
  • I tried to lay out the solution I proposed but is doesn't work. There reason is that a symlink to ../Documents (valid on the host) just says "goes up and find the Documents folder" which doesn't exist (on the guest). I wondered if I could share the whole host home dir, mounting in /mnt on the guest and then link what I need in the host home dir. Jun 9, 2015 at 9:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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