📜 ⬆️ ⬇️

Multiseat for Windows jobs


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:

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:

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.

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 / fstab
The 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.

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.

Some important conventions for the scripts below:

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 #        sched.mem.maxmemctl=0 sched.mem.pshare.enable = "FALSE" mainMem.useNamedFile = "FALSE" MemTrimRate = "0" MemAllowAutoScaleDown = "FALSE" 

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/startup
Disable 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:
 #      VGA xrandr --output VGA1 --mode 1280x1024 #      HDMI xrandr --output HDMI1 --mode 1920x1080 #  HDMI    VGA xrandr --output HDMI1 --left-of VGA1 #  HDMI   (    ) xrandr --output HDMI1 --primary 

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 & #   VM00 /home/vm/user01/start & #   VM01 } & wait $fbpid 

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 .
/home/vm/.fluxbox/apps
/home/vm/.fluxbox/apps
 #  VMPlayer user00 [app] (title=.*user00.*) #  2 [Head] {2} #   [Deco] {NONE} #   [Minimized] {yes} [end] #  VMPlayer user00 [app] (title=.*user01.*) #  1 [Head] {1} #   [Deco] {NONE} #   [Minimized] {yes} [end] # Other applications [app] (title=.*) [Jump] {no} # [Workspace] {1} [Position] (CENTER) {0 0} [Layer] {12} [end] 

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
 #   vmmouse.present = "FALSE" usb.generic.allowHID = "TRUE" svga.noHWCursor = "TRUE" #   c VID=0458  PID=010e usb.quirks.device0 = "0x0458:0x010e allow" usb.autoConnect.device0 = "0x0458:0x010e" #   c VID=0566  PID=3107 usb.quirks.device1 = "0x0566:0x3107 allow" usb.autoConnect.device1 = "0x0566:0x3107" 

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:
  1. When you turn on the system unit, the virtual machines start automatically.
  2. Each of the workplaces can be turned on and off, even if the neighboring workplace is working.
  3. 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.

Source: https://habr.com/ru/post/153911/


All Articles