参考https://www.bilibili.com/video/BV1DU4y1Q7nX?vd_source=ed510e307a3219d08a36b11f24056cc9
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
34
35
36
37
38
39
40
41
42
43
|
sudo snap install lxd
sudo /snap/bin/lxd init
➜ ~ sudo /snap/bin/lxc list
To start your first container, try: lxc launch ubuntu:22.04
Or for a virtual machine: lxc launch ubuntu:22.04 --vm
+------+-------+------+------+------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+------+-------+------+------+------+-----------+
➜ ~ sudo lxc remote add tuna-images https://mirrors.tuna.tsinghua.edu.cn/lxc-images/ --protocol=simplestreams --public
➜ ~ sudo lxc image list tuna-images:archlinux
➜ ~ sudo lxc launch tuna-images:333496ddf185 archlinux-container -c security.privileged=true
Creating archlinux-container
Starting archlinux-container
➜ ~ sudo lxc list
+---------------------+---------+-------------------+------+-----------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+---------------------+---------+-------------------+------+-----------+-----------+
| archlinux-container | RUNNING | 10.3.0.154 (eth0) | | CONTAINER | 0 |
+---------------------+---------+-------------------+------+-----------+-----------+
➜ ~ sudo lxc exec archlinux-container passwd
New password:
Retype new password:
passwd: password updated successfully
➜ ~ sudo lxc list
+---------------------+---------+---------------------+------+-----------------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+---------------------+---------+---------------------+------+-----------------+-----------+
| archlinux-container | RUNNING | 10.3.0.154 (eth0) | | CONTAINER | 0 |
+---------------------+---------+---------------------+------+-----------------+-----------+
| archlinux-vm | RUNNING | 10.3.0.160 (enp5s0) | | VIRTUAL-MACHINE | 0 |
+---------------------+---------+---------------------+------+-----------------+-----------+
➜ ~ sudo lxc launch tuna-images:25d3d9408923 archlinux-vm --vm -c security.secureboot=false
Creating archlinux-vm
Starting archlinux-vm
➜ ~ sudo lxc delete archlinux-vm
Error: The instance is currently running, stop it first or pass --force
➜ ~ sudo lxc stop archlinux-vm
➜ ~ sudo lxc stop archlinux-container
➜ ~ sudo lxc stop archlinux-vm
Error: The instance is already stopped
➜ ~ sudo lxc delete archlinux-vm
➜ ~ sudo lxc delete archlinux-container
|