当前位置: 首页 > news >正文

Macbook M1 Fusion安装Debian/Linux

背景

本人主力工作电脑已经迁移到苹果芯片m1的macbook上,曾经尝试使用Fusion安装CentOS、OpenEuler、Ubuntu的一些版本,都没有安装成功。最近开始研究Linux/Unix系统编程,迫切需要通过VMware Fusion安装一台Linux操作系统的虚拟机。

Linux安装

在VMware Fusion下通过Linux发行版iso镜像安装操作,大部分步骤已经比较成熟,本文不做过多介绍,这里主要介绍安装过程遇到的问题和解决方案。

尝试OpenEuler

OpenEuler 22.03和24.03均在grub引导阶段失败,报错如下:

# OpenEuler 22.03
EFI stub:Booting Linux Kernel...
EFI stub:EFI_RNG_PROTOCOL unavailable,no randomness supplied
EFI stub:Using DTB from configuration table
EFI stub:Exiting boot services and installing virtual address map..# OpenEuler 24.03
EFI stub:Booting Linux Kernel...
EFI stub:EFI_RNG_PROTOCOL unavailable,no randomness supplied
EFI stub:Using DTB from configuration table
EFI stub:Exiting boot services...

OpenEuler安装多次失败尝试无果,参考网友分享m1 MacOS上通过Parallels Desktop成功安装Debian 10的版本,并成功运行大数据相关软件。VMware Fusion作为功能类似的软件,理论上也具有成功安装Debian Linux的能力,因此我选择采用Debian ARM64版本: Debian 12.5, 网络安装形式的最小镜像,debian-12.5.0-arm64-netinst.iso。

安装Debian

由于Debian ISO镜像默认为国外源,会导致安装软件的步骤无比慢,建议Debian OS安装完后改为国内镜像,进一步配置。需要通过一下操作进行:
1、Fusion创建VM时需要断开网络
2、安装过程指定国内镜像
3、完成安装

配置Debian/Linux

在Debian 12.5安装成功后,通过Fusion VM控制台root登陆OS,开始配置操作:
1、检查并启动网络

root@debian:~# ip route show#发现没有IP地址,无法联网,通过dhcpclient连接网络
root@debian:~#  dhclient ens160 

2、修改Debian 12.5(bookworm)源为国内镜像

root@debian:~# cat /etc/apt/sources.list
#deb cdrom:[Debian GNU/Linux 12.5.0 _Bookworm_ - Official arm64 DVD Binary-1 with firmware 20240210-11:28]/ bookworm contrib main non-free-firmware
deb https://mirrors.huaweicloud.com/debian/ bookworm main non-free non-free-firmware contrib
deb https://mirrors.huaweicloud.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb https://mirrors.huaweicloud.com/debian/ bookworm-backports main non-free non-free-firmware contrib
deb-src https://mirrors.huaweicloud.com/debian/ bookworm main non-free non-free-firmware contrib
deb-src https://mirrors.huaweicloud.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb-src https://mirrors.huaweicloud.com/debian/ bookworm-backports main non-free non-free-firmware contrib
deb https://mirrors.huaweicloud.com/debian-security/ bookworm-security main non-free non-free-firmware contrib
deb-src https://mirrors.huaweicloud.com/debian-security/ bookworm-security main non-free non-free-firmware contrib# 配置sources.list后更新缓存
root@debian:~#  apt-get update
Hit:1 https://mirrors.huaweicloud.com/debian bookworm InRelease
Hit:2 https://mirrors.huaweicloud.com/debian bookworm-updates InRelease
Hit:3 https://mirrors.huaweicloud.com/debian bookworm-backports InRelease
Hit:4 https://mirrors.huaweicloud.com/debian-security bookworm-security InRelease
Get:5 https://mirrors.huaweicloud.com/debian bookworm/non-free-firmware Sources [6,168 B]
Get:6 https://mirrors.huaweicloud.com/debian bookworm/non-free-firmware arm64 Packages [5,824 B]
Get:7 https://mirrors.huaweicloud.com/debian bookworm/non-free-firmware Translation-en [20.8 kB]
Get:8 https://mirrors.huaweicloud.com/debian bookworm-updates/non-free-firmware Sources [2,076 B]
Get:9 https://mirrors.huaweicloud.com/debian bookworm-updates/non-free-firmware arm64 Packages [616 B]
Get:10 https://mirrors.huaweicloud.com/debian bookworm-updates/non-free-firmware Translation-en [384 B]
Get:11 https://mirrors.huaweicloud.com/debian-security bookworm-security/non-free-firmware Sources [796 B]
Get:12 https://mirrors.huaweicloud.com/debian-security bookworm-security/non-free-firmware Translation-en [472 B]
Fetched 37.2 kB in 4s (10.2 kB/s)       
Reading package lists... Done

网络最小化安装的Debian/Linux的sources.list文件本只指定了DVD的位置,不存在相关镜像链接,该链接为参考网易镜像提供的Debian buster版本sources.list文件的修改而来。

3、安装NetworkManager,解决Debian/Linux VM重启后网络消失的问题

