一提到虚拟机大家一般都会想到VMvare和Virtual Box这两个的虚拟机软件,这两个软件一个比较麻烦的地方是安装完虚拟机以后还需要下载操作系统镜像。小编偶然间发现了Multipass。这款轻量级的虚拟机管理器,仅需一个命令就可以快速安装Ubuntu 环境。
Multipass是一个轻量虚拟机管理器是由Ubuntu官方运营的公司Canonical推出的开源项目。运行环境支持Linux,并且提供了一个命令行界面来启动和管理Linux实例。下载一个全新的镜像需要几秒钟的时间,并且在几分钟内就可以启动并运行VM。
功能特点
Multipass支持跨平台,所以可以在Linux、 Windows 和 macOS上进行安装,本文采用Win10操作系统来进行Multipass安装等相关知识的介绍。
本质上而言,Multipass用于管理各平台上的虚拟机引擎,例如:
Hyper-V 和 VirtualBox(Windows)KVM(Linux)HyperKit(macOS)
所以使用前需要安装相应的虚拟机引擎,再通过Multipass进行管理。
通过官网下载免费的Virtual Box并安装。
下载地址:
安装包非常小,仅有20多M。
双击安装,接着下一步即可。
我安装过Virtual Box,所以选择了【Oracle VM Virtual Box】
添加环境变量。
选择安装路径。
安装
安装完成之后就可以使用了。
在命令行输入multipass,可以获得Multipass的使用帮助。
C:\Users\Administrator>multipass
Usage: multipass [options] <command>
Create, control and connect to Ubuntu instances.
This is a command line utility for multipass, a
service that manages Ubuntu instances.
Options:
-?, -h, --help Displays help on commandline options.
--help-all Displays help including Qt specific options.
-v, --verbose Increase logging verbosity. Repeat the 'v' in the short
option for more detail. Maximum verbosity is obtained with 4
(or more) v's, i.e. -vvvv.
Available commands:
alias Create an alias
aliases List available aliases
authenticate Authenticate client
delete Delete instances
exec Run a command on an instance
find Display available images to create instances from
get Get a configuration setting
help Display help about a command
info Display information about instances
launch Create and start an Ubuntu instance
list List all available instances
mount Mount a local directory in the instance
networks List available network interfaces
purge Purge all deleted instances permanently
recover Recover deleted instances
restart Restart instances
set Set a configuration setting
shell Open a shell on a running instance
start Start instances
stop Stop running instances
suspend Suspend running instances
transfer Transfer files between the host and instances
umount Unmount a directory from an instance
unalias Remove an alias
version Show version details
查看安装的Multipass版本信息
C:\Users\Administrator>multipass version
multipass 1.9.1+win
multipassd 1.9.1+win
multipass launch命令用于创建实例。
可以通过下面命令,创建实例。
multipass launch --name <实例名称>
multipass launch -n <实例名称>
如果不指定name参数,multipass会随机生成一个实例名。
查看创建的实例。
C:\Users\Administrator>multipass list
No instances found. --》当前没有创建任何实例
例:
--下载镜像
C:\Users\Administrator>multipass launch
Retrieving image: 5%
--创建实例acceptable-joey
C:\Users\Administrator>multipass launch
Starting acceptable-joey -
** launch第一次创建实例时会首先消耗几分钟下载镜像,之后launch会直接创建实例。
4.3 查看实例列表
C:\Users\Administrator>multipass list
Name State IPv4 Image
acceptable-joey Running N/A Ubuntu 20.04 LTS
通过如下命令查看实例信息
multipass info <实例名称>
例:
C:\Users\Administrator>multipass info acceptable-joey
Name: acceptable-joey
State: Running
IPv4: N/A
Release: Ubuntu 20.04.4 LTS
Image hash: 75a04c7eed58 (Ubuntu 20.04 LTS)
Load: 0.24 0.17 0.07
Disk usage: 1.4G out of 4.7G
Memory usage: 137.7M out of 976.9M
Mounts: --
创建命名的实例:
C:\Users\Administrator>multipass launch -n test
Launched: test
C:\Users\Administrator>multipass launch --name test2
Launched: test2
C:\Users\Administrator>multipass list
Name State IPv4 Image
acceptable-joey Running N/A Ubuntu 20.04 LTS
test Running N/A Ubuntu 20.04 LTS
test2 Running N/A Ubuntu 20.04 LTS
删除实例
multipass delete test2 --purge
C:\Users\Administrator>multipass list
Name State IPv4 Image
acceptable-joey Running N/A Ubuntu 20.04 LTS
test Running N/A Ubuntu 20.04 LTS
4.4 关闭和启动实例
C:\Users\Administrator>multipass stop acceptable-joey
C:\Users\Administrator>multipass stop test
C:\Users\Administrator>multipass list
Name State IPv4 Image
acceptable-joey Stopped -- Ubuntu 20.04 LTS
test Stopped -- Ubuntu 20.04 LTS
C:\Users\Administrator>multipass start test
C:\Users\Administrator>multipass list
Name State IPv4 Image
acceptable-joey Stopped -- Ubuntu 20.04 LTS
test Running N/A Ubuntu 20.04 LTS
4.5 使用实例
通过multipass shell 开始使用实例的命令行。
multipass shell <实例名称>
C:\Users\Administrator>multipass shell test
Welcome to Ubuntu 20.04.4 LTS (GNU/Linux 5.4.0-120-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
System information as of Wed Jun 22 21:29:00 CST 2022
System load: 0.0 Processes: 102
Usage of /: 29.1% of 4.67GB Users logged in: 0
Memory usage: 19% IPv4 address for enp0s3: 10.0.2.15
Swap usage: 0%
1 update can be applied immediately.
To see these additional updates run: apt list --upgradable
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
ubuntu@test:~$ pwd
/home/ubuntu
ubuntu@test:~$ hostname
test
ubuntu@test:~$ id
uid=1000(ubuntu) gid=1000(ubuntu) groups=1000(ubuntu),4(adm),20(dialout),24(cdrom),25(floppy),27(sudo),29(audio),30(dip),44(video),46(plugdev),117(netdev),118(lxd)
这就是一台ubuntu的虚拟机,可以尽情使用了。是不是非常方便!
网站声明:如果转载,请联系本站管理员。否则一切后果自行承担。
添加我为好友,拉您入交流群!
请使用微信扫一扫!