Page 1 of 1

Tutorial: better integration of VirtualBox (Windows) into MX Linux (guide in steps)

Posted: Thu Jan 21, 2021 8:37 am
by Duliwi
What will be the benefit, when anybody has implemented these steps?


A) Opening for example a "Microsoft Word"-file (or any other Windows file-typ) in thunar with "double click":


-Without this tips: We must start VirtualBox. After we have to choose and start our VM. Then we have to wait until the VM is booted. This takes a while. Then we have to start "Windows Explorer" and search the Word-file, we want to open. Then we can double click it.

-When these tips are implemented: You just open thunar (in Linux). Search your file and double click it. Done.
Then automatically the right VM starts and the Word-file will be opened with "Microsoft Word". (Windows must not boot, because it was in save state. So this way Windows will be ready faster.) This not only works with word-files, but this works with any file for which a program is installed in the Windows VM.

-Also when you are surfing in the internet with Firefox and have a link to a word document (or any other file-typ that needs a program, that you have in your VM), then just click "open" in Firefox and it will automatically start in your VM with the matching windows program.
-Same, when you want to open for example a *.docx file attachment in Thunderbird.
-Simlinks can also be opened the same way.



B) Starting for example "Microsoft Word" (or any other Windows-Program):

-Without this tips: We must start VirtualBox. After we thave to choose and start our VM. Then we have to wait until the VM is booted. This takes a while. After, we have to look for the "Microsoft Word" starter in the VM and start it.

-Starting "Microsoft Word" when these tips are implemented: You will have a "Microsoft Word" starter in Linux. The starter can be on the desktop, in the menu or in the panel. The only thing you have to do, is to click on this starter. Done.
Then automatically the right VM starts and "Microsoft Word" starts. (Windows must not boot, because it was in save state. So this way Windows will be ready faster. Edit: But it also works, if you shut your PC down.)

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

"How to do"-guide in steps (for variant A) from above):

0. Pre-requisite: You have already a Windows VM with your prefered Windows programs. For this description I have used "Windows 7 32bit" and as windows programs "Office 2010". (I assume that it also works with other versions of windows. And with any windows-programs.)
Please note: This is an implementation for MX Linux 19.3 Xfce.

1. Steps you have to do with "windows user password":
Give your windows account a password (this is mandatory):
a. Start your windows VM
b. press WindowKey+R
c. type in: compmgmt.msc
d. open the Users folder in Local Users and Groups
e. Right-click your user account and choose Set Password.
f. Proceed to continue
g. Enter a new password, reenter it and click OK.

This is also needed:
h. press WindowKey+R
i. type in: gpedit.msc
j. Navigate to -> Computer Configuration\Windows Settings\Security Settings\Local Policies\Security Options
k. Change -> "Accounts: Limit local account use of blank passwords to console logon only" to "disabled".

This is needed so that you need not to type in manually your password, when you have shut down your VM instead of using the "save state" mode:
l. start your Windows-VM an log you in.
m. Press Win + R, enter netplwiz and press Enter. This opens the dialogue box for user accounts.
n. In the ‘User accounts’ dialogue box, select the user account that is to be logged in automatically.
o. Deactivate the option Users must enter user name and password and click on Apply.
p. Another dialogue box appears in which you must enter the user name and password of the account that is to be logged in automatically. Enter the password twice and confirm with OK.
q. Close all open dialogues with OK.
r. Shut down your VM.

2. VirtualBox: Set up "shared folders":
a. open VirtualBox Manager
b. right click on your Windows VM
c. choose "change" -> tab "shared folders"
d. add a new folder with path "/tmp" (this is necessary when you later click in Firefox on a "MS Word" link. So that this *.docx can be opened automatically in your Win-VM; Or when you have an attachment in Thunderbird, you want to open.)
e. check "Integrate automatically" and "only readable"
f. Embedding point "H:"
g. add a new folder with path "/home/MyUsername" (replace "MyUsername" with your Linux-account name). This is the place where all your files are, that you wont to be able to open directly with double clicking in thunar (See "A)" above). When your files, that you want to open in with windows programs, are all in a particular folder, then you can choose here this particular folder.)
h. check "Integrate automatically" and leave unchecked "only readable"
j. Embedding point "G:"


