Odroid-HC2 (or ARM)에 LXD & LXC 설치하기



  Environment
    Device : Odroid-HC2
    OS : Ubuntu-20.04




1. Odroid-HC2에 LXD & LXC 설치


1) LXD & LXC 설치
$ sudo apt install lxc lxd lxd-client -y
2) LXD 그룹 추가
$ sudo usermod -aG lxd $USER
3) LXD 초기 설정
$ sudo lxd init
Would you like to use LXD clustering? (yes/no) [default=no]:
Do you want to configure a new storage pool? (yes/no) [default=yes]:
Name of the new storage pool [default=default]: Name of the storage backend to use (btrfs, dir, lvm, zfs, ceph) [default=zfs]:
Create a new ZFS pool? (yes/no) [default=yes]:
Would you like to use an existing empty block device (e.g. a disk or partition)? (yes/no) [default=no]:
Size in GB of the new loop device (1GB minimum) [default=5GB]:
Would you like to connect to a MAAS server? (yes/no) [default=no]:
Would you like to create a new local network bridge? (yes/no) [default=yes]:
What should the new bridge be called? [default=lxdbr0]:
What IPv4 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]:
What IPv6 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]:
Would you like LXD to be available over the network? (yes/no) [default=no]:
Would you like stale cached images to be updated automatically? (yes/no) [default=yes]
Would you like a YAML "lxd init" preseed to be printed? (yes/no) [default=no]:

2. LXC & LXD 관리

1) LXC 이미지 검색
$ lxc image list imageserver:imagename
Ex)
$ lxc image list images:centos
$ lxc image list ubuntu:20.04
$ lxc image list ubuntu:
2) LXC 이미지 정보 확인
$ lxc launch imageserver:imagename instancename
Ex)
$ lxc image info images:centos/7/armhf
$ lxc image info images:centos/8/arm64
$ lxc image info ubuntu:20.04/arm64
3) LXC 이미지 설치
$ lxc launch imageserver:imagename instancename
Ex)
$ lxc launch ubuntu:20.04/arm64 u2004
$ lxc launch images:centos/8/arm64 cen8
4) LXC 이미지 bash 접근
$ lxc exec instancename -- /bin/bash
Ex)
$ lxc exec u2004 -- /bin/bash
5) 로컹 서버내 컨테니어 리스트 확인
$ lxc list
6) 컨테이너 정보 확인
$ lxc list u2004
7) 컨테이너 기동
$ lxc start instancename
Ex)
$ lxc start u2004
8) 컨테이너 중단
$ lxc stop instancename
Ex)
$ lxc stop u2004
9) 컨테이너 삭제
$  lxc delete instancename
Ex)
$ lxc delete u2004