
I want to tell you about an unusual way to create a multi-user workstation, which is based on VMPlayer.
This solution was developed for commercial use, and as a message to the solution of this problem, it was stated that the current characteristics of the purchased equipment exceed the needs of users and the software they use. Of course, this applies mainly to typical office plankton and many peripheral posts. It will also be useful for solving problems for those who, due to their well-founded reasons, refused or are likely to refuse to update the workstation. Sadly, but it happens ...
In order for the solution to be worthy of application, the following requirements were imposed on it:
- As an operating system for end users, Windows should remain.
- The cost of the system unit for two employees, ideally, should be comparable to the cost of one model, of the acquired at that time.
- The users should not noticeably slow down or be uncomfortable because of the use of one computer.
Well, actually, the business requirements are clear, so it's time to move on to solving ...
Technical part
The development was carried out on a workstation with currently modest parameters - AMD Athlon 64 X2, GeForce GT 440, DDR II 4Gb, HDD 320GB, and although the result was quite acceptable, to meet the above requirements, the following recommendations should be taken into account when choosing the technical component:
- A processor with two cores - each VM is allocated one at a time, and of course the support of modern virtualization technologies is desirable, then we can expect performance close to the “iron” workstation.
- RAM is not a particularly expensive component, so it’s better, without regret, to calculate 3Gb for each workplace, plus 1 Gb for the host system. But in certain situations it is quite possible to manage with 1.5 Gb for each location.
- The hard disk on which the virtual machine will be located, it is desirable that it be separate for each workplace, this will give I / O independence and virtual machines will interfere less with each other. This requirement can be omitted if the goal of cost savings is a higher priority.
- The motherboard , preferably, should already be with two video outputs, this eliminates the need to purchase a separate video card. But, if you have a desire to use your video card and / or there are no video outputs on the motherboard, then you can use, of course, the external one.
There are a few comments on the periphery, namely, monitors, keyboards and mice, and although at first glance they are somewhat strange, their implementation will not be easy and costly, which is important for meeting the requirements for the solution.
- Monitors . When choosing monitors, please note that motherboards with DVI and VGA video outputs do not support DVI-> VGA adapters. Therefore, you need to make sure that the available monitors and video outputs match each other.
- Keyboard and mouse . This is probably not a comment, but more of a limitation to the choice of these HID devices. First, all devices must be USB. Secondly, the VID: PID of one keyboard should not coincide with the VID: PID of another. The same condition is imposed on the mouse. In simpler terms, the keyboard models should be different, and the mouse models should also be different. This limitation is related to the fact that VID and PID are used to distribute devices between virtual machines, and the ability to connect identical models has not been studied, since this condition is not difficult.
For example, here’s the configuration that we took as the standard for our dualseats:
Intel Core i3, MB (DVI + VGA, Audio, GLan), HDD 500Gb x 2 .
')
So, the technical part explained and justified. Now move on to the software stuffing and the principle of operation.
Training
Well, let's get started. To create a dualseat, we need to prepare a few basic components.
Platform
The first step to create a platform for dualseat is to install Ubuntu Server 12.04 x64. After a fairly trivial installation of the system, we deliver packages that will ensure the functioning of the remaining components, and at the same time some useful utilities:
apt-get install ...apt-get install unclutter xinput libxcursor1 mc openssh-server binutils gcc x11-xserver-utils x11vnc xinetd alsa-base alsa-utils vim nodm fluxbox tofrodos ntfsprogs
If required, install video card drivers.
After installation, we configure the system so that its launch is transparent to the user, and the graphic design of the host system itself is not conspicuous, and it is even better that it is completely absent.
Let's start with the configuration of nodm, which is designed to automatically start the X session, immediately at system boot time:
/ etc / default / nodm/ etc / default / nodm NODM_ENABLED=true NODM_USER=vm NODM_XINIT=/usr/bin/xinit NODM_XSESSION=/etc/X11/Xsession NODM_X_OPTIONS='vt7 -nolisten tcp' NODM_MIN_SESSION_TIME=60
Now we will configure the window manager to organize an empty workspace. To do this, set the following parameters in the settings of fluxbox:
/home/vm/.fluxbox/init/home/vm/.fluxbox/init session.screen0.toolbar.visible: false session.screen0.workspaces: 1
The operating system is prepared, and as Lyolik from the movie “The Diamond Arm” would say - “Chef, mustache is ready, the system is loaded without noise and dust.”
Next, download the latest version of VMPlayer from the official VMWare site. Installation is quite simple, but it may require
installing a patch immediately after installation, if the vmplayer does not start. But, to achieve maximum responsiveness of virtual machines, we will
small system tuning and hypervisor/ etc / vmware / config mainMem.useNamedFile="FALSE" tmpDirectory="/run/shm" prefvmx.useRecommendedLockedMemSize="TRUE" prefvmx.minVmMemPct="100"
/etc/sysctl.conf vm.swappiness=0 vm.overcommit_memory=1 vm.dirty_background_ratio=5 vm.dirty_ratio=10 vm.dirty_expire_centisecs=1000 dev.rtc.max-user-freq=1024
/ etc / fstabThe size value depends on the amount of installed RAM, and cannot be less than the amount allocated to both virtual machines plus 1 Gb. This will be due to the tuning conducted below.
tmpfs /run/shm tmpfs size=8G
System environment
Now you need to prepare the system environment: create a user and a couple of folders.
- vm is the user who will log in to nodm and from which the virtual machines will be launched.
- / home / vm / user01 and / home / vm / user02 - folders for users' virtual machines. In case the system is prepared with two hard disks, the second hard disk should be mounted into one of these folders.
Virtual Jobs
Creating a virtual machine and installing systems will leave you at the mercy, I think this process is familiar to most readers. But a few recommendations will still be, since the goal is to create a comfortable user experience.
- Virtual disks should be SCSI, no matter what the system will be, and in no case should you choose an IDE, since you will get a very inefficient virtual disk subsystem.
- Unused hardware (Printer, Floppy disk, Serial port, etc.) should be removed from the virtual machine configuration.
- VMWare Tools is a must-have for the guest to work efficiently.
Some important conventions for the scripts below:
- The names of both vmx files are expected to be workstation.vmx.
- The virtual machine names must be user00 and user01, respectively.
After the virtual workstations are prepared and located in their places, we will tune them, again squeezing the maximum performance.
/home/vm/user00/workstation.vmx and /home/vm/user01/workstation.vmx/home/vm/user00/workstation.vmx and /home/vm/user01/workstation.vmx mem.ShareScanTotal=0 mem.ShareScanVM=0 mem.ShareScanThreshold=8192
All components are prepared and optimized, it remains to put everything together and add a couple of strokes.
System startup configuration
To start the dualseat, use
/home/vm/.fluxbox/startup
, the contents of which, consistently and commenting, I quote further (note the settings of the monitors).
/home/vm/.fluxbox/startup/home/vm/.fluxbox/startupDisable all system attempts to "put out" the screen: xset -dpms xset s off setterm -blank 0 setterm -powerdown 0
By default, a system with two monitors runs in clone mode, this is when we see the same picture on both monitors. To configure the correct display, we will use the xrandr
utility (instead of the configuration in xorg.conf
).
To obtain the available resolutions for each monitor, use the xrandr -q
command. You need to pay attention to the fact that the DVI output system is shown as HDMI.
Both monitors are set up at the moment fluxbox is launched, the following lines are used for this (the order of the lines is important), in which you must have your own values:
We do not need the system cursor, and by itself it remains always visible, therefore we “extinguish” it in this way. unclutter -idle 1 -root &
Now the launch of the graphical shell and immediately after it the launch of the virtual machines themselves exec fluxbox & fbpid=$! sleep 1 { /home/vm/user00/start &
The following are the startup scripts for the virtual machines themselves, where it is first checked whether the target machine is already running. The launch itself, followed by the
check_shutdown
script, which will be executed immediately after the VM is turned off. It is needed to check the need to turn off the computer when you turn off both workplaces.
Virtual Machine Startup Scripts/ home / vm / user00 / start if ps ax | grep -v grep | grep -P "vmplayer.*user00" > /dev/null then exit else /usr/bin/vmplayer -X /home/vm/user00/workstation.vmx && /home/vm/check_shutdown & fi
/ home / vm / user01 / start if ps ax | grep -v grep | grep -P "vmplayer.*user01" > /dev/null then exit else /usr/bin/vmplayer -X /home/vm/user01/workstation.vmx && /home/vm/check_shutdown & fi
/ home / vm / check_shutdown if ps ax | grep -v grep | grep vmplayer > /dev/null then exit 0 else sudo shutdown -h now fi
To execute the
sudo shutdown
without entering a password, you need to add a line to the
/etc/sudoers
:
vm ALL=NOPASSWD: /sbin/shutdown
Insulation
Now we proceed to the isolation of resources between jobs.
Monitors
To start the virtual machines, each on its monitor, we use the capabilities of the fluxbox window manager, where the rules for the location of virtual machines at the time of launch are specified in the file
/home/vm/.fluxbox/apps
.
Please note that VMPlayer is launched minimized, this is done so that the user does not see the launch of the VMPlayer shell. But in order for this effect to work to the end, you need not to forget to tick the option
“Enter full screen mode after powering on” in the
gui.viewModeAtPowerOn = "fullscreen"
settings or, equivalently, set the parameter
gui.viewModeAtPowerOn = "fullscreen"
in
workstation.vmx
.
If you have an NVidia or Radeon video card and you have installed the drivers, then you can fully use the 3D acceleration function in the virtual video device by ticking the
“Accelerate 3D graphics” option. In
workstation.vmx
, the
mks.enable3d = "TRUE"
parameter is responsible for this.
Keyboards and mice
To distribute these HID devices, VMPlayer is used to capture USB equipment in exclusive use. Before allocating devices, we find out their VID and PID using the utility
lsusb
. After all the device identifiers are clarified, we set the following parameters in each
workstation.vmx
.
/home/vm/user00/workstation.vmx and /home/vm/user01/workstation.vmx/home/vm/user00/workstation.vmx and /home/vm/user01/workstation.vmx
USB
All USB devices can be divided into two categories: permanently connected and plug-in during operation.
There are no problems with permanently connected ones, they are registered in the corresponding workstation.vmx, by analogy and with the help of the same parameter
usb.autoConnect.device
N
and the
lsusb
utility that were used when connecting the mouse and keyboard.
There are two options for connecting USB devices during operation. The first option is when all USB devices prokibyvayutsya only on one machine. To do this, in the workstation.vmx file of this machine, set the parameter
usb.generic.autoconnect=TRUE
, and in the other,
usb.generic.autoconnect = "FALSE"
respectively.
The second option that allows you to distribute USB devices during connection by the users themselves is to use the USB over IP technology. Although this method may be somewhat costly, but it solves the problem. The problem is solved as follows: the server side is put on the host, which shares USB devices, and the client is put on the guest system. Unfortunately, the opensource
usb / ip project turned out to be a raw and acceptable result. With urgent need, you can use commercial products, for example, we used
this one : USB Redirector for Linux (this part is free) and USB Redirector Client (this one is worth the money).
Finishing touch
For completeness, the following scenarios should work:
- When you turn on the system unit, the virtual machines start automatically.
- Each of the workplaces can be turned on and off, even if the neighboring workplace is working.
- When you turn off all jobs, the system unit should turn off.
Paragraphs 1 and 3 are implemented using the scripts above. Point two is partially implemented. When you turn off one of the virtual machines, the second will work. But how to turn the machine back on? The question is solved very elegantly: for this, we hang a command to start the virtual machines on the Power button (this is the one on the system unit). To do this, in the file
/home/vm/.fluxbox/keys
write several lines:
/home/vm/.fluxbox/keys/home/vm/.fluxbox/keys 124 :Exec /home/vm/user00/start & /home/vm/user01/start 133 :Exec /home/vm/user00/start & /home/vm/user01/start
After this configuration, the user will turn on his machine in the usual way.
Result
I tried to state the decision completely, but I omitted some of the details so as not to clutter up an overgrown article, I hope they will not hurt to assemble my dualseat, and if you really have such a desire, I am ready to answer all the questions arising during the assembly process.
Despite the fact that many of the settings and techniques are already ready to use, their search was not a trivial task, so I hope that the article will also be useful for those who find the solution unacceptable for their unconditionally justified reasons.
How it works for us
The solution really works. Build dualseat'a actually minimized. After installing the system, the script installs additional packages, vmplayer and copies all the mentioned configs and scripts. Virtual machines are simply replicated using the “golden template”. In the end, a little refinement is required: set the correct resolutions for the monitors, connect fixed devices and configure USB operation.
Responsiveness of the system is more than acceptable for most of our employees. Of course, we do not do general application, but we have closed many questions on the organization and renewal of workplaces for which this solution is the best.
Thank you all for your attention, I hope it turned out interesting.