WSL2 잘 사용하기

WSL2 이용 Linux 사용시 쓸만한 팁

  1. wsl 사용 명령
  2. WSL 쉘 사용
  3. wsl 하위 시스템 디렉토리
  4. wsl 구성 파일
  5. wsl 외부 디스크 마운트 하기
  6. wsl 배포본 이름 변경하기

1. wsl 사용 명령

윈도우즈 하위 시스템 목록

1
2
3
4
5
# Linux용 Windows 하위 시스템의 목록
PS> wsl -l

# Linux용 Windows 하위 시스템의 상태를 표시
PS> wsl --status

wsl 재시작

혹은 윈도우 서비스를 재시작할 수 있다. Windows에서 PowerShell을 관리자 권한으로 열고 다음 명령을 실행하면 됩니다.

1
PS> Restart-Service LxssManager

wsl 종료

하위 시스템 배포본을 지정해 종료하려면 -t <Distro> 명령을 사용한다.

1
2
3
4
PS> wsl -l
Ubuntu-20.04(기본값)

PS> wsl -t Ubuntu-20.04

wsl shutdown

모든 하위 시스템을 종료 시키려면 --shutdown 명령을 사용한다. --shutdown 명령은 실행 중인 모든 배포과 WSL 2 경량 유틸리티 가상 머신을 즉시 종료한다.

1
PS> wsl --shutdown

Unregister

Window store 에서 설치한 배포본을 삭제해도 wsl 의 Distro 목록에는 남아 있다. 이것은 --unregistre 명령으로 제거할 수 있다.

1
2
3
4
PS> wsl -l --all
Linux용 Windows 하위 시스템 배포:
Ubuntu-20.04(기본값)
Ubuntu-22.04

--unregistre 명령으로 제거한 Distro 등록을 해제한다.

1
2
3
4
5
6
7
PS> wsl --unregister Ubuntu-22.04
등록 취소 중입니다.
작업을 완료했습니다.

PS> wsl -l
Linux용 Windows 하위 시스템 배포:
Ubuntu-20.04(기본값)

2. WSL 쉘 사용

--system : 현재 시스템의 distro의 셸을 시작한다.

1
2
3
4
5
PS> wsl --system
wslg [ /mnt/c/Users/daddy ]$ cd
wslg [ ~ ]$
wslg [ ~ ]$ exit
logout

--exec, -e: 시스템 distro의 명령을 현재 PowerShell에서 실행한다.

1
2
3
PS> wsl -e bash
()qkboo:/mnt/c/Users/daddy$ cd
()qkboo:~$

wsl IP 주소

1
wsl hostname -I

2. WSL 하위 시스템 디렉토리

윈도우즈와 하위 시스템의 디렉토리를 Host 의 프로그램 들에서 사용할 수 있다.

탐색기에서 직접 접근하기

윈도우즈에서 네트워크 경로로 WSL 하위 시스템 디렉토리를 접근할 수 있다.

1
\\wsl$\<Distribution>:

예를 들어 하위 시스템 이름이 Ubuntu-20.04 이고 계정이 qkboo 이라면 탐색기에서 qkboo 계정의 홈디렉토리를 이렇게 접그할 수 있다.

1
\\wsl$\Ubuntu-20.04\home\qkboo

아래는 윈도우즈 탐색기에서 wsl 홈디렉토리를 접근한 캡쳐 화면인다.

터미널에서 홈디렉토리 탐색기 열기

터미널에서 윈도우즈 탐색기를 직접 열 수 있다.

1
$ explorer.exe .

VisualStudio Code 에서 현재 디렉토리를 연다.

1
$ code.exe .

3. WSL 고급 설정 구성

배포본 구성 파일 wsl.conf 와 전역 구성 파일 .wslconfig 이 있다.

전역 구성 파일 .wslconfig

wslconfig 예제 파일

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# 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

# Disables nested virtualization
nestedVirtualization=false

# Turns on output console showing contents of dmesg when opening a WSL 2 distro for debugging
debugConsole=true

배포본 구성 파일 wsl.conf

  • 위치: /etc/wsl.conf
  • wsl1, wsl2 배포본에 대한 구성을 지정한다.
  • 단, Windows 빌드 17093 이상에서만 사용할 수 있다.
  • systemd 지원
  • automount 지원
    DrvFS 지원
    interop 설정 등등
  • wsl.conf 구성 설정