3. Start your VM
4. choose -> menu -> view -> "Full screen mode"
5. choose -> menu -> view -> Seamless mode
6. Change to "Oracle VM VirtualBox Manager"
7. Menu -> machine -> close -> "save state" (You must always close this VM this way. This is something like "hibernate" in Windows. It makes, that your VM will start faster.
8. Copy the attached file "Windows7VM.sh" into "/home/YourUserName/.bin/" (Replace YourUserName with your user name. If you do not have this folder, create it.)

In the file "Windows7VM.sh" you have to replace some lines:
Line 3: replace "Win7NeuFurOfficeVersuch" through the name of your VM. You find the name of your VM in the "Oracle VM VirtualBox Manager". It's the bold part of the name at the left side of the window.
Line 10: replace "/home/user/" through the path that you have set up in 2.g. (see above)
Line 31: replace "WindowsAccountName" through the "account name" of your windows in your VM. (Pardon, what name exactly? When you normally start windows, you have to log-in and your account name is shown. This is the name, you have to take here.)
Line 32: replace "MyPassword" through your windows password of your "windwos account" you have set up in 1.g. (see above)
Line 42: replace "Win7NeuFurOfficeVersuch" through the name of your VM. You find the name in "Oracle VM VirtualBox Manager". It's the the bold part of the name at the left side of the window.
Line 50: replace "Win7NeuFurOfficeVersuch" through the name of your VM. You find the name in "Oracle VM VirtualBox Manager". It's the the bold part of the name at the left side of the window.
Line 55: replace "Win7NeuFurOfficeVersuch" through the name of your VM. You find the name in "Oracle VM VirtualBox Manager". It's the the bold part of the name at the left side of the window. And replace "MyUsername" through your "Windows user name". And replace "MyPassword" through your "Windows password".

Edit: To bring it into work with MX-23 Xfce and VirtualBox 7.0.16 you have to change the following line:
--exe "%SystemRoot%\system32\cmd.exe"
through ...
--exe "C:\Windows\System32\cmd.exe"

9. Make the file "Windows7VM.sh" executable, if it is not already executable. (Right click on the file-> properties-> Tab "rights")
10. Copy the attached file "Windows7-VM.desktop" to the folder "/home/user/.local/share/applications/" (replace user to your Linux user-name)

In this "Windows7-VM.desktop" you have to replace
Line 3: "User" through your Linux user name.

Variant A) (see above) should now work.


How to use it?
-open thunar
-go to the file you want to open in your VM (This file must be in a folder, that is entered in VirtualBox as "shared folder". See above "point 2")
-make a right click on it -> "open with" -> "Open with another application"
-check "Use by default for files of this type"
-choose "windwos7 VM" from the list

---------------------------------------------------------------------------------------------------------------------------------------------------------------

Additional steps for B)

(Please note: This "steps for B)" only work, when you also have implemented all steps above.)

Just download the attached "Microsoft starters" for Linux.
Copy them to the folder "/home/user/.local/share/applications/Windows_VM_Programs/" (Replace "user" through your "Linux user name")
Open each of this starters in Featherpad and replace in the line

Code: Select all

Exec=/home/user/.bin/Windows7VM.sh "C:\\Program Files\\Microsoft Office\\Office14\\Winword.exe"
"user" through your "Linux username".

Copy the attached file "VirtualBox-VM-Programs.directory" into the folder

Code: Select all

/home/user/.local/share/desktop-directories/
(replace user)

Copy the attached file "VirtualBox-VM-Programs.menu" into the folder

Code: Select all

/home/user/.config/menus/applications-merged/
(replace user)


-> Now you will have this starters in your Whisker menu (Category VirtualBox-VM-Programs)
(Thank you for your kind help @dolphin_oracle)

Just download in addition the attached icons to get Microsoft Symbols for your starters.
Copy them into the matching folders:
/home/user/.local/share/icons/hicolor/16x16/apps/
/home/user/.local/share/icons/hicolor/32x32/apps/
/home/user/.local/share/icons/hicolor/48x48/apps/
/home/user/.local/share/icons/hicolor/96x96/apps/
/home/user/.local/share/icons/hicolor/128x128/apps/

---------------------------------------------------------------
Main source for this guide: https://unix.stackexchange.com/question ... rough-virt



FAQ:


