Step 2: Configuring the VirtualBox VM on the HostAt the time of writing, the current version of VirtualBox (v6.1.12) does not have GUI support for configuring the LPT settings of the VM, you must instead use the VBoxManage command in a terminal window (command console). Users of Windows hosts often have difficulty understanding how to use a command line: just open the command console (cmd.exe), change to the VBoxManage folder by typing
cd "c:\Program Files\Oracle\VirtualBox" (note the double quotes around the path string, since it contains a space), and then you can type the additional commands shown below :-
General command syntax (fields in < > brackets are placeholders, the brackets are not literal):
- Code: Select all Expand viewCollapse view
VBoxManage modifyvm <VMname> --lptmode1 <host LPT device name>
VBoxManage modifyvm <VMname> --lpt1 0x378 7
Windows Host Example (where the host port I want to use is called "LPT4"):
- Code: Select all Expand viewCollapse view
VBoxManage modifyvm "My VM Name" --lptmode1 "LPT4"
VBoxManage modifyvm "My VM Name" --lpt1 0x378 7
Linux Host Example equivalent to above:
- Code: Select all Expand viewCollapse view
VBoxManage modifyvm "My VM Name" --lptmode1 "/dev/parport3"
VBoxManage modifyvm "My VM Name" --lpt1 0x378 7
All of the above examples configure a virtual LPT1 inside the guest. Of course you could configure another guest port instead, but there isn't much point in doing so hence I have ignored that possibility in the instructions.
The above also tells VirtualBox which host port you want to use. VirtualBox does not check at this point that the host port actually exists. Nor does it guarantee that your host OS will allow VirtualBox to use that port. In particular, if you install a parallel port printer driver on the host, and if that driver opens the parallel port when the host starts up, then that port
may not be available for the guest to use (it depends on the driver). Parallel ports are legacy devices which were never designed to be shared, only one application (or driver) at a time can "own" the port.
Step 2a: Additional Notes for Linux HostsVirtualBox may be blocked from accessing the parallel port due to permission issues. Make sure that your user name is in the lp and lpadmin group on the host. Remember to log out and in again for permission changes to "take".
You may find that you still can't access the printer because the kernel is already using it. You'll get a message to the effect "could not claim parallel port". I'm told that the solution is to unload the "lp" module from the kernel, e.g. using "sudo modprobe -r lp".