Skip to content

Latest commit

 

History

History
171 lines (97 loc) · 4.38 KB

01. Setup Ubuntu.md

File metadata and controls

171 lines (97 loc) · 4.38 KB

1. Turn on some feature requirement for linux on windows 10 ($ mean begin command dont copy it)

=========================================================================

First sorry about my English, hope you can understand it! Press

$ Windows + S

to open search, then type feature, select Turn Windows features on or off

Check the Windows Subsystem for Linux option. Check the Vitual machine platform option. Click OK, dont restart

Press

$ Windows + X then $ A

to open powershell as admin, then type:

$ Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

Restart, then open powershell as admin again, then type:

$ choco install --force lxrunoffline 

Restart, then open powershell as admin again, then type:

    $ wsl --set-default-version 2

1.1 Install nathanchange wsl kernel for best performance

Download bZImage and paste to C:\Users :

$ https://github.com/nathanchance/WSL2-Linux-Kernel/releases

In your user folder (me C:\Users\LeCmnGend), create text file and rename to **.wslconfig **

Open it and paste (wsl config option you can search in google), save and close: (case sensitive C is different with c, if user name like: some One, you have to replace exactly some One (someOne or some one not work)

    $ [wsl2]
    kernel = C:\\Users\\bzImage
    processors=16
    memory=10.4GB
    swap=10GB
    swapFile=C:\\Users\\<your-user>\\swap.vhdx
    localhostForwarding=true

Open store then install Ubuntu, then type to pws to check version:

$ wsl -l -v 

Mine show:

    $ 
    NAME        STATE           VERSION
    * Ubuntu    Running         2

2. Move WSL install dir to drive E (optional)

================================================

2.1 Set permissions to the target folder.

Type:

  $ Windows + R 

then type cmd , Ctrl + shift + enter , to run as admin, it should show:

  $ C:\Windows\system32>

then type:

  $ whoami

it should show something \ <your_user> , then type:

  $ 
  icacls E:\WSL2 /grant "LeCmnGend:(OI)(CI)(F)"

  lxrunoffline move -n Ubuntu -d E:\WSL2

It should show ext4.vdhx in E:\wsl folder (mean success)

3. Resize unbuntu disk size (optional):

==========================================

Turn off ubuntu first: (pws admin):

  $ wsl --shutdown

Open cmd admin then type: (for me 299GB is enough, set this value by yours)

  $ 
  diskpart
  select vdisk file="E:\WSL2\ext4.vhdx"
  detail vdisk
  expand vdisk maximum=299000

Now check again:

  $ 
  detail vdisk
  exit

Mine show Virtual size: 291 GB , Close cmd.

3.1 Open Ubuntu again

   $ 
   sudo mount -t devtmpfs none /dev
   mount | grep ext4

You may see this message in response to the first mount command: "/dev: none already mounted on /dev."

This message can safely be ignored.

Copy the name of this entry, which will look like:

    $ /dev/sdX 

(with the X representing any other character). In the following example the value of X is b : Then type

    $ 
    sudo resize2fs /dev/sdb <sizeInMegabytes>M

The output should show similar:

   $  
   resize2fs 1.44.1 (24-Mar-2021)
   Filesystem at /dev/sdb is mounted on /; on-line resizing required
   old_desc_blocks = 32, new_desc_blocks = 38
   The filesystem on /dev/sdb is now 78643200 (4k) blocks long.

4. Unbuntu dir

Create a network drive Z for easy to track linux dir:

Open this PC , right click to the space, select Add a network location , click next , click on choose a .. then next Then type:

      $
      \\wsl$\Ubuntu

5. Turn of disk cache buffer for more speed

Ensure you are ticked all, in a both ssd and hdd disk like me

$ https://www.thewindowsclub.com/enable-disable-disk-write-caching-windows-7-8#:~:text=Disable%20or%20Turn%20off%20Disk%20Write%20Caching&text=Follow%20this%20procedure%20to%20disable,Click%20Apply%2FOK%20%3E%20Exit.

SUCESS, move to part 2