Question: What do I have to do, when I want to open for example an *.pdf file with the newest "Foxit Reader" with right click in thunar? (https://www.foxitsoftware.com/downloads/)
Answer: You have already implemented all you need for this. The only thing you need, is to link the file typ *.pdf with "windwos7 VM". See above section "How to use it?" .


Question: What do I have to do, when I want to start "Foxit Reader" with a starter. I have no starter for this?
Answer: Just open one of the attached "Microsoft starters" in Featherpad and you see how such a starter works. Then you can replace the lines

Code: Select all

Name=Word VM
Exec=/home/user/.bin/Windows7VM.sh "C:\\Program Files\\Microsoft Office\\Office14\\Winword.exe"
Icon=0575_wordicon.0

Question: How can I open an attachment in Thunderbird with a programme that is in the Windows VM?
Answer: You have already created the preconditions in step 2. d) above and with the existing section in "Windows7VM.sh" that looks like this:

Code: Select all

# /temp/ is mounted as H:
original=$fixedFilePath
findWhat="/tmp/"
replaceWith="H:\\"
fixedFilePath="${original/$findWhat/$replaceWith}"
Assumed you have an *.docx attachment in an E-Mail in thunderbird, you can make this additional steps:
1. Open Thunderbird
2. open menu -> edit -> settings -> general -> File & attachments
3. In the list go to the entry (Microsoft Word Document: application/vnd.openxmlformats-officedokument.wordprocessingml.document) and on the right side select "use other"
4. Go to "/home/YourUserName/.bin/" and open "Windows7VM.sh"
5. It's now selected in the column "Action"
6. When you click on it, you can see, that it is now in the list.
7. Select now in this list "always ask"
8. Close the settings tab
5. Go to your mail with the *.docx attachment
6. click or double click it
7. Check the option "open with"
8. select "other"
9. "Windows7VM.sh should be now in the list right of "open with"
10. select it, wait some seconds until the OK button is activ and then open it. Done.

-> Please not: It can be, that you do not have the fitting entry in "menu -> edit -> settings -> general -> File & attachments".
In this case the fist thing (step 0) you have to do, is to open (in this case) the *.docx document with any programme. For example LibreOffice or whatever programme is offered for you. This way thunderbird generates automatically a fitting entry in "menu -> edit -> settings -> general -> File & attachments". This means, after this step "0" you will have an additional entry in "menu -> edit -> settings -> general -> File & attachments" and you can continue with step 1 above.


Question: Should I "shut down" my Windos VM, when I am done?
Answer: No. First close all open windows programs in you VM. Then put the VM into the "save state". For example this way: Go to "Oracle VM VirtualBox Manager"; Menu -> machine -> close -> "save state" . You also can make a "key combination" for this:
-> Xfce settings -> keyboard -> tab "short keys for programs" -> add -> Command:

Code: Select all

VBoxManage controlvm "Win7NeuFurOfficeVersuch" savestate
(replace "Win7NeuFurOfficeVersuch" through the name of your VM.)
Edit: But yes, if you want, you can alternatively shut down the VM. It can be, that the start will need a bit longer with this method.


Question: When I set my VM into "save state" is my VM then still running in the background?
Answer: No. It's not "sleeping" or "standby" or "pause". It's more something like "hibernate" in Windows. I guess, it also saves the content of your RAM on the HD, so that the VM is able to start faster again.





.

Re: How to do guide: better integration of VirtualBox into MX Linux

Posted: Thu Jan 21, 2021 8:39 am
by Duliwi
Here are the icons

Re: Tutorial: better integration of VirtualBox into MX Linux (guide in steps)

Posted: Thu Jan 21, 2021 9:23 am
by jonnken
Perhaps the task of learning LibraOffice...is less than figuring out and operating a virtual box? With LibraOffice you're able to work and save seamlessly with all type Word type files. No more worries about compatibility with this or that. Most methods in LibraOffice are quite similar to the MS Word environment. The learning curve is not that steep from Word to LibraOffice.

Re: Tutorial: better integration of VirtualBox into MX Linux (guide in steps)

Posted: Thu Jan 21, 2021 9:56 am
by SwampRabbit
Nice tutorial, its on the list of things to check out, thanks for sharing.

jonnken wrote: Thu Jan 21, 2021 9:23 am Perhaps the task of learning LibraOffice...is less than figuring out and operating a virtual box? With LibraOffice you're able to work and save seamlessly with all type Word type files. No more worries about compatibility with this or that. Most methods in LibraOffice are quite similar to the MS Word environment. The learning curve is not that steep from Word to LibraOffice.
I think the use of Word was just an example, they did state "or any other Windows-Program".
While I like LibreOffice, creating or editing MS Office documents without then checking if they look and act fine in actual MS Office, usually leads to trouble. When it comes to MS Office documents I need for work, I stopped relying on LibreOffice really. It is not fun to be in a meeting and someone opens up your PowerPoint slides or a Word document and the format is all messed up.

I find this very interesting and see how it can come in handy for many things. Using WINE is good, but this method Duliwi is sharing also lets you open and execute files inside a VM and not directly on your system. Would be interesting to see what people adapt and use this for.

Re: Tutorial: better integration of VirtualBox into MX Linux (guide in steps)

Posted: Thu Jan 21, 2021 11:25 am
by jonnken
My use of LibraOffice is mostly personal and I know the cross formatting can be an issue. I do know that the LibraOffice spreadsheet crashes more than Excel did for me. But overall LibraOffice seems better for me, than figuring out and operating with the additional virtual machine elements. Oh, the great versatility of Linux.

Re: Tutorial: better integration of VirtualBox into MX Linux (guide in steps)

Posted: Thu Jan 21, 2021 11:44 am
by Duliwi
@jonnken
As @SwampRabbit has said.
-> This tutorial is for any windows-program for which anybody has not found a replacement or is not willing to use a replacement.

Re: Tutorial: better integration of VirtualBox into MX Linux (guide in steps)

Posted: Thu Jan 21, 2021 11:44 am
by andyprough
Duliwi wrote: Thu Jan 21, 2021 8:37 am What will be the benefit, when anybody has implemented these steps?


A) Opening a for example "Microsoft Word"-file (or any other file-typ) in thunar with "double click":


-Without this tips: We must start VirtualBox. After we have to choose and start our VM. Then we have to wait until the VM is booted. This takes a while. Then we have to start "Windows Explorer" and search the Word-file, we want to open. Then we can double click it.
Very interesting, I did not know this was possible. Have you run into any trouble with it? Any breakage of Windows or corruption or loss of files?

I'd like to try it, but don't want to risk losing any files or breaking Windows in order to gain the convenience.

Re: Tutorial: better integration of VirtualBox into MX Linux (guide in steps)

Posted: Thu Jan 21, 2021 11:51 am
by Duliwi
@andyprough
If you want to be on the safe side, you can first take a snapshot of the current state of your VM in VirtualBox:
Oracle VMVirtualBox Manager -> snapshot -> take...

Re: Tutorial: better integration of VirtualBox into MX Linux (guide in steps)

Posted: Thu Jan 21, 2021 11:56 am
by jonnken
Duliwi wrote: Thu Jan 21, 2021 11:44 am @jonnken
As @SwampRabbit has said.
-> This tutorial is for any windows-program for which anybody has not found a replacement or is not willing to use a replacement.
Yes, the more I look over what you're working on...the more I see it's broader applications and potential. The MS Windows compatibility with Linux is the major roadblock that keeps a good many users away. But to have a more seamless integration thru virtual box...would indeed have real value to lots of people.

Re: Tutorial: better integration of VirtualBox into MX Linux (guide in steps)

Posted: Thu Jan 21, 2021 11:56 am
by andyprough
Duliwi wrote: Thu Jan 21, 2021 11:51 am @andyprough
If you want to be on the safe side, you can first take a snapshot of the current state of your VM in VirtualBox:
Oracle VMVirtualBox Manager -> snapshot -> take...
I know how to be on the safe side with snapshots and cloning, that was not my question. Really I want to know - have you experienced any breakage or corruption or any negative consequences?

Re: Tutorial: better integration of VirtualBox into MX Linux (guide in steps)

Posted: Thu Jan 21, 2021 12:52 pm
by Duliwi
@andyprough
I have not used it a lot until now.
But no, I have not corrupted my linux.
I have not lost a file.
I have not corrupted my Windows.

The only thing you have to look at is:
When you have started a lot of programs in your VM this way, in your "windows task manager" you will find several processes ""VBoxService.exe" and "conhost.exe".
So from time to time, maybe when you have used the VM 15-30 times, you have to close this processes in your "windows task manager". Or you can "shut down" your VM from time to time, instead of bringing the VM into "save state".

