【自学成才系列一】multipass 安装篇
2020-07-03 本文已影响0人
朱大毛
multipass官网
官网下载安装包安装, 过程不表
安装完成,查看版本:
$ multipass version
multipass 1.3.0+mac
multipassd 1.3.0+mac
创建虚拟机
$ multipass launch -n vm01 -c 4 -m 4G -d 40G
Creating vm01
Starting vm01
Waiting for initialization to complete
Launched: vm01
-n, --name: 名称
-c, --cpus: cpu核心数, 默认: 1
-m, --mem: 内存大小, 默认: 1G
-d, --disk: 硬盘大小, 默认: 5G
1、安装时会去在线下载ubuntu最新安装包, 地址: https://cloud-images.ubuntu.com/releases/bionic, 国内访问速度较为感人, 建议走梯子
比如: https://cloud-images.ubuntu.com/releases/bionic/release-20200626/ubuntu-18.04-server-cloudimg-amd64.img
2、目前MacOS还不支持http/file安装方式, 想先下载img文件再安装暂不可行。
launching local images is only currently supported on Linux
详见: https://github.com/canonical/multipass/issues/1029#issuecomment-529126601
$ multipass launch -n vm02 -c 4 -m 4G -d 40G file:///Users/zfj/Downloads/ubuntu-18.04-server-cloudimg-amd64.img
launch failed: http and file based images are not supported
小插曲
创建时忘记指定cpu个数,导致默认1核,运行颇慢,修改cpu数:
原文地址: https://github.com/canonical/multipass/issues/1158#issuecomment-548073024
# 停用multipassd
$ sudo launchctl unload /Library/LaunchDaemons/com.canonical.multipassd.plist
# 修改配置文件
$ sudo vi '/var/root/Library/Application Support/multipassd/multipassd-vm-instances.json'
配置文件示例:
{
"primary": {
...
},
"vm01": {
"deleted": false,
"disk_space": "42949672960",
"mac_addr": "52:54:00:26:63:fb",
"mem_size": "4294967296",
"metadata": {
},
"mounts": [
{
"gid_mappings": [
{
"host_gid": 20,
"instance_gid": -1
}
],
"source_path": "/zfj/vm",
"target_path": "/shared",
"uid_mappings": [
{
"host_uid": 501,
"instance_uid": -1
}
]
}
],
"num_cores": 1,
"ssh_username": "ubuntu",
"state": 4
}
}
修改num_cores这一项,改为想要的cpu核心数,比如:4,保存。
# 启动multipassd
$ sudo launchctl load /Library/LaunchDaemons/com.canonical.multipassd.plist