Accessing ext4.vhdx via another machine? - windows-subsystem-for-linux

Is there anyway to mount or access the ext4.vhdx on another machine? I understand that accessing the linux environment files while WSL is running will likely corrupt them; but I want to be able to access this hard disk image when WSL is inactive?

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.

Share a folder between my EC2 windows instance to my local PC

I have a process that creates an EXCEL file on a local folder on my local PC.
I want to share this folder \ file with my EC2 instance on AWS.
FXs it's not an option because the costs are very high, file size is smaller than a 100MB.
any idea?
The answer is secure copy AKA: SCP.
SCP uses SSH (hence the name secure copy bit) because you are using a windows machine you'll need to make some changes to your machine first.
You should either look into WSL(windows subsystem for linux) or use native PowerShell, specifically this pkg

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

QEMU Virtual Machine: Creating a shared folder between Windows 10 (host) and Solaris 2.7 (guest)

I was wondering if anyone could give me wisdom on how to create a shared folder between my host machine (running Windows 10) and the virtual machine I created in qemu which is running Solaris 2.7. I need a way to get files in and out of the VM.
I've managed to "plug in" a folder as a virtual drive into the VM, using
-drive file=fat:rw:[folder],bus=0,unit=1,if=scsi,format=raw,media=disk
in the VM invocation. Solaris sees this as a disk, but I'm unsure where to go from here. I can't seem to format it because I don't know the "disk" geometry (apparently Solaris was very particular about this). I tried mounting the unformatted drive in Solaris but it wasn't able to do that either. I even tried giving it an entry in /etc/vfstab to see if I could get it to automount, but that didn't work either.
Is there a different way I should be mounting it? Or is there a trick to getting Solaris to use this virtual drive? I'm also open to other alternatives people are aware of for transferring files in/out of my VM, but since Solaris 2.7 is a rather old operating system, things like networking (for example) aren't trivial to set up (and even basic things like ssh are missing).
Any help would be appreciated!

Is it possible to have Vagrant box running on USB?

I want to creatre portable dev environment inside a Vagrant box. But faced a problem with ssh key access rights. On some target machines I haven't got enough rights to change them. Is it possible to configure Vagrant to have access maybe only with password to make box fully rights-independent?
You can have vagrant box running from USB (I do that a lot and its nice to take hard drive with you and go on another computer and everything is running the same)
If you run VMWare provider, this is all set as all the vagrant file and the VM files are within the .vagrant directory from your project so just run Vagrant init and vagrant up within your USB and all the files are there, you can take the USB drive with you and connect to another computer running vagrant/VMWare and you're good
When you run VirtualBox provider, its a bit different as the vagrant files will be stored within your vagrant directory but your VM files will likely be stored with your My Documents folder.
You can overcome that by forcing VirtualBox to store the files on the USB as well - see this answer https://stackoverflow.com/a/36343325/4296747 to have multiple options how you can do that