Re: Tutorial: better integration of VirtualBox into MX Linux (guide in steps)

Posted: Thu Jan 21, 2021 3:41 pm
by andyprough
Seamless mode increases the CPU and overall resource usage substantially - for this reason alone I probably won't try the steps of this tutorial. What's your experience with CPU usage when running Virtualbox in this manner?

Re: Tutorial: better integration of VirtualBox into MX Linux (guide in steps)

Posted: Thu Jan 21, 2021 4:21 pm
by Duliwi
It takes about the same amount of CPU like Wine does.
But of course: It takes much more RAM then Wine.

HTop with closed VirtualBox and closed VM:
CPU, RAM without VirtualBox.jpg

HTop with MS Word started in VB "Seamless mode" -> "IDLE":

Something between:
CPU, RAM after VirtualBox MS Word idle.jpg
and
CPU, RAM after VirtualBox MS Word idle 2.jpg

My System:
8 GB RAM.
Intel i5 Generation 4

(I don't want to force you to try this out.)

--------------------------------------------

Please note: In the file

Code: Select all

Windows7VM.sh
there is a line

Code: Select all

VBoxManage guestcontrol "Win7NeuFurOfficeVersuch" start ...
There would be an alternative command. It is

Code: Select all

VBoxManage guestcontrol "Win7NeuFurOfficeVersuch" run ...
The difference is the command start vs. run. When I take "run" instead of "start", then my cpu cores are permanently at 60% when the PC is idle.
So please let "Windows7VM.sh" unchanged and use the command "start".

Re: Tutorial: better integration of VirtualBox into MX Linux (guide in steps)

Posted: Thu Jan 21, 2021 4:25 pm
by andyprough
That's pretty good actually. MS Office on Wine and seamless mode Virtualbox normally make my machine run at between 25-50% CPU with some higher spikes. The fact that you are using Win7 and Office 10 may be helping - I'm using Win10 and Office 365.

Re: Tutorial: better integration of VirtualBox into MX Linux (guide in steps)

Posted: Thu Jan 21, 2021 4:36 pm
by Duliwi
As said: It's when it's idle.
What PC machine do you have (hardware)?

Re: Tutorial: better integration of VirtualBox into MX Linux (guide in steps)

Posted: Fri Jan 22, 2021 8:10 am
by Duliwi
Duliwi wrote: Thu Jan 21, 2021 12:52 pm @andyprough
The only thing you have to look at is:
When you have started a lot of programs in your VM this way, in your "windows task manager" you will find several processes ""VBoxService.exe" and "conhost.exe".
So from time to time, maybe when you have used the VM 15-30 times, you have to close this processes in your "windows task manager". Or you can "shut down" your VM from time to time, instead of bringing the VM into "save state".
-> It's solved with an update of "Windows7VM.sh".
No more need to close this processes in your "windows task manager" or to "shut down" your VM from time to time.

Re: Tutorial: better integration of VirtualBox into MX Linux (guide in steps)

Posted: Fri Jan 22, 2021 12:30 pm
by jonnken
andyprough wrote: Thu Jan 21, 2021 4:25 pm That's pretty good actually. MS Office on Wine and seamless mode Virtualbox normally make my machine run at between 25-50% CPU with some higher spikes. The fact that you are using Win7 and Office 10 may be helping - I'm using Win10 and Office 365.
It's the real "beauty" of Linux...low CPU usage. When I have a 500 row (100 column) spreadsheet open in LibraOffice, my CPU usage (Dell Optiplex 755) will just sit down around 2%. It spikes to 30-40 on task demands and then right back down. For the most part it just sits there in wait for the next commands.

Re: Tutorial: better integration of VirtualBox into MX Linux (guide in steps)

Posted: Fri Jan 22, 2021 4:55 pm
by andyprough
Duliwi wrote: Thu Jan 21, 2021 4:36 pm As said: It's when it's idle.
What PC machine do you have (hardware)?
I have a pretty new laptop with fast cpu and lots of ram and fast SSD. I want to tell you, I spent most of today with Virtualbox in Seamless mode, and the CPU usage was not much higher than in non-Seamless mode. I might have to try your steps after all - maybe Virtualbox has managed to improve Seamless mode to not be such a resource hog. Thanks for sharing this info, very useful and interesting.