wsl.conf 예제

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# 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 파티션 디스크를 마운트해서 사용하려고 한다.

  1. 관리자 모드에서 Powershell 을 연다.

파워쉘에서 연결된 디스크 목록을 확인한다.

1
2
3
4
5
6
7
PS> GET-CimInstance -query "SELECT * from Win32_DiskDrive"

DeviceID Caption Partitions Size Model
-------- ------- ---------- ---- -----
\\.\PHYSICALDRIVE0 ST2000DM008-2FR102 1 2000396321280 ST2000DM008-2FR102
\\.\PHYSICALDRIVE1 WDS500G3X0C-00SJG0 4 500105249280 WDS500G3X0C-00SJG0
\\.\PHYSICALDRIVE2 ATA HGST HTS721010A9 USB Device 1 1000202273280 ATA HGST HTS721010A9...
  1. 관리자 모드 PowerShell 에서 마운트할 Device ID를 마운트 한다.

--bare 를 사용해 마운트 여부를 확인할 수 있다.

1
PS> wsl --mount \\.\PHYSICALDRIVE2 --bare
  1. WSL 리눅스 터미널에서 디스크를 확인한다.

아래 같이 마운트를 실행한다.

1
2
3
4
PS> wsl --mount \\.\PHYSICALDRIVE2 -type ext4
디스크가 '/mnt/wsl/PHYSICALDRIVE2'(으)로 탑재되었습니다.
참고: /etc/wsl.conf에서 automount.root 설정을 수정한 경우 위치가 달라집니다.
디스크를 분리하고 분리하려면 'wsl.exe --unmount \\.\PHYSICALDRIVE2'을 실행하십시오.

파티션을 마운트 한다면

1
2
3
4
PS> wsl --mount \\.\PHYSICALDRIVE2 -p 1   # partition 1
디스크가 '/mnt/wsl/PHYSICALDRIVE2p1'(으)로 탑재되었습니다.
참고: /etc/wsl.conf에서 automount.root 설정을 수정한 경우 위치가 달라집니다.
디스크를 분리하고 분리하려면 'wsl.exe --unmount \\.\PHYSICALDRIVE2'을 실행하십시오.

연결된 디스크가 sdd 에 표시된다.

1
2
3
4
5
6
7
~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 363.1M 1 disk
sdb 8:16 0 8G 0 disk [SWAP]
sdc 8:32 0 256G 0 disk /mnt/wslg/distro
sdd 8:48 0 931.5G 0 disk
└─sdd1 8:49 0 931.5G 0 part

어떠 파일 시스템인지 확인하려면 lsblk -f 명령을 사용한다.

1
2
3
4
5
6
7
8
~$ lsblk -f
NAME FSTYPE LABEL UUID FSAVAIL FSUSE% MOUNTPOINT
sda ext4
sdb swap 44bcbb9a-3a2c-44db-99e4-9c14dec69098 [SWAP]
sdc ext4 3255683f-53a2-4fdf-91cf-b4c1041e2a62 159.1G 32% /mnt/wslg/distro
sdd
└─sdd1 ext4 9b3c51ab-a49b-41c7-a105-fb9d47a86476
(3.11.1)qkboo@desktop-goyangi:~$

df 명령으로 확인해 보자,

1
2
3
4
5
6
7
8
9
10
s$ df -h
Filesystem Size Used Avail Use% Mounted on
none 16G 4.0K 16G 1% /mnt/wsl
drivers 465G 397G 69G 86% /usr/lib/wsl/drivers
none 16G 0 16G 0% /usr/lib/wsl/lib
/dev/sdc 251G 80G 160G 34% /

...

/dev/sdd1 917G 852G 19G 98% /mnt/wsl/PHYSICALDRIVE2p1

6. 배포본 이름 변경하기

  1. 먼저 모든 WSL 실행 배포본을 종료한다.

현재 배포본 Ubuntu 20.04 인데 do-os-relase 업그레이드로 22.04 로 완료된 상태이다. 하지만 배포본 이름은 20.04 라서 이름을 22.04 로 변경하려고 한다.

