乘风破浪,遇见最美Windows 11之现代Windows开发运维 - VMware Workstation Player/VMware Workstation Pro虚拟机安装乌班图(Ubuntu OS)
背景
最近要折腾在Linux下开发.Net 跨平台桌面程序,在众多Linux发行版本中,Ubuntu绝对的首选,除了之前提到的温故知新,在Windows 11的WSLg(或Multipass)的Ubuntu中安装和运行桌面应用(Snap、Deb),还有个选项就是通过虚拟机来创建一个Ubuntu环境,关于虚拟机,Windows上有两大选择,VMware和VirtualBox,说实话各有千秋,而VMware旗下有两款,一款面向免费用户的VMware Workstation Player,一款面向专业用户的VMware Workstation Pro,这两个都可以,前者基本够用,后者呢,在一些比如快照管理等高级功能上更强一点。
什么是乌班图(Ubuntu OS)
Ubuntu是一个基于Debian的Linux发行版,主要由自由和开源软件组成。Ubuntu正式发布了三个版本: 桌面版(Desktop)、服务器版(Server) 和用于物联网设备和机器人的核心版(Core For IOT)。所有版本都可以在电脑上单独运行,或在虚拟机中运行。Ubuntu是一个流行的云计算操作系统,支持OpenStack。从17.10版本开始,Ubuntu的默认桌面是GNOME。
Ubuntu每六个月发布一次,长期支持(LTS)版本每两年发布一次。截至2022年4月21日,最新的长期支持版本是22.04("Jammy Jellyfish")。
Ubuntu由英国公司Canonical和一个由其他开发者组成的社区,在一个任人唯贤的管理模式下开发。Canonical为每个Ubuntu版本提供安全更新和支持,从发布日期开始,直到版本达到其指定的寿命终止(EOL)日期。Canonical通过销售与Ubuntu相关的高级服务和下载Ubuntu软件的人的捐赠来获得收入。
乌班图是以恩古尼哲学中的ubuntu命名的,Canonical表示这意味着 "对他人的人性",其内涵是 "我之所以是我,是因为我们都是谁"。
背景
Ubuntu建立在Debian的架构和基础设施之上,包括Linux服务器、桌面和已停产的手机和平板电脑操作系统版本。Ubuntu每六个月可预测地发布一次更新版本,每个版本都会得到九个月的免费支持(13.04之前为十八个月),包括安全修复、高影响的错误修复和保守的、实质上有益的低风险错误修复。第一个版本是在2004年10月。
目前的长期支持(LTS)版本支持五年,每两年发布一次。自Ubuntu 6.06发布以来,每四个版本都得到长期支持。长期支持包括对新硬件的更新、安全补丁和对"Ubuntu堆栈"(云计算基础设施)的更新。第一个LTS版本在桌面上支持三年,在服务器上支持五年;从Ubuntu 12.04 LTS开始,LTS版本的桌面支持也增加到五年。LTS版本得到了定期的点发布,支持新的硬件并整合了该系列迄今为止发布的所有更新。
Ubuntu的软件包是基于Debian的不稳定分支的软件包,每六个月同步一次。两个发行版都使用Debian的deb软件包格式和软件包管理工具(例如APT和Ubuntu软件)。然而,Debian和Ubuntu的软件包不一定相互兼容,所以软件包可能需要从源头上重建才能在Ubuntu中使用。许多Ubuntu的开发者也是Debian中关键软件包的维护者。Ubuntu通过向Debian推送修改内容与Debian合作,尽管有批评说这种情况发生得不够频繁。Ian Murdock,Debian的创始人,对Ubuntu软件包可能与Debian相差太远而无法保持兼容表示担忧。在发布之前,软件包会不断地从Debian的不稳定版本中导入,并与Ubuntu特有的修改合并。在发布前一个月,导入的软件包会被冻结,然后打包人员会努力确保被冻结的功能能够很好地相互操作。
Ubuntu目前由Canonical有限公司资助。2005年7月8日,Mark Shuttleworth和Canonical宣布创建Ubuntu基金会,并提供1000万美元的初始资金。基金会的目的是确保对所有未来版本的Ubuntu的支持和发展。马克-沙特尔沃思将基金会的目标描述为确保Ubuntu项目的延续性。
2009年3月12日,Ubuntu宣布开发者支持第三方云管理平台,如亚马逊EC2使用的平台。
32位i386处理器被支持到Ubuntu 18.04。决定支持"遗留软件",即为Ubuntu 19.10和20.04 LTS选择32位i386软件包。
下载地址
- Ubuntu 22.04 LTS (Jammy Jellyfish)
桌面版本
https://releases.ubuntu.com/jammy/ubuntu-22.04-desktop-amd64.iso
服务器版本
https://releases.ubuntu.com/jammy/ubuntu-22.04-live-server-amd64.iso
- Ubuntu 21.10 (Impish Indri)
桌面版本
https://releases.ubuntu.com/21.10/ubuntu-21.10-desktop-amd64.iso
服务器版本
https://releases.ubuntu.com/21.10/ubuntu-21.10-live-server-amd64.iso
- Ubuntu 20.04.4 LTS (Focal Fossa)
桌面版本
https://releases.ubuntu.com/focal/ubuntu-20.04.4-desktop-amd64.iso
服务器版本
https://releases.ubuntu.com/focal/ubuntu-20.04.4-live-server-amd64.iso
- Ubuntu 18.04.6 LTS (Bionic Beaver)
桌面版本
https://releases.ubuntu.com/bionic/ubuntu-18.04.6-desktop-amd64.iso
服务器版本
https://releases.ubuntu.com/bionic/ubuntu-18.04.6-live-server-amd64.iso
- Ubuntu 16.04.7 LTS (Xenial Xerus)
桌面版本
https://releases.ubuntu.com/xenial/ubuntu-16.04.7-desktop-amd64.iso
https://releases.ubuntu.com/xenial/ubuntu-16.04.6-desktop-i386.iso
服务器版本
https://releases.ubuntu.com/xenial/ubuntu-16.04.7-server-amd64.iso
https://releases.ubuntu.com/xenial/ubuntu-16.04.6-server-i386.iso
- Ubuntu 14.04.6 LTS (Trusty Tahr)
桌面版本
https://releases.ubuntu.com/trusty/ubuntu-14.04.6-desktop-amd64.iso
https://releases.ubuntu.com/trusty/ubuntu-14.04.6-desktop-i386.iso
服务器版本
https://releases.ubuntu.com/trusty/ubuntu-14.04.6-server-amd64.iso
https://releases.ubuntu.com/trusty/ubuntu-14.04.6-server-i386.iso
安装VMware Workstation Pro
获取VMware Workstation Pro
安装VMware Workstation Pro
重启电脑生效安装。
激活VMware Workstation Pro
*****-*****-*****-*****-*****
*****-*****-*****-*****-*****
*****-*****-*****-*****-*****
安装乌班图(Ubuntu OS)
开始安装
- 创建虚拟机
- 选择系统镜像
- 定制个性化Linux信息
输入名称、账户名、密码
比如:UbuntuBionic
、taylorshi
、xxxxxx
- 定制虚拟机信息
取名字、确定存储位置
比如:UbuntuBionic
、E:\VmwareSpace\UbuntuBionic
- 设定存储空间大小
这里我们还是给它大一些空间,最大40GB,它其实是弹性使用的,这里我们选拆成多个文件,它就是弹性使用的,实际用多少就是多少。
- 设定硬件参数
如果你不希望到时候跑起来卡卡的,建议还是点击自定义硬件
按钮增加一些配置。
比如把内存拉到8GB、处理器拉到4核心
- 完成并开启虚拟机
- 进入安装引导
Ubuntu的图标已经点亮了,说明找到入口了。
- 开始安装系统
VMware应该是针对Ubuntu做了优化,这个简易模式帮你做了一些工作,不会再询问你很多问题了,直接往前开始搞。
体验系统
首次进入系统
首次进入桌面,欢迎你
提示有一堆软件等待更新
设置常亮不锁屏
设置Root密码
sudo passwd
然后切换到root
su root
安装Vim
有些低版本系统连Vim都没有,那就需要补装一个。
sudo apt install vim
替换Ubuntu源为国内节点
通过vim编辑/etc/apt/sources.list
这个文件即可,把国内节点替换进去。
以Ubuntu 21.10为例:
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ impish main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ impish main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ impish-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ impish-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ impish-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ impish-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ impish-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ impish-security main restricted universe multiverse
# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ impish-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ impish-proposed main restricted universe multiverse
以Ubuntu 20.04为例:
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
以Ubuntu 18.04为例:
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
以Ubuntu 16.04为例:
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse
弄完,我们更新下apt库索引,看看是否修改生效。
sudo apt-get update
看到已经开始从我们新的节点开始拉取那就对了。
使用设置
解决鼠标键盘失效问题
有一次重启之后进去,发现,键盘始终输入不了东西,经过查询,关掉后,把虚拟机设置
-常规
底部的增强型键盘,设置回:必需
,再开启系统,这时候就恢复了。
解决Vmware和Ubuntu 22.04共享文件夹
目前Vmware有个已知bug是设置了共享目录的时候,前往/mnt/hgfs
可能还是看不到共享的目录,但是官方也给出了解决方案。
首先,我们要去虚拟机设置
- 选项
- 共享文件夹
,首先要把它设置成总是启用
然后点击添加
按钮,根据流程,可以把已知的Windows本地目录添加进来。
这里建议用一个小写开头的单词来做共享目录的名称。
然后问题来了,这样弄完,跑到/mnt/hgfs
一看,是空的。
根据官方指引,先做两个检查:
先确保挂载根目录存在,
sudo mkdir -p /mnt/hgfs/
然后确保Vmware共享的启用和连接成功,
sudo /usr/bin/vmhgfs-fuse .host:/ /mnt/hgfs/ -o subtype=vmhgfs-fuse,allow_other
这一步执行不报错就好。
然后我们需要通过管理员权限来编辑/etc/fstab
sudo vim /etc/fstab
按下i
进入编辑模式,然后在最后一行换行,粘贴如下配置进去。
vmhgfs-fuse /mnt/hgfs fuse defaults,allow_other 0 0
最后Esc
键退出,按:wq
保存退出编辑。
好了,这时候,重启下系统。
再次前往/mnt/hgfs
位置,就可以看到了。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· DeepSeek 开源周回顾「GitHub 热点速览」
2021-05-07 敢为人先,从阿里巴巴云原生团队实践Dapr案例,看分布式应用运行时前景