OS/Windows

Windows 10에서 WSL2를 이용하여 Ubuntu 설치하는 방법

정리하는개발자 2021. 5. 19. 18:22
728x90
반응형

 

Windows 10에서 WSL2를 이용하여 우분투를 설치해보자.

Windows 참가자를 위한 단순화된 설치와 수동설치. 2가지 방식이 있는데 역시나 수동설치(?!)를 해보도록 하자.

 

WSL2 설치 공식사이트 - https://docs.microsoft.com/ko-kr/windows/wsl/install-win10

 

<설치 및 실행환경>

  • 윈도우 10 (해당 PC는 윈도우 10 프로페셔널)
  • x64 시스템의 경우 : 버전 1903 이상, 빌드 18362 이상
  • ARM64 시스템의 경우 : 버전 2004 이상, 빌드 19041

 

1. 실행환경 OS 버전확인

윈도우 실행(윈도우키 + R) -> winver 입력 후 엔터 -> OS버전을 확인

내 PC는 x64 시스템이고 버전이 20H2, 빌드가 19024 이기 때문에 문제없이 WSL2를 설치 할 수 있다.

이 버전 보다 낮으면 윈도우시스템을 업그레이드 후 설치가 가능할 것이다.

winver

 

2. Virtual Machine 기능 사용

PowerShell을 관리자 권한으로 실행한뒤 dism 명령어를 입력한다.

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

dism.exe

 

PC를 재기동하여 WSL 설치를 완료하고 WSL2로 업그레이드를 해보자.

 

3. WSL2로 업데이트 후 설정변경

wsl_update_x64.msi 패키지를 다운로드, 실행하여 WSL2로 업그레이드하자.

다운로드 - https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi

 

Next > 설치(너무빠르다.) > Finish 하면 완료

 

WSL2를 기본 버전으로 설정

wsl --set-default-version 2

 

4. 리눅스/Ubuntu 를 설치 후 초기설정

윈도우 앱스토어 > Linux 검색 > Ubuntu 20.04 LTS 를 선택하여 설치해보자.

(CentOS가 앱스토어에 등록되어 있지만 유료이다.!!!)

윈도우 앱스트어 > Ubuntu 20.04 LTS

 

받기 버튼 클릭

윈도우 앱스트어 > Ubuntu 20.04 LTS 받기

 

우분투 다운로드중

윈도우 앱스트어 > Ubuntu 20.04 LTS 다운로드중

 

시작버튼을 클릭하면 Ubuntu 가 시작되면서 초기설정를 시작한다.

윈도우 앱스트어 > Ubuntu 20.04 LTS 시작

 

새로운 사용자와 암호를 입력하자. (root로 할려고 했으나 이미 등록되어 있는 유저라 실패하였다.)

WSL2 - Ubuntu 초기설정

 

Installing, this may take a few minutes...
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms/wslusers
Enter new UNIX username: root
adduser: The user `root' already exists.
Enter new UNIX username: wylee
New password:
Retype new password:
passwd: password updated successfully
Installation successful!
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

Welcome to Ubuntu 20.04.2 LTS (GNU/Linux 5.4.72-microsoft-standard-WSL2 x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Wed May 19 17:43:56 KST 2021

  System load:  0.26               Processes:             8
  Usage of /:   0.4% of 250.98GB   Users logged in:       0
  Memory usage: 0%                 IPv4 address for eth0: 172.26.44.64
  Swap usage:   0%

1 update can be installed immediately.
0 of these updates are security updates.
To see these additional updates run: apt list --upgradable


The list of available updates is more than a week old.
To check for new updates run: sudo apt update


This message is shown once a day. To disable it please create the
/home/wylee/.hushlogin file.
wylee@DESKTOP-KT5AJK5:~$

 

uname -a 명령어를 이용하여 해당 리눅스가 WSL2에서 구동되고 있다는 것을 확인할 수 있다.

wylee@DESKTOP-KT5AJK5:~$ uname -a
Linux DESKTOP-KT5AJK5 5.4.72-microsoft-standard-WSL2 #1 SMP Wed Oct 28 23:40:43 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

 

5. WSL2 간단한 사용법

5.1) wsl -l -v 명령어를 이용하여 설치버전/상태 확인

wsl -l -v

 

5.2) 윈도우 터미널을 이용하여 Ubuntu 에 접속하기

  • 윈도우 터미널이 설치되어 있으면 Ubuntu 구동 및 접속을 쉽게 할 수 있다.

윈도우 터미널

 

윈도우 터미널 > WSL2 우분투 구동 및 접속

 

<정리>

  • VirtualBox, Hyper-V 등 가상화 프로그램을 사용하지 않고 리눅스를 설치해서 사용할 수 있다는 것이 WSL의 큰 장점인 것 같다.
  • WSL 공식사이트에서 VS Code, Git, Dokcer등. WSL/리눅스에서 할 수 있는 많은 기능을 서술해 놓았는데 추후 사용해 보고 포스팅을 해보면 좋을듯 하다.

 

728x90
반응형