1
2
3
PS> wsl -l
Linux용 Windows 하위 시스템 배포:
Ubuntu-20.04(기본값)
  1. 레지스트리 편집기를 열고 다음 위치로 이동한다.

HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss

  1. Lxss 항목 중 배포본 레지스트리를 선택하면 아래 같은 내용에서 *DistributionName 을 찾아 변경한 배포본 이름으로 바꾸고 저장한다.
  1. 변경된 이름을 저장하고 wsl 배포본 목록을 확인한다.
1
2
3
PS> wsl -l
Linux용 Windows 하위 시스템 배포:
Ubuntu-22.04(기본값)

— 참고

  1. WSL 시작하기: https://github.com/wslhub/wsl-firststep/

openSUSE: firewalld

firewalld 를 이용해서 방화벽을 구성해 보자.

  • 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.

https://www.ctrl.blog/entry/ufw-vs-firewalld

firewalld 설치

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.
  • trusted
    All network connections are accepted.

Zone

1
2
sudo firewall-cmd --get-default-zone
public

서비스

This command prints a space separated list.

Get a list of all supported services

1
$ firewall-cmd --get-services

This command prints a space separated list.

Get a list of all supported icmptypes

1
firewall-cmd --get-icmptypes

서비스를 제거하려면

1
2
3
4
# firewall-cmd --zone=public --remove-service=http
success
root@odroidc2:/home/qkboo# firewall-cmd --zone=public --remove-service=https
success

Http, Ssh 방화벽 활성화

http, https 를 공개 서비스를 지원하는 기본 존인 public에 추가한다.

1
2
3
sudo firewall-cmd --add-service=ssh
sudo firewall-cmd --add-service=http
sudo firewall-cmd --add-service=https

sudo firewall-cmd –zone=public –add-service=http –permanent

방화벽을 갱신한다

1
2
firewall-cmd --reload
firewall-cmd --state

혹은 zone을 지정해 추가한다.

1
2
3
4
sudo firewall-cmd --zone=web --add-service=ssh
sudo firewall-cmd --zone=web --add-service=http
sudo firewall-cmd --zone=web --add-service=https
sudo firewall-cmd --zone=web --list-all

Likewise, we can add the DNS service to our “privateDNS” zone:

1
2
sudo firewall-cmd --zone=privateDNS --add-service=dns
sudo firewall-cmd --zone=privateDNS --list-all

Zone 에 구성한 서비스 등은 런타임 혹은 완전히 방화벽에 구성할 수 있다.

To change settings in both modes, you can use two methods:
Change runtime settings and then make them permanent as follows:

1
2
firewall-cmd <other options>
firewall-cmd --runtime-to-permanent

Set permanent settings and reload the settings into runtime mode:

1
2
firewall-cmd --permanent <other options>
firewall-cmd --reload

모든 구성 내용 확인:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
$ sudo firewall-cmd --list-all
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 에 대한 내역을 출력한다:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$ sudo firewall-cmd --zone=public --list-all
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:

참조

https://www.linode.com/docs/security/firewalls/introduction-to-firewalld-on-centos/

FirewallD

Firewalld configuration and usage

Raspberry Pi: mmcblk

mmcblk

SD/MMC card 는 MMC 서브시스템을 /dev/mmcblk{id} 형식으로 블럭 장치로 사용한다.

