Anybody tried to migrate Ubuntu (in this particular case 21.10 in use) from virtual machine (powered by VirtualBox, if this concerns) to WSL? Migration within one single host.
How well could imaging source (v.m.) then restoring to target (WSL) work? Hardware layer has a good chance to differ.
In general, if you can get a tarball'd rootfs of the VM, it should (in theory) be pretty straightforward, although I haven't tried it. The main trick will be getting the
rootfs.tar
"just right". Considerations:It will need to include all "normal" filesystems from the VM, but you can, of course, ignore things like
/proc
,/sys
,/dev
, etc.You should include the
--xattrs
flag to tar to make sure you pick up any extended attributes. This is not the default.Once you have a valid rootfs tarball, importing in WSL is easy:
The first argument (distribution name) can be whatever you prefer, although I'd recommend avoiding
Ubuntu
as this is the name of the default WSL distro and could cause a conflict.I tend to set up my WSL "directory":
~\Documents\WSL
~\Documents\WSL\instances\Ubuntu2110
(and others) for my distributions~\Documents\WSL\images\Ubuntu2110.tar
(and others) for my rootfs images.Not really the issue you might think. WSL2 instances are actually more "containers" than VMs. There is a VM running, but you can't access it. The VM itself is what handles the import and running of the distros/instances/containers. All WSL2 instances share the same kernelspace, virtual hardware, network, etc., but each has its own PID namespace, chroot, etc (to oversummarize).
Differences between WSL and your VM
System startup
The biggest difference you are going to find is that the VM does all of its configuration via Systemd, of course. That's not going to happen on WSL2, as Systemd isn't supported. Instead, WSL uses its own
/init
for bootstrapping the interoperability with the system VM and Windows.That means that, when you start up the WSL2 instance from the imported VM, pretty much nothing is going to be running.
You'll need to start each service manually. Or use other techniques to start automatically.
Other Systemd issues
While you can start many services in Ubuntu without Systemd, more and more are relying on Systemd. Those can be problematic under WSL. Although there are workarounds to run Systemd in WSL, they tend to be "hacky" at present.
GUI Apps
Also, remember that WSL is primarily a command-line environment. To run GUI apps, you'll need to run either:
xrdp
Desktop Environments
Finally, desktop environments can be even more challenging, for a combination of the above reasons and more: