$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 119.2G 0 disk ├─sda1 8:1 0 84.5G 0 part └─sda6 8:6 0 28.9G 0 part / mmcblk0 179:0 0 7.5G 0 disk ├─mmcblk0p2 179:2 0 6.8G 0 part /media/qkboo/ROOT ├─mmcblk0p3 179:3 0 486.1M 0 part └─mmcblk0p1 179:1 0 200M 0 part /media/qkboo/EFI
parted 사용
파티션 및 포맷을 위해 마운트된 파티션을 언마운트 한다. parted 는 상호작용 프롬프트에서 사용하거나 단일 명령어로 사용할 수 있다.
parted 프롬프트 사용
[ext4 파티션 생성]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
sudo parted /dev/sdb (parted) print Number Start End Size File system Name Flags 1 0.00GB 32.0GB 32.0GB
(parted) mklabel gpt Warning: The existing disk label on /dev/sda will be destroyed and all data on this disk will be lost. Do you want to continue? Yes/No? y
(parted) unit GB (parted) mkpart primary 0 1000.0GB #디스크 크기 입력
(parted) print Number Start End Size File system Name Flags 1 0.00GB 32.0GB 32.0GB primary lvm (parted) quit
[fat32 파티션 생성]
USB 스토리지는 아래 같이 나타난다. 다음은 USB 파티션에 fat32 파일시스템을 프롬프트로 생성하고 있다.
1 2 3 4 5
sudo parted /dev/mmcblk0 (parted) mklabel msdos (parted) mkpart primary fat32 1MiB 100% (parted) set 1 boot on (parted) quit
생성한 파티션에 시스템 지원 파일 시스템을 생성해야 한다. 해당 파일 시스템으로 파티션을 포맷한 후에 지정한 디렉토리에 마운트를 해서 사용하면 된다. 지속적인 사용을 위해서 /etc/fstab 에 파티션을 마운트 포인트로 등록하면 재시동 후에도 동일한 폴더에 마운트 된다.
mkfs
mkfs 명령은 파일 시스템에 따랴서 -t 옵션에 파일시스템을 지시하거나 mkfs.[FS] 형식을 명령을 바로 쓰기도 한다.
# Settings apply across all Linux distros running on WSL 2 [wsl2]
# Limits VM memory to use no more than 4 GB, this can be set as whole numbers using GB or MB memory=4GB
# Sets the VM to use two virtual processors processors=2
# Specify a custom Linux kernel to use with your installed distros. The default kernel used can be found at https://github.com/microsoft/WSL2-Linux-Kernel kernel=C:\\temp\\myCustomKernel
# Sets additional kernel parameters, in this case enabling older Linux base images such as Centos 6 kernelCommandLine = vsyscall=emulate
# Sets amount of swap storage space to 8GB, default is 25% of available RAM swap=8GB
# Sets swapfile path location, default is %USERPROFILE%\AppData\Local\Temp\swap.vhdx swapfile=C:\\temp\\wsl-swap.vhdx
# Disable page reporting so WSL retains all allocated memory claimed from Windows and releases none back when free pageReporting=false
# Turn off default connection to bind WSL 2 localhost to Windows localhost localhostforwarding=true
# Automatically mount Windows drive when the distribution is launched [automount]
# Set to true will automount fixed drives (C:/ or D:/) with DrvFs under the root directory set above. Set to false means drives won't be mounted automatically, but need to be mounted manually or with fstab. enabled = true
# Sets the directory where fixed drives will be automatically mounted. This example changes the mount location, so your C-drive would be /c, rather than the default /mnt/c. root = /
# DrvFs-specific options can be specified. options = "metadata,uid=1003,gid=1003,umask=077,fmask=11,case=off"
# Sets the `/etc/fstab` file to be processed when a WSL distribution is launched. mountFsTab = true
# Network host settings that enable the DNS server used by WSL 2. This example changes the hostname, sets generateHosts to false, preventing WSL from the default behavior of auto-generating /etc/hosts, and sets generateResolvConf to false, preventing WSL from auto-generating /etc/resolv.conf, so that you can create your own (ie. nameserver 1.1.1.1). [network] hostname = DemoHost generateHosts = false generateResolvConf = false
# Set whether WSL supports interop process like launching Windows apps and adding path variables. Setting these to false will block the launch of Windows processes and block adding $PATH environment variables. [interop] enabled = false appendWindowsPath = false
# Set the user when launching a distribution with WSL. [user] default = DemoUser
# Set a command to run when a new WSL instance launches. This example starts the Docker container service. [boot] command = service docker start
4. wsl 외부 디스크 마운트 하기
윈도우즈 wsl 에서 리눅스 파티션 혹은 USB 파티션 디스크를 마운트해서 사용하려고 한다.
네이티브 리눅스 앱을 Windows 11 and later OS build 에서 실행할 수 있는 Windows Subsystem for Linux 이다.
WSL 1 vs. WSL 2
WSL2 is the second generation of WSL that offers the following benefits:
Linux applications can run as is in WSL2. WSL 2 is characteristically a VM with a Linux WSL Kernel in it that provides full compatibility with mainstream Linux kernel allowing support for native Linux applications including popular Linux distros.
Faster file system support and that’s more performant.
WSL 2 is tightly integrated with the Microsoft Windows operating system, which allows it to run Linux applications alongside and even interop with other Windows desktop and modern store apps.
2. NVIDIA GPU Accelerated Computing on WSL 2
WSL 2에서 마이크로소프트는 NVIDIA CUDA 및 기타 컴퓨팅 프레임워크와 기술과 함께 데이터 과학, 머신러닝 및 추론 솔루션을 위한 GPU 가속 컴퓨팅을 가능하게 하는 GPU 반가상화 기술을 도입했다. WSL 유사 환경 또는 WSL 2에서 CPU 개입을 줄이면서 GPU에서 더 많은 병렬 작업을 파이프라인으로 수행할 수 있으므로 거의 네이티브에 가까운 성능을 제공한다. NVIDIA 드라이버 지원은 CUDA 및 관련 컴퓨팅 소프트웨어 스택에서 멈추지 않습니다. 다이렉트 ML 지원과 함께 DX12 API를 지원하여 WSL 2에서 그래픽을 활성화하는 DirectX 지원이 있습니다.
Illustration of the possibilities with NVIDIA CUDA software stack on WSL 2
3. WSL2 시작
WSL2 요구사항
Geforce, Quadro 제품 계열에서 Pascal 또는 최신 GPU 구조를 WDDM모드로 SKU를 사용할 수 있다.
최신 WSL 커널 로 5.10.16.3 이상을 권장한다. (최소 4.19.121+ 이상)
Windows 11 에서는 윈도우 인사이더 프로그램 가입이 필요 없다.
Windows 10 에서는 윈도우 인사이더 프리뷰 프로그램이 필요하다.
Step 1: Install NVIDIA Driver for GPU Support
윈도우 11 그래픽 드라이버로 NVIDIA GeForce Game Ready or NVIDIA RTX Quadro 를 설치한다.
(tf25gpu_p39)~$ nvidia-smi Sun Dec 5 02:29:22 2021 +-----------------------------------------------------------------------------+ | NVIDIA-SMI 510.00 Driver Version: 510.06 CUDA Version: 11.6 | |-------------------------------+----------------------+----------------------+ | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | | | | MIG M. | |===============================+======================+======================| | 0 NVIDIA GeForce ... On | 00000000:09:00.0 On | N/A | | 0% 43C P8 20W / 320W | 1179MiB / 11264MiB | N/A Default | | | | N/A | +-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+ | Processes: | | GPU GI CI PID Type Process name GPU Memory | | ID ID Usage | |=============================================================================| | No running processes found | +-----------------------------------------------------------------------------+
Initializing data... ...allocating CPU memory for options. ...allocating GPU memory for options. ...generating input data in CPU mem. ...copying input data to GPU mem. Data init done.
Executing Black-Scholes GPU kernel (512 iterations)... Options count : 8000000 BlackScholesGPU() time : 0.234201 msec Effective memory bandwidth: 341.586668 GB/s Gigaoptions per second : 34.158667
여러가지 방법이 있지만 대부분의 Windows에서 동작하는 방법은 먼저 PowerShell을 관리자 권한으로 열고 다음 명령을 실행하면 됩니다.
1
Restart-Service LxssManager
Windows 10 버전 1903/19H1 (빌드 18362) 이상 부터는 명령 프롬프트(CMD)를 열고 다음 명령어만 간단히 입력함으로서 WSL 시스템을 종료할 수 있습니다.
wsl -t [배포판 이름] 예를 들어 Ubuntu 20.04를 설치하였다면 wsl -t ubuntu를, Debian을 설치하였다면 wsl -t debian과 같이 사용하시면 됩니다.
추가로 Windows 10 버전 2004/20H1 (빌드 18917) 이상 부터는 명령 프롬프트에서 다음 명령어를 사용하여 모든 WSL 시스템을 한 번에 종료할 수 있습니다. 가령 Ubuntu와 Debian 머신이 구동되고 있다면 아래 명령어로 모두 종료 시킬 수 있습니다.
wsl –shutdown
1 2 3 4 5 6 7
(base) PS C:\Users\daddy> wsl -l Linux용 Windows 하위 시스템 배포: Ubuntu-20.04(기본값) (base) PS C:\Users\daddy> wsl -t Ubuntu-20.04 (base) PS C:\Users\daddy> (base) PS C:\Users\daddy> wsl -t Ubuntu-20.04 --shutdown (base) PS C:\Users\daddy>
주요 명령
설치
WSL 및 Linux의 기본 Ubuntu 배포판을 설치합니다. WSL은 기본 배포판으로 Ubuntu를 제공한다.
RedHat, Ubuntu, OpenSUSE LEAP 15.0 등은 시스템 기본 파이어월 관리자로 firewalld 를 제공한다고 한다.
firewalld
firewalld 는 ….
firewalld는 ufw 처럼 iptables 을 구성할 수 있다.
[그림. Firewall Stack (redhat.com)]
네트워크를 지역 관리가 가능해서 다른 네트워크, 지역에 따라 다른 규칙으로 구성해서 사용할 수 있다. For example “Home” and “Office” where all communications with local machines are allowed, and “Public Wi-Fi” where no communication with the same subnet would be allowed.
OpenSUSE LEAP 15.0, RedHat, Ubuntu 등은 시스템 기본 파이어월 관리자로 firewalld 를 제공한다고 한다.
1
$ sudo apt install firewalld
Start firewalld
To start firewalld, enter the following command as root:
1
systemctl start firewalld
root 사용자로 시작한다.
1 2
sudo systemctl enable firewalld sudo reboot
For more information about the service status, use the systemctl status sub-command:
1 2 3 4 5 6
sudo systemctl status firewalld ● firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: disabled) Active: active (running) since Thu 1970-01-01 09:01:48 KST; 48 years 6 months ago
sudo firewall-cmd --state
Stop firewalld
To stop firewalld, enter the following command as root:
1
systemctl stop firewalld
To prevent firewalld from starting automatically at system start, enter the following command as root:
1
systemctl disable firewalld
To make sure firewalld is not started by accessing the firewalld D-Bus interface and also if other services require firewalld, enter the following command as root:
1
systemctl mask firewalld
사용해 보기
firewalld 는 명령라인 firewall-cmd 와 GUI로 firewall-config 명령을 지원한다.
Zone 설정
Get a list of all supported zones
1
firewall-cmd --get-zones
List all zones with the enabled features.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
$ firewall-cmd --list-all-zones ...
public target: default icmp-block-inversion: no interfaces: sources: services: ssh dhcpv6-client http https ports: protocols: masquerade: no forward-ports: source-ports: icmp-blocks: rich rules:
기본으로 제공하는 Zone
drop: Any incoming network packets are dropped, there is no reply. Only outgoing network connections are possible.
block: Any incoming network connections are rejected with an icmp-host-prohibited message for IPv4 and icmp6-adm-prohibited for IPv6. Only network connections initiated within this system are possible.
public: For use in public areas. You do not trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.
external: For use on external networks with masquerading enabled especially for routers. You do not trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.
dmz: For computers in your demilitarized zone that are publicly-accessible with limited access to your internal network. Only selected incoming connections are accepted.
work For use in work areas. You mostly trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.
home For use in home areas. You mostly trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.
internal For use on internal networks. You mostly trust the other computers on the networks to not harm your computer. Only selected incoming connections are accepted.