dmesg 로 부트 메시지를 보면 SDHCI 인터페이스에 장착한 장치를 확인할 수 있다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
[    0.789621] sdhci: Secure Digital Host Controller Interface driver
[ 0.789628] sdhci: Copyright(c) Pierre Ossman
[ 0.789999] sdhost-bcm2835 3f202000.sdhost: could not get clk, deferring probe
[ 0.790252] sdhci-pltfm: SDHCI platform and OF driver helper
[ 0.791051] ledtrig-cpu: registered to indicate activity on CPUs
[ 0.791232] hidraw: raw HID events driver (C) Jiri Kosina
[ 0.791461] usbcore: registered new interface driver usbhid
[ 0.791467] usbhid: USB HID core driver
[ 0.792448] vchiq: vchiq_init_state: slot_zero = 0xb6980000, is_master = 0
[ 0.794533] Initializing XFRM netlink socket
[ 0.794566] NET: Registered protocol family 17
[ 0.794724] Key type dns_resolver registered
[ 0.795223] Registering SWP/SWPB emulation handler
[ 0.796192] registered taskstats version 1
[ 0.796681] vc-sm: Videocore shared memory driver
[ 0.796694] [vc_sm_connected_init]: start
[ 0.802967] [vc_sm_connected_init]: end - returning 0
[ 0.809343] 3f201000.serial: ttyAMA0 at MMIO 0x3f201000 (irq = 87, base_baud = 0) is a PL011 rev2
[ 0.809410] console [ttyAMA0] enabled
[ 0.811406] sdhost: log_buf @ b6913000 (f6913000)
[ 0.889149] mmc0: sdhost-bcm2835 loaded - DMA enabled (>1)
[ 0.889333] of_cfs_init
[ 0.889478] of_cfs_init: OK
[ 0.890211] Waiting for root device /dev/mmcblk0p2...
[ 0.956566] mmc0: host does not support reading read-only switch, assuming write-enable
[ 0.958563] mmc0: new high speed SDHC card at address 59b4
[ 0.959555] mmcblk0: mmc0:59b4 00000 14.9 GiB
[ 0.961428] mmcblk0: p1 p2

메시지에서 보듯 mmc0 장치에 카드가 삽입되기 전에 인터럽트가 없다.

1
2
$ cat /proc/interrupts |grep mmc
86: 393 0 0 0 ARMCTRL-level 88 Edge mmc0

https://developer.toradex.com/knowledge-base/sd-mmc-card-(linux)

Raspberry Pi : Digital Signage

Digital Signage

라즈베리파이에서 슬라이드쇼 구현해 보자.

py-slideshow

https://github.com/cgoldberg/py-slideshow/

pyglet 으로 이미지를 패닝, 확대 효과를 가진 슬라이드 쇼.

Screenly OSE

Screenly Open Source Edition은 디지털 시그네이지 소프트웨어 이다.

Disk images

The recommended installation method is to grab the latest disk image from here

라즈비안에서 설치

Raspbian Lite 에서 설치를 할 수 있다.

먼저

sudo apt install -y network-manager

