How to effectively use a VirtualBox VM on multiple computers? - virtual-machine

My IDE is Eclipse, running in Ubuntu 12.10 inside a VirtualBox VM. I currently work in two locations - one office has a Windows 7 PC, the other has a Mac. It seemed most efficient to move my VM onto a high-speed USB flash drive, then carry it between offices. It hasn't worked out.
I used the PC to copy the VM to the flash drive, and tested it there. It worked. I took it to the other office, plugged it into the Mac, started VirtualBox and tried to boot the VM. It said 'can't find drive at E:...' It expected a Windows drive location. So, I tried removing the disk from the VM and re-mounting it on the Mac. That resulted in a 'UUID already in use' error.
Is this transport method possible? I don't want to have to run sethduuid every time I change offices.

The VirtualBox configuration files contain paths for the virtual hard disks, so copying them to another host is problematic. The simplest solution would be to create two similar configurations, one on each host and just copying the disk file to the external flash drive. Configure the paths to the disk file on each host independently so they fit your platform.
The drawback is, that you have to maintain two configurations. But they shouldn't change that often anyway.
The UUID error happens, if try to add another disk image to the virtual media manager with a UUID that match an already existing disk image. This might be because you copied a disk image in the past without replacing the UUID. Check your disk files for duplicate UUIDs.

Related

Can I run one WSL2 virtual machine instance on two system?

I'm new to the WSL2 and wondering if it's possible to run the same WSL2 ubuntu instance on both my desktop and laptop.
Now I am able to use wsl --export and wsl --import method to save and load the system to/from my portable hard drive. But these methods takes a long time.
I notice that wsl --import load a file named ext4.vhdx. Is there a way to load straightly from this file?
Update v2.0:
I was able to get a workaround and it works great.
Thanks to Booting from vhdx here, I was able to load straightly from my vhdx file on my portable hard disk. Windows track down its subsystem with regedit, So we can write our own(p.s: make sure to get BasePath right, it starts with "\\\\?", or you will not be able to access the subsystem' filesystem on your host system.):
Windows Registry Editor Version 5.00
[HKEY_USERS\【your SID here】\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss\{【UUID here】}]
"State"=dword:00000001
"DistributionName"="distribution name"
"Version"=dword:00000002
"BasePath"="vhdx folder path" 【 e.g. "\\\\?\\E:\\S061\\WSL\\ubuntu-20"】
"Flags"=dword:0000000f
"DefaultUid"=dword:000003e8
I suppose the best way to do this would be to store ext4.vhd on a network storage device accessible to both devices.
I have previosly mentioned how to move ext4.vhd. You can check that out here
Basically you need to export from one machine and import it while making sure the vhd file is configured for wsl to access from the network storage
Since this should *officially* not supported expect some performance hits
Another way would be to run WSL on one computer and ssh/remote desktop to it from another device on the network
I'm of the strong belief that sharing the same ext4 vhd between two VM's simultaneously would be a bad idea. See this and this Unix & Linux StackExchange, including the part about ...
note that sharing LVs/partitions on a single disk between the servers at the same time is NOT very safe. You should only access whole disks from any of the servers at one time.
However, as dopewind's answer mentioned, you can access the WSL instance on one computer (probably the desktop) from another (e.g. the laptop). There are several techniques you can use:
If you have Windows 10 Professional or Enterprise on one of the computers, you can enable Remote Desktop, which allows you to access pretty much everything on one computer from another. RDP ("Remote Desktop Protocol") even works from other devices such as an iPad or Android tablet (or even a phone, although that's a bit of a small screen for a "desktop"). That said, there are better, more idiomatic solutions for WSL ...
You could enable SSH server on the Windows 10 computer with the WSL instance (instructions). This may sound counterintuitive to some people, since Linux itself running in the WSL instance also includes an SSH server (by default). But by SSH'ing from (for example) your laptop into your desktop's Windows 10, you can then launch any WSL instance you have installed (if you choose to install more than one) via wsl -d <distroName>. You also avoid a lot of the network unpleasantness in the next option ...
You could, as mentioned above, enable SSH on the WSL instance (usually something like sudo service ssh start) and then ssh directly into it. However, note that WSL2 instances are NAT'd, so there's a whole lot more hackery that you have to do to get access to the network interface. There's a whole huge thread on the WSL Github about it. Personally, I'd recommend the "Windows SSH Server" option mentioned about to start out with, then you can worry about direct SSH access later if you need it.
Side note: Even though I have SSH enabled on my WSL instances, I still use Windows SSH to proxy to them, to avoid these networking issues.

How to access the windows subsystem for linux 2 filesystem from another computer?

I know that I can access the wsl2 filesystem by just opening \\wsl$ on the local computer. Can I somehow expose this to another computer in the same network? The goal is to just have a network drive on a remote computer where I drop files to copy them directly to wsl2.
EDIT: While it is not exactly what I wanted, I just noticed I can run a FTP server inside wsl2 and just transfer files in and out that way. I am still leaving the question open though as there might be a simpler solution to this.
You can find your home folder of wsl on c drive (its in AppData) and use ordinary windows folder sharing.
You can mount your network storage directly into WSL like in a particular Linux.
Example for Ubuntu and SMB: https://askubuntu.com/a/1050499

How to mount windows volume without letter in "Linux for Windows"

I have the following task:
I installed Linux for Windows in Windows 10 Pro computer;
I installed Ubuntu 18.04 LTS;
I have a separate volume in Windows computer, which doesn't have a drive letter assigned to it;
I need to find a way to mount this Windows volume without letter in WSL Ubuntu.
I know the volume id in case it is required.
Any ideas how to achieve this?
Thx, Vlad.
First of all, my question wasn't completely right, I wrote Linux for Windows but in fact I was talking about "Windows Subsystem for Linux".
The idea is to have 1 disk drive as hardware configured RAID 0 storage which is built with 2x Samsung SSD 1Tb. But for protection of data on RAID 0, I want to use HDD which will sync data with rsync or any cloud service. I selected ownCloud.
Finally, I want to hide the HDD from the system and configure WSL to use it.
Hereby how it works for me:
1) I created a folder here: c:\Users\Public\wsl
2) I mounted the HDD in the folder created above.
3) After the HDD is mounted, I created a subfolder for my favorite Linux distribution: c:\Users\Public\wsl\ubuntu
4) I installed Ubuntu 18.04 in this folder as it described here: Installing WSL on Windows 10 without MS Store
5) The point above allows to install ownCloud server on hidden HDD. Now, in order to get it running at system boot, one can create scripts as described here: how to autoload apache2 and mysql in WSL at Windows boot
6) And finally, to get ownCloud Server running at system boot, even before any user login, one needs to do as follows:
*) Open Windows task scheduler;
*) add a task which runs autostart.sh (see how to make this script on a link above) on system boot;
*) use wscript.exe (from windows system32) as the command to run and the vbs script as parameter. Check this link if you need more details;
7) Finally, we need to setup ownCloud client on the computer and connect it with the server by using http://localhost as the server url.
So, as result of this setup, one gets faster disk system based on 2x SSH configured in RAID 0 and to protect data, one uses a local cloud server in virtual machine to get personal content synchronized with standard HDD.
If the system uses actively SSD, the cloud won't get time for syncing data. But as soon as resources are available, system will sync data in background mode into the HDD, which requires more time to write the same data.
This setup allows to use SSD system at full speed as it is required by applications and it does not limit dramatically the performance of SSD subsystem while keep syncing data in slow HDD as computer resources are available and SSD resources are available.

