Skip to content

Instantly share code, notes, and snippets.

@Wombatpm
Last active March 8, 2023 07:31
Show Gist options
  • Select an option

  • Save Wombatpm/b7e86908fb9c8001b3db830701fb27b4 to your computer and use it in GitHub Desktop.

Select an option

Save Wombatpm/b7e86908fb9c8001b3db830701fb27b4 to your computer and use it in GitHub Desktop.
Setup CentOS for WSL2 with Django and Postgres

Configure your win10 box for WSL 1

Using Powershell (see https://docs.microsoft.com/en-us/windows/wsl/install-win10 for more information)

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

Configure for WSL 2

(see https://docs.microsoft.com/en-us/windows/wsl/wsl2-install )

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

CentOS is not in the Windows Store. Luckily the internet elves have been hard at work creating root file systems that can be launched with WSLDL. I went with this one https://github.com/yuk7/CentWSL.

Why not Ubuntu? Ubuntu is fine if you have complete control of your environment. I'm setting this up to create a local environment that reflects my production environment which is CentOS. The company's admin elves insist that it is a better choice for their needs. Since they are the ones who have to troubleshoot at 3:00AM I'm not going to argue.

Download and unzip CentOS7.zip Double click Centos.exe This is the wsldl laucher that will unpack and register the rootfilesystem. The first time you run it, it will take a while to set everthing up.

wsl --set-version CentOS7 2

Conversion in progress, this may take a few minutes...
For information on key differences with WSL 2 please visit https://aka.ms/wsl2
Please enable the Virtual Machine Platform Windows feature and ensure virtualization is enabled in the BIOS.
For information please visit https://aka.ms/wsl2-install

The VPM is already active from the commands above, you may need to restart and configure the BIOS.

Restart and check that the conversion is complete

PS C:\Users\wombatpm> wsl -l -v
  NAME       STATE           VERSION
* CentOS7    Stopped         1
PS C:\Users\bruce> wsl --set-version CentOS7 2
Conversion in progress, this may take a few minutes...
For information on key differences with WSL 2 please visit https://aka.ms/wsl2
Conversion complete.
PS C:\Users\wombatpm> wsl -l -v
  NAME       STATE           VERSION
* CentOS7    Stopped         2

Update & upgrade your dist

yum update
yum upgrade


@curious-monggo
Copy link

Thank you, internet elves!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment