WSL 2 or How I Brought my Linux and Windows Installs Together
A while back I bought a mini PC to replace my old, tired and non-functional Linux box. 16G RAM, 512GB SSD, 11th Gen Intel Celeron and it included a license for Windows 11 Pro. Now I haven’t been happy with Windows since Windows 10 would drain my laptop’s battery by deciding it needed to install updates in the middle of the night. I’d pick up my laptop after a few days and the battery would be exhausted! So, I swore off Windows, opting instead for Linux (usually Ubuntu) and Chromebooks. But I got a Windows 11 Pro sitting in front of me on my new PC. Being the packrat that I am, I didn’t wipe the Windows partition but split the SSD into another partition and installed Ubuntu (which happily recognized the bootable Windows partition and set things up so I could boot to either Windows or Linux.
Curiosity eventually got the better of me and I started fooling around with Windows. I recalled messing with Window Subsystem for Linux (WSL) on my Windows 10 machines so I did some searches and found that Microsoft had come up with WSL 2. Futher, there were many distros available from the Windows Store. So I fired up WSL2 and loaded Ubuntu 22.04. Yup, looks pretty nice! Hmmm…I’ve got this external drive that’s formatted at ext4 and holds a bunch of the stuff I was using on my Linux box (media library, precious files and photos, backups, etc). Can I use that on Windows? Well, not without adding some “stuff” to Windows but I CAN attach the drive to my running WSL2 Ubuntu! So I did.
Now I can run some Windows-only services that I’ve been wanting to try out (Channels DVR server, for one) alongside my Linux services (JR Media Center for one, not to mention the Samba server which makes my backups, files and pictures available to my other machines.
The only thing that’s missing is an automated way of attaching that disk to my Linux WSL2 instance and redirecting the appropriate ports to the Linux instance. I managed to get that done with a PowerShell script that I had ChatGPT write for me. That’s right, ChatGPT wrote a PowerShell script for me! For a couple of weeks I had been trying to figure out what I could use ChatGPT for when it occurred to me to give it this task. I don’t know PowerShell. Sure I’m familiar with the basic concepts but the object model and the commands themselves are largely unknown to me. ChatGPT spit out the script in about 10 seconds and, while it wasn’t 100% right, it only took a hour or so of fiddling to get it to work just perfectly! ChatGPT to the rescue! But its not a panacea – I’ll do another blog post about that later.
WSL 2 or How I Brought my Linux and Windows Installs Together Read More »