Sharing OS between real and virtual machine

Is it feasible to have a virtual machine running an OS on a local disk (not the one with the guest system) and booting the real machine from that same disk?
I'd like to do it with both linux and Windows. Is it possible?
If you use separate partitions on the disk for the two OSes, then it works with no problem. But I think you mean that you want both instances of the OS to use the same partition, so the answer is no. There are many files in both Linux and Windows that are modified by the system while it is running. If two different instances of the OS are running and trying to update these files at the same time, it will result in chaos.
It would be possible to share the read-only parts of the system, and have separate copies of the writable parts, but that would be fairly tricky to set up. And it would result in two separate OSes on the disk, albeit with some shared files, so I don't think it really meets the premise of your question.

Where does the Host store the documents used in a Virtual Machine?

Is there a folder in the Host where the files used in the Guest are stored? Specifically, I refer to documents, text files et similia.
I found several posts about file sharing between the two OSs, but they do not answer this question. Actually, on the Host I found only the VM configuration files.
I mean, it is a VM, ok, but they have to physically stay somewhere on the Host HD! What if I want to access them without starting the WM?
My usual config:
W10 - Host;
Lubuntu - Guest.
It really depends on what kind of virtual disk you use VDI, VMDK, VHD, or HDD.
VDI is an issue. The only way i've found so far is to use a USB drive to copy things off and on, or create a network share.
If you're using VMDK, Vmware has a tool I believe is called VMware disk mount as a part of their VDDK, and you should be able to use it to mount VMDK disks as hard drives. https://developercenter.vmware.com/web/dp/sdk/55/vddk
Windows VHD is the easiest one to work with. You can use "Computer Management" on your windows PC to mount the VHD as an external drive using this tutorial. http://notebooks.com/2011/02/25/how-to-browse-and-copy-files-from-a-vhd-system-image-backup/
I'm really not sure about HDD.