1
2
3
4
5
6
7
8
9
10
11
$ bash <(curl -sL https://www.screenly.io/install-ose.sh)
_____ __ ____ _____ ______
/ ___/_____________ ___ ____ / /_ __ / __ \/ ___// ____/
\__ \/ ___/ ___/ _ \/ _ \/ __ \/ / / / / / / / /\__ \/ __/
___/ / /__/ / / __/ __/ / / / / /_/ / / /_/ /___/ / /___
/____/\___/_/ \___/\___/_/ /_/_/\__, / \____//____/_____/
/____/
Screenly OSE requires a dedicated Raspberry Pi / SD card.
You will not be able to use the regular desktop environment once installed.

Do you still want to continue? (y/N)
1
Would you like to use the experimental branch? It contains the last major changes, such as the new browser and migrating to Docker (y/N)

It looks like NetworkManager is not installed. Please install it by running ‘sudo apt install -y network-manager’ and then re-run the installation.

1
Would you like to perform a full system upgrade as well? (y/N)

설치를 시작하면 15분 이상이 소요된다.
This installation will take 15 minutes to several hours, depending on variables such as:

1
2
Installation completed.
You need to reboot the system for the installation to complete. Would you like to reboot now? (y/N)

pipresent

python2 기반이고, 실행이 안됐다.

https://pipresents.wordpress.com

https://github.com/KenT2/pipresents-beep

Requirements
  • must use the latest version of Raspbian Stretch with Desktop (not the Lite version)
  • must be run from the PIXEL desktop.
  • must be installed and run from user Pi

install

required packages

1
2
sudo apt install python-imaging python-pil.imagetk python-pexpect
sudo apt install unclutter mplayer uzbl

optional packages

sudo pip install evdev (if you are using the input device I/O plugin)
sudo apt-get install mpg123 (for .mp3 beeps)

1
wget https://github.com/KenT2/pipresents-beep/tarball/master -O - | tar xz

Dead-simple Digital menu

https://github.com/angryrancor/ezdmb

Raspberry Pi 3 64bit OS openSUSE: Service 관리

Upgrade OpenSUSE LEAP 42.2 to LEAP 15

https://en.opensuse.org/SDB:System_upgrade

OpenSUSE LEAP 42.2를 LEAP 15.0으로 업그레이드 하려고 한다.

[그림. 지원 중단 배포본 (OpenSUSE)]

Upgrade

Update repository

다음 명령으로 현재 배포본의 Repository Url이 활성화 되어 있는지 확인한다.

1
2
3
4
5
6
7
8
# zypper repos --uri

Repository priorities are without effect. All enabled repositories share the same priority.

# | Alias | Name | Enabled | GPG Check | Refresh | URI
--+-----------------------------------+-----------------------------------+---------+-----------+---------+----------------------------------------------------------------------------
1 | openSUSE-Ports-Leap-42.2-Update | openSUSE-Ports-Leap-42.2-Update | Yes | (r ) Yes | Yes | http://download.opensuse.org/ports/update/42.2/
2 | openSUSE-Ports-Leap-42.2-repo-oss | openSUSE-Ports-Leap-42.2-repo-oss | Yes | (r ) Yes | Yes | http://download.opensuse.org/ports/aarch64/distribution/leap/42.2/repo/oss/

42.2 저장소 백업하고,

1
# cp -Rv /etc/zypp/repos.d /etc/zypp/repos.d.Old

42.2 를 15.0 으로 변경하자,

1
# sed -i 's/42.2/15.0/g' /etc/zypp/repos.d/*

업데이트 저장소 위치가 다르기 때문에 zypper repos --uri 에서 openSUSE-Ports-Leap-15.2-Update 를 삭제한다.

1
zypper rr 1

그리고 openSUSE-Ports-Leap-15.0-Update 를 추가한다.

1
zypper addrepo --check --refresh --name 'openSUSE-Leap-15.0-Update' http://download.opensuse.org/update/leap/15.0/oss/ repo-update

15.2 저장소가 제대로 들어갔는지 확인한다.

1
2
3
4
5
6
7
# zypper repos --uri
Repository priorities are without effect. All enabled repositories share the same priority.

# | Alias | Name | Enabled | GPG Check | Refresh | URI
--+-----------------------------------+-----------------------------------+---------+-----------+---------+----------------------------------------------------------------------------
1 | openSUSE-Ports-Leap-15.0-repo-oss | openSUSE-Ports-Leap-15.0-repo-oss | Yes | (r ) Yes | Yes | http://download.opensuse.org/ports/aarch64/distribution/leap/15.0/repo/oss/
2 | repo-update | openSUSE-Leap-15.0-Update | Yes | ( p) Yes | Yes | http://download.opensuse.org/update/leap/15.0/oss/

결과에서 repo-update 가 Enabled 컴럼이 Yes 인지 확인한다. 만약 No 라면 다음 명령으로 활성화 한다.

1
zypper modifyrepo --enable repo-update

Update repository

zypper ref

Distribution Upgrade

1
2
3
4
5
6
7
8
# zypper dup
...

613 packages to upgrade, 170 to downgrade, 340 new, 103 to remove, 6 to change
arch.
Overall download size: 658.0 MiB. Already cached: 0 B. After the operation,
additional 774.1 MiB will be used.
Continue? [y/n/...? shows all options] (y): y

homepi64:~ # reboot
[11840.081284] reboot: Restarting system
MMC: mmc@7e202000: 0, mmc@7e300000: 1
Loading Environment from FAT… *** Warning - bad CRC, using default environment

진행중 42.2와 충돌하는 패키지가 표시되는데 모둔 1로 설치했다.

1
2
3
4
5
6
7
8
9
10
11
12
4 Problems:
Problem: nothing provides tar = 1.30 needed by tar-lang-1.30-lp150.2.3.2.noarch
Problem: nothing provides python3-dbus-python needed by snapper-zypp-plugin-0.5.4-lp150.3.3.1.noarch
Problem: nothing provides libgphoto2-6 = 2.5.18 needed by libgphoto2-6-lang-2.5.18-lp150.2.3.1.noarch
Problem: nothing provides gpg2 = 2.2.5 needed by gpg2-lang-2.2.5-lp150.3.3.1.noarch

Problem: nothing provides tar = 1.30 needed by tar-lang-1.30-lp150.2.3.2.noarch
Solution 1: deinstallation of tar-lang-1.27.1-11.1.noarch
Solution 2: keep obsolete tar-lang-1.27.1-11.1.noarch
Solution 3: break tar-lang-1.30-lp150.2.3.2.noarch by ignoring some of its dependencies

Choose from above solutions by number or skip, retry or cancel [1/2/3/s/r/c] (c):1

재시동

업그레이드를 설치한 후에 재시동 하면 약 5분 정도 펌웨어 등을 설치하는 과정을 거친다. 로그인해서 버전을 확인해 보자

qkboo@homepi64:~> uname -a
Linux homepi64 4.4.104-18.44-default #1 SMP Thu Jan 4 08:07:55 UTC 2018 (05a9de6) aarch64 aarch64 aarch64 GNU/Linux

~> uname -a
Linux homepi64 4.4.104-18.44-default #1 SMP Thu Jan 4 08:07:55 UTC 2018 (05a9de6) aarch64 aarch64 aarch64 GNU/Linux

https://en.opensuse.org/SDB:Find_openSUSE_version

Getting Started `firewalld`

RedHat, CentOS, Fedora 배포본 등에서 표준 방화벽 인터페이스로 제공되는 최신 FirewallD 사용을 시작해 보자. firewalld 패키지 설치는 각 배포본의 방법으로 설치하면 된다.

여기서는 OpenSUSE, Armbian 배포본을 설치한 시스템에서 firewalld 방화벽을 구성하고 설정하는 과정을 요약 정리했다.

자세히 보기

Raspberry Pi : Upgrade OpenSUSE LEAP 42.2 to 42.3

Raspberry Pi 3 에 설치해 사용중이던 openSUSE LEAP 42.2의 지원이 종료되어, 2019년가지 지원하는 LEAP 42.3으로 업그레이드하는 과정을 정리했다.

openSUSE는 LEAP 15.0으로 최신 버전으로 배포하고 있다. 42.2에서 15.0으로 바로 업그레이드시 내가 해결 못하는 문제가 생겨서 42.3으로 업그레이드 했다.

자세히 보기

Naver ncloud 설정

ncloud 서비스

sudoer 설정

새 사용자를 추가하고 suder 로 등록한 후에 사용한다. 우분투/데비안 계열 새 사용자 추가는 Odroid Install 문서를 참고한다.

새 사용자 등록

adduser 추가할 사용자에 대한 정보를 하나씩 묻고, 사용자 홈 디렉토리가 생성된다. 추가한 사용자에 대한 /etc/passwd, /etc/shadow, /etc/group and /etc/gshadow 편집이 된다

추가하고 패스워드를 입력한다.

1
2
# adduser USERNAME
# sudo passwd USERNAME

그리고 suder로 등록해 준다.

sudoer 등록

usermod 혹은 visudo 를 사용할 수 있다.

1
# usermod -aG sudo USERNAME

hostname 확인

hostname 명령에 따라 현재 호스트 이름이 /etc/hosts 혹은 dns resolver에서 검색되야 한다.

1
2
$ sudo systemcgl status nginx
sudo: unable to resolve host ubuntu-84

위 같은 경고가 나타난다면 호스트 이름을 /etc/hosts 에 등록해 준다.

ssh

서버에

1
$ ssh-keygen -t rsa -b 4096 -C "USER@localhost"

위 2 과정을 아래 명령 한 줄로 복사->붙여넣기를 동시에 할 수 있다.

클라이언트:

1
cat ~/.ssh/id_rsa.pub | ssh <USERNAME>@<IP-ADDRESS> 'cat >> .ssh/authorized_keys'

mongod-org 설치

커뮤티티에디션 설치

네이버 NCloud에서 Micro server를 하나 생성한 후에, MongoDB Community Edition을 설치했고, ncloud의 Ubuntu 16.01 이미지로 서버를 생성한 후에 업그레이드해서 16.04.4 LTS 버전에서 설치했다.

설정

mongodb 설정
mongodb auth

현재 실행중인 mongod 를 종료한다.

sudo systemctl stop mongod.service

MongoDB 설정
Mongo Database를 사용하기 위해서 데이터 파일 위치, 로그, 포트, Ip 주소 등에 대한 구성을 mongod.conf 에서 할 수 있다. 수정된 구성이 작동하는지 mongo 클라이언트로 접속해서 테스트한다.

mongod.conf

/etc/mongod.conf 파일에 인증을 제외한 데이터 디렉토리, bindIp, 로그 부분만 설정한다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  dbPath: /data/mongodata/
journal:
enabled: true

systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log

processManagement:
fork: true

net:
port: 27017
bindIp: 0.0.0.0

설정을 저장하고 명령 라인에서 MongoDB를 다시 시작한 후에 mongo client로 접속한다.

모든 인터페이스에 db 접속을 허용하면 bindIpAll: true 를 사용한다.

1
$ sudo mongod --port 27017 --dbpath /var/lib/mongodb

이어서 클라이언트로 데이터베이스에 접속한다.접속에 성공하면 > 프롬프트가 나온다.

1
2
$mongo
>

admin 계정

mongod 에서 데이터베이스 및 사용자를 관리할 admin 이란 관리자를 추가하자

1
2
3
> use admin
switched to db admin
>

관자자의 권한과 역할을 선언한다.

1
2
3
4
5
6
7
8
>db.createUser(
{
user:'admin',
pwd:'****',
roles:['userAdminAnyDatabase']
}
)
Successfully added user: { "user" : "admin", "roles" : [ "userAdminAnyDatabase" ] }

사용자의 role 을 변경,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
> db.grantRolesToUser( 'admin', [{role: 'userAdmin', db:'admin'}])
> db.getUsers()
[
{
"_id" : "admin.admin",
"user" : "admin",
"db" : "admin",
"roles" : [
{
"role" : "userAdmin",
"db" : "admin"
},
{
"role" : "userAdminAnyDatabase",
"db" : "admin"
}
]
}
]

관리자 admin 계정을 admin 데이터베이스에 추가한 후에 mongo client로 admin 계정으로 로그인해서 …

터미널에서 시작한 mongod 를 종료한다.

수동으로 mongod 를 시작하면 root 계정으로 데이터 파일이 생성된다. systemctl로 서비스 시작 전에 data 폴더 퍼미션을 맞춰준다.

Directory permissions
로그 디렉토리 /var/log/mongo 그리고 데이터 디렉토리 /data/mongodata 라면 해당 디렉토리에 몽고디비 사용자가 쓸 수 있는 퍼미션을 준다.

1
2
$ sudo chown mongo.daemon /var/log/mongodb
$ sudo chown mongodb.mongodb /data/mongodata

데이터베이스 사용자 추가

데이터베이스를 생성하고 해당 데이터베이스를 접속하는 사용자 계정을 추가하자.

수동으로 접근제어 –auth 옵션으로 데이터베이스를 시작하면, mongo 클리이언트 로그인시 -u , -p 와 –authenticationDatabase 를 지정해 주어야 한다.

1
$ mongo --port 27017 -u "admin" -p "****" --authenticationDatabase "admin"

The following operation creates accountUser in the products database and gives the user the readWrite and dbAdmin roles.

1
2
3
4
5
6
7
8
9
use products
db.createUser(
{
user: "accountUser",
pwd: "password",
roles: [ "readWrite", "dbAdmin" ]
}
)```

Raspberry Pi : Raspbian 설치준비

이 글은 Raspberry Pi Programming 과정을 진행하며 강의한 자료를 바탕으로 공개강의를 위한 텍스트로 슬라이드쉐어, blog.thinkbee.kr 그리고 실제 과정을 영상 youtube 채널에 공개할 목적으로 작성한다.

Install Rasbperry Pi 글타래는 아래 같이 구성되며 간단한 소개, Serial console, OS 설치, Service 구성 및 사용에 대해 작성했다.

  1. Raspberry Pi 설치준비
  2. Install Raspbian OS
  3. Managing Service daemon
  4. Basic OS Security for Server
  5. Install & Configuration - Nginx, Node JS, Jupyter
자세히 보기
marginless" target="_blank" rel="noopener" title="Dribbble" href="https://dribbble.com">