root@debian:~# apt-get install network-manager
root@debian:~# systemctl start network-manager
root@debian:~#  systemctl status NetworkManager
● NetworkManager.service - Network ManagerLoaded: loaded (/lib/systemd/system/NetworkManager.service; enabled; preset: enabled)Active: active (running) since Wed 2024-06-19 10:33:35 EDT; 7h leftDocs: man:NetworkManager(8)Main PID: 700 (NetworkManager)Tasks: 3 (limit: 2251)Memory: 15.1MCPU: 400msCGroup: /system.slice/NetworkManager.service└─700 /usr/sbin/NetworkManager --no-daemonJun 19 10:33:35 debian NetworkManager[700]: <info>  [1718807615.8088] dhcp4 (ens160): state changed no lease
Jun 19 10:33:38 debian NetworkManager[700]: <info>  [1718807618.0607] dhcp4 (ens160): state changed new lease, add>
Jun 19 10:33:38 debian NetworkManager[700]: <info>  [1718807618.0620] policy: set 'Wired connection 1' (ens160) as>
Jun 19 10:33:38 debian NetworkManager[700]: <info>  [1718807618.0692] device (ens160): state change: ip-config -> >
Jun 19 10:33:38 debian NetworkManager[700]: <info>  [1718807618.0719] device (ens160): state change: ip-check -> s>
Jun 19 10:33:38 debian NetworkManager[700]: <info>  [1718807618.0721] device (ens160): state change: secondaries ->
Jun 19 10:33:38 debian NetworkManager[700]: <info>  [1718807618.0724] manager: NetworkManager state is now CONNECT>
Jun 19 10:33:38 debian NetworkManager[700]: <info>  [1718807618.0727] device (ens160): Activation: successful, dev>
Jun 19 10:33:38 debian NetworkManager[700]: <info>  [1718807618.0731] manager: NetworkManager state is now CONNECT>
Jun 19 10:33:38 debian NetworkManager[700]: <info>  [1718807618.0735] manager: startup complete# 开启NetworkManager随VM开机启动
root@debian:~#  systemctl enable NetworkManager

重启Debian/Linux VM后检查发现可以正常联网

root@debian:~# ip route show
default via 192.168.7.254 dev ens160 proto dhcp src 192.168.4.223 metric 100 
192.168.4.0/22 dev ens160 proto kernel scope link src 192.168.4.223 metric 100

4、安装防火墙管理、编辑器软件

root@debian:~# apt-get install ufw
root@debian:~# ufw enable
# 打开端口22 TCP,方便ssh登陆
ufw allow 22/tcp
root@debian:~# ufw status
Status: activeTo                         Action      From
--                         ------      ----
22/tcp                     ALLOW       Anywhere                  
22/tcp (v6)                ALLOW       Anywhere (v6) 

5、配置root用户登陆,以及普通用户提权到root

# 配置root用户登陆
root@debian:~# cat  /etc/ssh/sshd_config | grep PermitRootLogin
#PermitRootLogin prohibit-password
PermitRootLogin yes
# the setting of "PermitRootLogin prohibit-password".# 配置普通用户提权
# 检查发现不存在sudo配置文件/etc/sudoers,因此需要先安装sudo
root@debian:~# apt-get install sudo
# sudo配置文件为root只读权限,需要加写权限
root@debian:~# chmod +w /etc/sudoers# 修改/etc/sudoers, 在%sudo ALL=(ALL:ALL) ALL后添加hbu的免密提权配置
root@debian:~# cat /etc/sudoers | grep -n "ALL="
47:root	ALL=(ALL:ALL) ALL
50:%sudo	ALL=(ALL:ALL) ALL
51:hbu	ALL=(ALL)	NOPASSWD:ALL
# 去除sudo配置写权限
root@debian:~# chmod -w /etc/sudoers

参考

1、 解决在MacBook Air m1芯片上使用parallels Desktop装ubuntu20.04 arm64 出现EFI

http://www.lryc.cn/news/384512.html

相关文章:

  • ERP收费模式是怎样的?SAP ERP是如何收费的?
  • 如何实现免交互
  • 浏览器userAgent大全及JS判断当前APP
  • 11.异常(java版)
  • 单片机学习记录
  • flask的基本使用1
  • 如何编写时区源文件
  • 植物大战僵尸杂交版v2.1最新整合版,附PC端+安卓端+iOS端安装包+修改器+安装教程!
  • 【5G射频基本架构】
  • 4.任务调度
  • Github 2024-06-27 Go开源项目日报Top10
  • 【D3.js in Action 3 精译】1.2.2 可缩放矢量图形(一)
  • 「C系列」C 排序算法
  • Power BI可视化表格矩阵如何保持样式导出数据?
  • 《UDS协议从入门到精通》系列——图解0x35:请求上传
  • Tailwindcss 扩展默认配置来自定义颜色
  • C++设计模式---享元模式
  • 智慧园区大数据云平台建设方案(Word原件)
  • 【学习】如何利用Python技术进行软件测试相关工作
  • Qt:3.项目创建、对象树、乱码问题、Qt命名规则
  • C# 入门—实现 Hello, World!
  • 【项目实训】前端页面初探索(前期探索)
  • 机器人控制系列教程之动力学建模(2)
  • Golang | Leetcode Golang题解之第200题岛屿数量
  • Linux系统启动流程
  • Vue 学习之 axios
  • Python学习笔记17 -- 猜数字小游戏2
  • 【系统架构设计师】七、信息安全技术基础知识(信息安全的概念|信息安全系统的组成框架|信息加解密技术)
  • CMMM Plus+ Calculus Update 超级游戏大作 游戏说明
  • Java OA系统任务协作模块