# multipass教程
# How to create an instance
# create a instance
## 创建一个默认实例
$ multipass launch
Launched: enjoyed-coatimundi
## 查看实例详情
$ multipass info enjoyed-coatimundi
Name: enjoyed-coatimundi
State: Running
IPv4: 192.168.64.2
Release: Ubuntu 20.04.4 LTS
Image hash: 75a04c7eed58 (Ubuntu 20.04 LTS)
Load: 0.05 0.15 0.08
Disk usage: 1.4G out of 4.7G
Memory usage: 139.4M out of 976.9M
Mounts: --
# create an instance with a specific image
## 查找可用的镜像
$ multipass find
Image Aliases Version Description
snapcraft:core18 18.04 20201111 Snapcraft builder for Core 18
snapcraft:core20 20.04 20210921 Snapcraft builder for Core 20
snapcraft:core22 22.04 20220426 Snapcraft builder for Core 22
18.04 bionic 20220615 Ubuntu 18.04 LTS
20.04 focal,lts 20220615 Ubuntu 20.04 LTS
21.10 impish 20220616 Ubuntu 21.10
22.04 jammy 20220622 Ubuntu 22.04 LTS
anbox-cloud-appliance latest Anbox Cloud Appliance
charm-dev latest A development and testing environment for charmers
docker latest A Docker environment with Portainer and related tools
minikube latest minikube is local Kubernetes
## 运行ubuntu 18.04, 别称:bionic
$ multipass launch bionic
Launched: intimate-monkey
## 查看实例详情
$ multipass info intimate-monkey
Name: intimate-monkey
State: Running
IPv4: 192.168.64.3
Release: Ubuntu 18.04.6 LTS
Image hash: babb200587b4 (Ubuntu 18.04 LTS)
Load: 0.01 0.04 0.01
Disk usage: 1.1G out of 4.7G
Memory usage: 73.1M out of 985.6M
Mounts: --
# create an instance with a custom name
## 使用--name参数指定创建实例的名字
$ multipass launch bionic --name test111
Launched: test111
# create an instance with custom cpu number, disk, and RAM
## 使用--cpu, --disk, --mem来指定创建实例的cpu核数、磁盘大小、内存大小
$ multipass launch bionic --name test222 --cpu 4 --disk 20G --mem 8G
Launched: test222
# create an instance with primary status
## 如果实例名称为primary 则此实例为默认实例
$ multipass launch 18.04 --name primary
Launched: primary
Mounted '/Users/bingbing.fu' into 'primary:Home'
## 查看实例信息
$ multipass info primary
Name: primary
State: Running
IPv4: 192.168.64.5
Release: Ubuntu 18.04.6 LTS
Image hash: babb200587b4 (Ubuntu 18.04 LTS)
Load: 0.54 0.24 0.09
Disk usage: 1.2G out of 4.7G
Memory usage: 108.5M out of 985.6M
Mounts: /Users/bingbing.fu => Home
UID map: 501:default
GID map: 20:default
# other condition to create an instance.
# How to use an instance
# open a shell prompt inside an instance
## 查看实例列表
$ multipass list
Name State IPv4 Image
primary Running 192.168.64.5 Ubuntu 18.04 LTS
enjoyed-coatimundi Running 192.168.64.2 Ubuntu 20.04 LTS
intimate-monkey Running 192.168.64.3 Ubuntu 18.04 LTS
test111 Running 192.168.64.4 Ubuntu 18.04 LTS
## 登录实例shell
$ multipass shell test111
Welcome to Ubuntu 18.04.6 LTS (GNU/Linux 4.15.0-187-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
System information as of Tue Jul 5 09:22:20 CST 2022
System load: 0.08 Processes: 91
Usage of /: 23.9% of 4.67GB Users logged in: 0
Memory usage: 12% IP address for enp0s2: 192.168.64.4
Swap usage: 0%
* Super-optimized for small spaces - read how we shrank the memory
footprint of MicroK8s to make it the smallest full K8s around.
https://ubuntu.com/blog/microk8s-memory-optimisation
0 updates can be applied immediately.
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
## multipass shell默认登录primary实例
$ multipass shell
Welcome to Ubuntu 18.04.6 LTS (GNU/Linux 4.15.0-187-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
System information as of Tue Jul 5 09:23:32 CST 2022
System load: 0.0 Processes: 101
Usage of /: 25.0% of 4.67GB Users logged in: 0
Memory usage: 16% IP address for enp0s2: 192.168.64.5
Swap usage: 0%
* Super-optimized for small spaces - read how we shrank the memory
footprint of MicroK8s to make it the smallest full K8s around.
https://ubuntu.com/blog/microk8s-memory-optimisation
0 updates can be applied immediately.
New release '20.04.4 LTS' available.
Run 'do-release-upgrade' to upgrade to it.
ubuntu@primary:~$
# Exec a command inside an instance
## exec 命令用来远程调用执行实例的命令
$ multipass exec test111 -- pwd
/home/ubuntu
# Start an instance
## 启动实例
$ multipass start test111
## 查看启动后的实例状态
$ multipass info test111
Name: test111
State: Running
IPv4: 192.168.64.4
Release: Ubuntu 18.04.6 LTS
Image hash: babb200587b4 (Ubuntu 18.04 LTS)
Load: 0.72 0.16 0.05
Disk usage: 1.3G out of 4.7G
Memory usage: 91.7M out of 985.6M
Mounts: --
## 启动多个实例
$ multipass start test111 test112 test113
## 启动所有的实例
$ multipass start -all
# Stop an instance
## 停止实例
$ multiopass stop test111
## 查看停止后的实例状态
$ multipass info test111
Name: test111
State: Stopped
IPv4: --
Release: --
Image hash: babb200587b4 (Ubuntu 18.04 LTS)
Load: --
Disk usage: --
Memory usage: --
Mounts: --
## 停止多个实例
$ multipass start test111 test112 test113
## 停止所有的实例
$ multipass start --all
# Suspend an instance
## 挂起实例
$ multipass suspend test111