0

I would like to run a desktop Ubuntu VM on top of (desktop or server) Ubuntu host; all the while looking like it is running on the bare metal. The reason for this is I would like to relegate critical processes to the host machine; where I can not disrupt their operation (I could, but I would have to specifically log in to the host system to do that; and most of the time I will be working in the VM instead) and where they won't be troubled by such things as system restarts.

I'd like to use KVM virtualization, as that's what I'm familiar on the server.

I think I'll need VGA passthrough for near-native performance? Can I do that on a laptop with just an integrated Intel graphics card?

I prefer command-line solutions that can be automated.

Nickolai Leschov
  • 8,120
  • 19
  • 49
  • 90

2 Answers2

0

You are looking for Linux Containers:

Containers are a lightweight virtualization technology. They are more akin to an enhanced chroot than to full virtualization like Qemu or VMware, both because they do not emulate hardware and because containers share the same operating system as the host. Therefore containers are better compared to Solaris zones or BSD jails.

LXC is very lightweight, so it's most common application is to have a container for each service. This means you can save up on a lot of space and other resources, since nothing is allocated unless needed. However, that doesn't mean it's the only way to use it. For example, Docker is a service built on LXC, for packaging and deploying complete apps.

LXc can be used for running GUI apps, or even X itself. This Unix & Linux answer has a guide. Essentially:

  1. Install any requisite drivers on both host and container systems.
  2. Make the device nodes available to the container, creating them via mknod if necessary.
  3. Configure them (the OP did it manually, since udev isn't available in the container).
  4. Start X on an unused VT.

However, in your case, where you want things to Just Work and don't mind using the VM for everything X, you can use KVM with libvirt. Check the official Server Guide.

muru
  • 193,181
  • 53
  • 473
  • 722
  • I will read up on LXC, but more details would be very appreciated. How do you think can I use LXC, I thought it is meant for running individual services with fine-grained control; while I had in mind to lump 'all the stuff' into 'desktop VM' and let it do the desktop graphics while the host machine does no graphics at all. Do you think I can do it this way with LXC? – Nickolai Leschov Jul 27 '14 at 23:36
  • It is most often used for containing individual services, because lxc is lightweight enough that you can have a separate container for each service without really eating up resources. It is possible to run X11 inside lxc, if you pass through the required devices according to http://unix.stackexchange.com/questions/18003/linux-lxc-deploying-images-with-tiniest-possible-x11 - but in your specific case, I suppose using `libvrt`+KVM would be simpler: https://help.ubuntu.com/lts/serverguide/libvirt.html – muru Jul 27 '14 at 23:45
  • This answer does not address the main point of the question, which was running the Ubuntu desktop in a VM. Passthrough is not possible since the user only has a single video card, so there will be a significant performance hit. – bain Jul 28 '14 at 11:20
  • @bain that maybe true for traditional virtualization software like VirtualBox, but not for lxc, from my reading of the Unix & Linux answer I linked to above. – muru Jul 28 '14 at 11:24
  • @bain This is not passthrough in that the lxc container uses that device exclusively. If you think so, you have missed the whole point of lxc. – muru Jul 28 '14 at 11:26
  • @bain "Passthrough is not possible since the user only has a single video card" Do you have a source for that? Are you sure this bit of information is not just the assumption that the machine should _always_ have a video card? There are servers that don't contain one, and I would be ok if dom0 could run without one. – Nickolai Leschov Jul 28 '14 at 15:28
  • @NickolaiLeschov For lxc it should not matter (as muru has pointed out), because lxc is not really a VM, just a bunch of isolated processes that run on your existing host, so you can run multiple Xorg processes if they have access to the right devices. For Xen and KVM, it is a general advice - you could try running dom0 headless (eg. serial port or network console); I have not heard of anyone doing it, but in theory it should work. – bain Jul 28 '14 at 18:36
  • @bain Yes, that's the impression I got too: they say on the forums that you cannot have VGA passthrough with only one graphics card, but I don't see exactly why not: after all, headless servers do exist! I guess the first step would be to figure out [hwo to install headless Ubuntu](http://askubuntu.com/questions/503848/how-do-i-run-ubuntu-in-headless-mode) and then go from there. As for LXC, it would be great if you told me how to proceed installing an X server on LXC. Could I have a full desktop environment on top of that; can I just install `ubuntu-desktop`? – Nickolai Leschov Jul 28 '14 at 19:46
  • Installing Ubuntu is a single command with lxc-create, very easy, I have never tried to run Xorg but it should just be a matter of following the instructions in the stackexchange answer. – bain Jul 28 '14 at 22:07
-1

The VM's are intended to appear as bare metal machines. You shouldn't notice any difference except for the restrictions that you actually place on your VM.

You might consider running your VM and posting questions of how to resolve any issue you might encounter. Most likely there will be a resolution to provide specifically what you might need, such as more video memory, lower level access to the hardware, etc.

To boot full screen:

  1. While in your VM OS, of virtual box, select the full screen option.
  2. Right click on the Virtual box profile of your preferred OS and click "Create Desktop Launcher".
  3. Grab the exec command from the created launch and make a batch file such indicated below
  4. Add the created created batch file your Ubuntu startup applications.
  5. Configure (from Ubuntu's user's manager) to boot the Ubuntu with the Automatic Login activated.

Batch file for Startup Applications (mystartvm.sh):

#!/bin/bash                                                                     

sleep 20                                                                        
/usr/lib/virtualbox/VirtualBox --startvm "ec9329a2-d86a-45ba-9dbe-cdd0d8e5c74b"

You can fine tune any step for your preference. I added the 20 seconds to give my machine time to perform the other background tasks that I have setup at boot time.

Of course there are many ways of doing this. This is just one of many.

The Guest OS appears to be on a bare machine. Of course as some pointed out, it really isn't on a bare machine. But the operator (as in making this easy for my clients) can't tell the difference. The OS is ran as if it were on a bare machine and not a guest.

L. D. James
  • 24,768
  • 10
  • 68
  • 116
  • I will try that approach; thanks. But basically I need VM to run full-screen at all times, hardware-accelerated (Unity is normally sluggish in a VM). The host machine does not have to have access to the screen, at all. I don't know where to start configuring system for this kind of setup. – Nickolai Leschov Jul 27 '14 at 21:52
  • I'm sure anyone using VM's will suggest their Visualization program as the easiest. In my case I find Virtual Box to be about as easy as it can get. As far as full screen, my clients who are computer illiterate doesn't have any problems with full screen. Some are running Virtual Box under Linux and don't know it. My support is easier for some of my clients who prefer windows, by having it sit in an Ubuntu VM. Again, the resolution is full screen. If you have problems with Virtual box ask the question and give a link to the question. I'll follow the link and help. – L. D. James Jul 27 '14 at 22:09
  • @James Do VM's on your clients' machines start automatically, in full screen? – Nickolai Leschov Jul 27 '14 at 23:34
  • @NickolaiLeschov Yes it does. I'll edit my answer and add the steps for the Full Screen Virtual Box Boot. – L. D. James Jul 28 '14 at 04:09
  • _"You shouldn't notice any difference"_ The question is asking about running a full desktop in a VM. 3D performance will be degraded, see [these benchmarks of VirtualBox 4.1 OpenGL 3D Guest Performance.](http://www.phoronix.com/scan.php?page=article&item=virtualbox_41_3d&num=2) – bain Jul 28 '14 at 11:17