|
|
## Description
|
|
|
Using LXD Containers to simple & quick create virtualhosts for Oniro testing.
|
|
|
|
|
|
LXD solution is lightweight and does not burden your system like classic virtual machine.
|
|
|
|
|
|
Unlike to Docker it can be usable as full working virtual system in container.
|
|
|
|
|
|
## Intruction
|
|
|
1. Installation and setup of LXD
|
|
|
``` bash
|
|
|
sudo snap install lxd
|
|
|
lxd init # setup size of storage, 120GB is recomended for building tests
|
|
|
# Size in GB of the new loop device (1GB minimum) [default=30GB]: 120
|
|
|
# Keep default values for others settings
|
|
|
```
|
|
|
|
|
|
2. Edit LXC Profile to implement settings
|
|
|
``` bash
|
|
|
lxc profile copy default onirotest-profile
|
|
|
lxc profile edit onirotest-profile
|
|
|
```
|
|
|
3. Insert settings below to lxc profile
|
|
|
``` bash
|
|
|
config:
|
|
|
user.user-data: |
|
|
|
#cloud-config
|
|
|
npackage_upgrade: true
|
|
|
npackages:
|
|
|
- htop
|
|
|
- gawk
|
|
|
- wget
|
|
|
- git
|
|
|
- diffstat
|
|
|
- unzip
|
|
|
- texinfo
|
|
|
- gcc-multilib
|
|
|
- build-essential.
|
|
|
- chrpath.
|
|
|
- socat.
|
|
|
- cpio.
|
|
|
- python3.
|
|
|
- python3-pip
|
|
|
- python3-pexpect
|
|
|
- xz-utils.
|
|
|
- debianutils.
|
|
|
- iputils-ping.
|
|
|
- python3-git.
|
|
|
- python3-jinja2.
|
|
|
- libegl1-mesa.
|
|
|
- libsdl1.2-dev
|
|
|
- pylint3
|
|
|
- xterm..
|
|
|
- file.
|
|
|
- zstd
|
|
|
users:
|
|
|
- default
|
|
|
- onirotest
|
|
|
system_info:
|
|
|
default_user:
|
|
|
name: onirotest
|
|
|
plain_text_passwd: 'onirotest'
|
|
|
home: /home/onirotest
|
|
|
shell: /bin/bash
|
|
|
lock_passwd: True
|
|
|
gecos: Ubuntu
|
|
|
groups: [plugdev, dip, netdev, root, sudo]
|
|
|
```
|
|
|
Settings description
|
|
|
- initialize cloud-config to implement settings
|
|
|
- preinstalled all required host packages from docs (https://docs.oniroproject.org/en/latest/oniro/oniro-quick-build.html#prerequisites)
|
|
|
- auto update packages
|
|
|
- create user 'onirotest'
|
|
|
- adding groups
|
|
|
|
|
|
|
|
|
4. Profile configuration file should looks something like this:
|
|
|
``` yaml
|
|
|
config:
|
|
|
user.user-data: "#cloud-config\npackage_upgrade: true\npackages:\n - htop\n -
|
|
|
gawk \n - wget \n - git \n - diffstat \n - unzip \n - texinfo \n - gcc-multilib\n
|
|
|
\ - build-essential \n - chrpath \n - socat \n - cpio \n - python3 \n - python3-pip
|
|
|
\n - python3-pexpect\n - xz-utils \n - debianutils \n - iputils-ping \n -
|
|
|
python3-git \n - python3-jinja2 \n - libegl1-mesa \n - libsdl1.2-dev\n - pylint3
|
|
|
\n - xterm \n - file \n - zstd\nusers:\n - default\n - onirotest\nsystem_info:\n
|
|
|
\ default_user:\n name: onirotest\n plain_text_passwd: 'onirotest'\n home:
|
|
|
/home/onirotest\n shell: /bin/bash\n lock_passwd: True\n gecos: Ubuntu\n
|
|
|
\ groups: [plugdev, dip, netdev, root, sudo]\n"
|
|
|
description: Default LXD profile
|
|
|
devices:
|
|
|
eth0:
|
|
|
name: eth0
|
|
|
network: lxdbr0
|
|
|
type: nic
|
|
|
root:
|
|
|
path: /
|
|
|
pool: default
|
|
|
type: disk
|
|
|
name: onirotest-profile
|
|
|
used_by: []
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
5. Create & run virtual host Ubuntu 20.04 with 'onirotest-profile' settings
|
|
|
|
|
|
``` bash
|
|
|
lxc launch ubuntu:20.04 virtualhost -p onirotest-profile
|
|
|
lxc exec virtualhost -- sudo --login --user onirotest
|
|
|
#use `exit` to exit
|
|
|
```
|
|
|
|
|
|
Now you can use new virtualhost to testing any things.
|
|
|
|
|
|
You can also simple create new containers using `lxc launch ubuntu:20.04 name_of_your_new_container -p onirotest-profile` or continue work in previous container.
|
|
|
|
|
|
to check runnig containers please use `lxc list`
|
|
|
``` bash
|
|
|
➜ ~ lxc list
|
|
|
+-------------+---------+-----------------------+-----------------------------------------------+-----------+-----------+
|
|
|
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
|
|
|
+-------------+---------+-----------------------+-----------------------------------------------+-----------+-----------+
|
|
|
| virtualhost | RUNNING | 10.123.242.161 (eth0) | fd42:1228:da87:1497:216:3eff:feab:a0f7 (eth0) | CONTAINER | 0 |
|
|
|
+-------------+---------+-----------------------+-----------------------------------------------+-----------+-----------+
|
|
|
```
|
|
|
|
|
|
for more please visit: https://linuxcontainers.org/lxd/advanced-guide/ |
|
|
\ No newline at end of file |