Skip to content

Instantly share code, notes, and snippets.

@ScriptAutomate
Last active October 3, 2024 15:50
Show Gist options
  • Select an option

  • Save ScriptAutomate/f94cd44dacd0f420fae65414e717212d to your computer and use it in GitHub Desktop.

Select an option

Save ScriptAutomate/f94cd44dacd0f420fae65414e717212d to your computer and use it in GitHub Desktop.

Revisions

  1. ScriptAutomate revised this gist Aug 16, 2024. No changes.
  2. ScriptAutomate revised this gist Aug 16, 2024. 1 changed file with 7 additions and 3 deletions.
    10 changes: 7 additions & 3 deletions Install-WSLAndUbuntu.ps1
    Original file line number Diff line number Diff line change
    @@ -21,18 +21,22 @@ Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
    # Uncomment if wanting 20.04 instead of latest
    # Invoke-WebRequest -Uri https://cloud-images.ubuntu.com/releases/focal/release/ubuntu-20.04-server-cloudimg-amd64-wsl.rootfs.tar.gz -OutFile $ENV:HOMEDRIVE$ENV:HOMEPATH\Downloads\ubuntu-20.04-focal-wsl.tar.gz -UseBasicParsing
    # Download Ubuntu 22.04 Jammy Jellyfish
    Invoke-WebRequest -Uri https://cloud-images.ubuntu.com/wsl/jammy/current/ubuntu-jammy-wsl-amd64-wsl.rootfs.tar.gz -OutFile $ENV:HOMEDRIVE$ENV:HOMEPATH\Downloads\ubuntu-22.04-jammy-wsl.tar.gz -UseBasicParsing
    # Invoke-WebRequest -Uri https://cloud-images.ubuntu.com/wsl/jammy/current/ubuntu-jammy-wsl-amd64-wsl.rootfs.tar.gz -OutFile $ENV:HOMEDRIVE$ENV:HOMEPATH\Downloads\ubuntu-22.04-jammy-wsl.tar.gz -UseBasicParsing
    # Download Ubuntu 24.04 Noble Numbat
    Invoke-WebRequest -Uri https://cloud-images.ubuntu.com/wsl/noble/current/ubuntu-noble-wsl-amd64-wsl.rootfs.tar.gz -OutFile $ENV:HOMEDRIVE$ENV:HOMEPATH\Downloads\ubuntu-24.04-noble-wsl.tar.gz -UseBasicParsing

    # Setup reserved directory path for WSL VM
    # mkdir c:\UbuntuFocal # If doing Focal
    mkdir c:\UbuntuJammy # If doing Jammy
    # mkdir c:\UbuntuJammy # If doing Jammy
    mkdir c:\UbuntuNoble # If doing Noble

    # Configure WSL for incoming VM
    # For more information about WSL: https://docs.microsoft.com/en-us/windows/wsl/about
    wsl --set-default-version 2 # Change to '1' if not able to support 2
    # Import into WSL
    # wsl.exe --import UbuntuFocal C:\UbuntuFocal $ENV:HOMEDRIVE$ENV:HOMEPATH\Downloads\ubuntu-20.04-focal-wsl.tar.gz
    wsl.exe --import UbuntuJammy C:\UbuntuJammy $ENV:HOMEDRIVE$ENV:HOMEPATH\Downloads\ubuntu-22.04-jammy-wsl.tar.gz
    # wsl.exe --import UbuntuJammy C:\UbuntuJammy $ENV:HOMEDRIVE$ENV:HOMEPATH\Downloads\ubuntu-22.04-jammy-wsl.tar.gz
    wsl.exe --import UbuntuJammy C:\UbuntuJammy $ENV:HOMEDRIVE$ENV:HOMEPATH\Downloads\ubuntu-24.04-noble-wsl.tar.gz
    wsl # Drops straight into default VM. Will be UbuntuFocal is WSL alternate VM didn't already exist

    ## BONUS: Docker Desktop
  3. ScriptAutomate revised this gist Nov 8, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Install-WSLAndUbuntu.ps1
    Original file line number Diff line number Diff line change
    @@ -21,7 +21,7 @@ Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
    # Uncomment if wanting 20.04 instead of latest
    # Invoke-WebRequest -Uri https://cloud-images.ubuntu.com/releases/focal/release/ubuntu-20.04-server-cloudimg-amd64-wsl.rootfs.tar.gz -OutFile $ENV:HOMEDRIVE$ENV:HOMEPATH\Downloads\ubuntu-20.04-focal-wsl.tar.gz -UseBasicParsing
    # Download Ubuntu 22.04 Jammy Jellyfish
    Invoke-WebRequest -Uri https://cloud-images.ubuntu.com/releases/jammy/release/ubuntu-22.04-server-cloudimg-amd64-wsl.rootfs.tar.gz -OutFile $ENV:HOMEDRIVE$ENV:HOMEPATH\Downloads\ubuntu-22.04-jammy-wsl.tar.gz -UseBasicParsing
    Invoke-WebRequest -Uri https://cloud-images.ubuntu.com/wsl/jammy/current/ubuntu-jammy-wsl-amd64-wsl.rootfs.tar.gz -OutFile $ENV:HOMEDRIVE$ENV:HOMEPATH\Downloads\ubuntu-22.04-jammy-wsl.tar.gz -UseBasicParsing

    # Setup reserved directory path for WSL VM
    # mkdir c:\UbuntuFocal # If doing Focal
  4. ScriptAutomate renamed this gist Jul 20, 2022. 1 changed file with 9 additions and 4 deletions.
    13 changes: 9 additions & 4 deletions Install-WSLAndUbuntuFocal.ps1 → Install-WSLAndUbuntu.ps1
    Original file line number Diff line number Diff line change
    @@ -18,21 +18,26 @@ dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /nores
    Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All

    # Download Ubuntu 20.04 Focal Fosa
    Invoke-WebRequest -Uri https://cloud-images.ubuntu.com/releases/focal/release/ubuntu-20.04-server-cloudimg-amd64-wsl.rootfs.tar.gz -OutFile $ENV:HOMEDRIVE$ENV:HOMEPATH\Downloads\ubuntu-20.04-focal-wsl.tar.gz -UseBasicParsing
    # Uncomment if wanting 20.04 instead of latest
    # Invoke-WebRequest -Uri https://cloud-images.ubuntu.com/releases/focal/release/ubuntu-20.04-server-cloudimg-amd64-wsl.rootfs.tar.gz -OutFile $ENV:HOMEDRIVE$ENV:HOMEPATH\Downloads\ubuntu-20.04-focal-wsl.tar.gz -UseBasicParsing
    # Download Ubuntu 22.04 Jammy Jellyfish
    Invoke-WebRequest -Uri https://cloud-images.ubuntu.com/releases/jammy/release/ubuntu-22.04-server-cloudimg-amd64-wsl.rootfs.tar.gz -OutFile $ENV:HOMEDRIVE$ENV:HOMEPATH\Downloads\ubuntu-22.04-jammy-wsl.tar.gz -UseBasicParsing

    # Setup reserved directory path for WSL VM
    mkdir c:\UbuntuFocal
    # mkdir c:\UbuntuFocal # If doing Focal
    mkdir c:\UbuntuJammy # If doing Jammy

    # Configure WSL for incoming VM
    # For more information about WSL: https://docs.microsoft.com/en-us/windows/wsl/about
    wsl --set-default-version 2 # Change to '1' if not able to support 2
    # Import into WSL
    wsl.exe --import UbuntuFocal C:\UbuntuFocal $ENV:HOMEDRIVE$ENV:HOMEPATH\Downloads\ubuntu-20.04-focal-wsl.tar.gz
    # wsl.exe --import UbuntuFocal C:\UbuntuFocal $ENV:HOMEDRIVE$ENV:HOMEPATH\Downloads\ubuntu-20.04-focal-wsl.tar.gz
    wsl.exe --import UbuntuJammy C:\UbuntuJammy $ENV:HOMEDRIVE$ENV:HOMEPATH\Downloads\ubuntu-22.04-jammy-wsl.tar.gz
    wsl # Drops straight into default VM. Will be UbuntuFocal is WSL alternate VM didn't already exist

    ## BONUS: Docker Desktop
    # Checkout the Install-ChocoStarterPackages gist for setting up choco (and other things):
    # - https://gist.github.com/ScriptAutomate/02e0cf33786f869740ee963ed6a913c1
    # Once chocolatey / choco is installed, and WSL is already configured with UbuntuFocal,
    # Once chocolatey / choco is installed, and WSL is already configured with Ubuntu,
    # run the following command from PowerShell, and not from within WSL:
    # choco install docker-desktop -y
  5. ScriptAutomate revised this gist Aug 25, 2020. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions Install-WSLAndUbuntuFocal.ps1
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,6 @@
    <#
    - BIOS of host machine also needs to be configured to allow hardware virtualization
    - Windows 10 Pro or otherwise is needed; Windows 10 Home Edition CANNOT get WSL
    - This gist WSLv2, but can use WSLv1 instead. I needed v1 as I run Windows 10 in a VM in Virtualbox.
    - WSLv2 has been giving me problems in Virtualbox 6.1, but WSLv1 works properly.
    - vbox has issues with the GUI settings when it comes to nested virtualization on certain systems,
  6. ScriptAutomate revised this gist Aug 21, 2020. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions Install-WSLAndUbuntuFocal.ps1
    Original file line number Diff line number Diff line change
    @@ -23,6 +23,7 @@ Invoke-WebRequest -Uri https://cloud-images.ubuntu.com/releases/focal/release/ub
    mkdir c:\UbuntuFocal

    # Configure WSL for incoming VM
    # For more information about WSL: https://docs.microsoft.com/en-us/windows/wsl/about
    wsl --set-default-version 2 # Change to '1' if not able to support 2
    # Import into WSL
    wsl.exe --import UbuntuFocal C:\UbuntuFocal $ENV:HOMEDRIVE$ENV:HOMEPATH\Downloads\ubuntu-20.04-focal-wsl.tar.gz
  7. ScriptAutomate revised this gist Aug 21, 2020. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions Install-WSLAndUbuntuFocal.ps1
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,9 @@
    <#
    - BIOS of host machine also needs to be configured to allow hardware virtualization
    - This gist uses WSLv1 instead of WSLv2, as I run Windows 10 in a VM in Virtualbox
    - WSLv2 has been giving me problems in Virtualbox 6.1, but WSLv1 works properly
    - This gist WSLv2, but can use WSLv1 instead. I needed v1 as I run Windows 10 in a VM in Virtualbox.
    - WSLv2 has been giving me problems in Virtualbox 6.1, but WSLv1 works properly.
    - vbox has issues with the GUI settings when it comes to nested virtualization on certain systems,
    so run the following if needing to give a VM this enabled setting:
    so run the following if needing to give a VM this enabled setting:
    VBoxManage modifyvm <vm-name> --nested-hw-virt on
    #>
  8. ScriptAutomate revised this gist Aug 21, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Install-WSLAndUbuntuFocal.ps1
    Original file line number Diff line number Diff line change
    @@ -23,7 +23,7 @@ Invoke-WebRequest -Uri https://cloud-images.ubuntu.com/releases/focal/release/ub
    mkdir c:\UbuntuFocal

    # Configure WSL for incoming VM
    wsl --set-default-version 1 # Change to '2' if supporting latest WSL
    wsl --set-default-version 2 # Change to '1' if not able to support 2
    # Import into WSL
    wsl.exe --import UbuntuFocal C:\UbuntuFocal $ENV:HOMEDRIVE$ENV:HOMEPATH\Downloads\ubuntu-20.04-focal-wsl.tar.gz
    wsl # Drops straight into default VM. Will be UbuntuFocal is WSL alternate VM didn't already exist
  9. ScriptAutomate revised this gist Aug 19, 2020. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion Install-WSLAndUbuntuFocal.ps1
    Original file line number Diff line number Diff line change
    @@ -29,5 +29,8 @@ wsl.exe --import UbuntuFocal C:\UbuntuFocal $ENV:HOMEDRIVE$ENV:HOMEPATH\Download
    wsl # Drops straight into default VM. Will be UbuntuFocal is WSL alternate VM didn't already exist

    ## BONUS: Docker Desktop
    # If chocolatey / choco is installed...
    # Checkout the Install-ChocoStarterPackages gist for setting up choco (and other things):
    # - https://gist.github.com/ScriptAutomate/02e0cf33786f869740ee963ed6a913c1
    # Once chocolatey / choco is installed, and WSL is already configured with UbuntuFocal,
    # run the following command from PowerShell, and not from within WSL:
    # choco install docker-desktop -y
  10. ScriptAutomate revised this gist Aug 19, 2020. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion Install-WSLAndUbuntuFocal.ps1
    Original file line number Diff line number Diff line change
    @@ -26,4 +26,8 @@ mkdir c:\UbuntuFocal
    wsl --set-default-version 1 # Change to '2' if supporting latest WSL
    # Import into WSL
    wsl.exe --import UbuntuFocal C:\UbuntuFocal $ENV:HOMEDRIVE$ENV:HOMEPATH\Downloads\ubuntu-20.04-focal-wsl.tar.gz
    wsl # Drops straight into default VM. Will be UbuntuFocal is WSL alternate VM didn't already exist
    wsl # Drops straight into default VM. Will be UbuntuFocal is WSL alternate VM didn't already exist

    ## BONUS: Docker Desktop
    # If chocolatey / choco is installed...
    # choco install docker-desktop -y
  11. ScriptAutomate created this gist Jul 13, 2020.
    29 changes: 29 additions & 0 deletions Install-WSLAndUbuntuFocal.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    <#
    - BIOS of host machine also needs to be configured to allow hardware virtualization
    - This gist uses WSLv1 instead of WSLv2, as I run Windows 10 in a VM in Virtualbox
    - WSLv2 has been giving me problems in Virtualbox 6.1, but WSLv1 works properly
    - vbox has issues with the GUI settings when it comes to nested virtualization on certain systems,
    so run the following if needing to give a VM this enabled setting:
    VBoxManage modifyvm <vm-name> --nested-hw-virt on
    #>

    ## IN AN ELEVATED SHELL
    ## Right-click PowerShell -> Run As Administrator

    # Enable Needed Virtualization
    dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
    dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
    Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All

    # Download Ubuntu 20.04 Focal Fosa
    Invoke-WebRequest -Uri https://cloud-images.ubuntu.com/releases/focal/release/ubuntu-20.04-server-cloudimg-amd64-wsl.rootfs.tar.gz -OutFile $ENV:HOMEDRIVE$ENV:HOMEPATH\Downloads\ubuntu-20.04-focal-wsl.tar.gz -UseBasicParsing

    # Setup reserved directory path for WSL VM
    mkdir c:\UbuntuFocal

    # Configure WSL for incoming VM
    wsl --set-default-version 1 # Change to '2' if supporting latest WSL
    # Import into WSL
    wsl.exe --import UbuntuFocal C:\UbuntuFocal $ENV:HOMEDRIVE$ENV:HOMEPATH\Downloads\ubuntu-20.04-focal-wsl.tar.gz
    wsl # Drops straight into default VM. Will be UbuntuFocal is WSL alternate VM didn't already exist