Published on

MBP Late 2013安装Fedora 31

Authors
  • avatar
    Name
    ttyS3
    Twitter

文章未完,待继续更新

en title: Install Fedora 31 on MacBook Pro Late 2013

本文写于2020年春节假期,当时由于在家想玩podman容器,而mac下并没有原生的docker或podman,因此给mbp加装第二系统: Fedora 所以本文是Mac + Fedora 双系统。 由于当时Fedora 32尚未正式发布,因此文章的图片素材显示的是Fedora 31, 但是实际上Fedora 32的安装过程是一样的。 现在Fedora 32已经发布了,因此,可请自行把文章中的 31 替换成 32便可直接安装Fedora 32. 如果你完全按文章操作安装的F31, 如果要从F31升级到F32的,可参考Fedora 31 升级到 Fedora 32一文升级

由于我用于安装Fedora的分区是使用了我原本是安装了ArchLinux的那个分区(也就是说,之前是Mac+ArchLinux双系统),因此这里并不涉及划分磁盘给Linux这一部分的操作。 实际操作中,如果你是单一的Mac,你需要划分一个分区出来给Linux使用, 如果需要这部分的帮助,请Goolge一下其他人的教程。 至于为什么从ArchLinux换成Fedora, 这个其实可以看之前的文章,我的台式机已经把用了10多年的ArchLinux也换成了Fedora. 主要原因是RHEL系对自家的podman肯定是支持更完善,省事。另外就是不想再用滚动升级的系统了。

准备工作

下载iso, 这里我选择从ustc镜像下载,速度非常快

Fedora 31下载地址:

https://mirrors.ustc.edu.cn/fedora/releases/31/Workstation/x86_64/iso/

Fedora 32下载地址:

https://mirrors.ustc.edu.cn/fedora/releases/32/Workstation/x86_64/iso/

下载完iso我们进行一下完整性校验,如果没有安装gpg的用brew安装一下:

brew install gpg

参照 https://getfedora.org/en/security/ 进行校验:

curl https://getfedora.org/static/fedora.gpg | gpg --import
#开始校验CHECKSUM文件签名,如果看到 good signature 就OK
LC_ALL=en_US gpg --verify-files *-CHECKSUM
gpg: Signature made Fri Oct 25 21:09:48 2019 CST
gpg: using RSA key 50CB390B3C3359C4
gpg: Good signature from "Fedora (31) <[email protected]>" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg: There is no indication that the signature belongs to the owner.
Primary key fingerprint: 7D22 D586 7F2A 4236 474B F7B8 50CB 390B 3C33 59C4

#最后校验sha256 hash
❯ sha256sum -c *-CHECKSUM
Fedora-Workstation-Live-x86_64-31-1.9.iso: OK
sha256sum: WARNING: 19 lines are improperly formatted

参考 https://docs.centos.org/en-US/centos/install-guide/Making_Media_USB_Mac/ 制作 fedora 安装U盘

❯ diskutil list
/dev/disk0 (internal, physical):
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *500.3 GB disk0
1: EFI EFI 209.7 MB disk0s1
2: Apple_APFS Container disk1 300.9 GB disk0s2
3: Apple_HFS untitled 104.9 MB disk0s3
4: Linux Filesystem 209.7 MB disk0s4
5: Linux Filesystem 85.9 GB disk0s5
6: Linux Filesystem 107.4 GB disk0s6

/dev/disk1 (synthesized):
#: TYPE NAME SIZE IDENTIFIER
0: APFS Container Scheme - +300.9 GB disk1
Physical Store disk0s2
1: APFS Volume Macintosh HD - Data 267.5 GB disk1s1
2: APFS Volume Preboot 81.7 MB disk1s2
3: APFS Volume Recovery 528.5 MB disk1s3
4: APFS Volume VM 1.1 GB disk1s4
5: APFS Volume Macintosh HD 10.9 GB disk1s5

/dev/disk2 (external, physical):
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *1.0 TB disk2
1: Microsoft Basic Data phiH1 1.0 TB disk2s1

/dev/disk3 (external, physical):
#: TYPE NAME SIZE IDENTIFIER
0: *7.9 GB disk3

卸载USB磁盘

❯ diskutil unmountDisk /dev/disk3
Unmount of all volumes on disk3 was successful

写盘

sudo dd if=/Users/hacklog/Downloads/Fedora-Workstation-Live-x86_64-31-1.9.iso of=/dev/rdisk3 bs=8m
Password:
460+0 records in
460+0 records out
1929379840 bytes transferred in 230.188987 secs (8381721 bytes/sec)

写完盘, Mac 会提示不能识别, 点击Eject 就行。 如果点了ignore, 需要手动 diskutil unmountDisk /dev/disk3 再卸载一下

安装Fedora

首先我们先在Mac下面确认一下我们需要将哪些分区给Fedora使用, 从下图可看到我之前的ArchLinux用了3个分区, disk0s4 - disk0s6, 先用手机将这个分区表情况拍照记录,以便接下来在Fedora系统安装过程中分区的时候,不会错误地损坏 Mac OSX 的分区。

参考 https://support.apple.com/en-us/HT202796 从U盘启动Mac book pro:

在按下开机键或系统重启后,马上按住Option (Alt),直到出现启动管理器界面才松开,然后就可以选择从我们制作好的Fedora U盘启动 If you press and hold the Control key during this step, your selection is saved in Startup Disk preferences, so it persists until you change it.

注意下图,这里有点令人困惑,因为我之前的ArchLinux也是基于UEFI启动的,所以加上我们刚才制作的 Fedora 安装U盘,会出现两个EFI Boot的选项, 所幸的是,我们能从移动设备的黄色图标看出,最右边那个才是我们的Fedora 安装U盘。

选择Install to Hard Drive并没有什么特别,它只是直接给你启动了一个安装器而已:

可以看到,ntp客户端默认是不能工作的(因为没连网):

接下来我们要选择安装系统到哪个分区了。

Fedora这个安装器的好处是,虽然它默认是满屏幕显示,但是其实它是运行在Live系统的一个GUI程序而已。 因此我们在安装过程中,完全可以启动任意Live系统里默认内置的程序。

在操作磁盘分区之前,我们先再次确认一下磁盘分区.

然后我们对比一下之前拍照记录下的那个图,发现分区顺序和大小都是对应的。 (注意在Mac磁盘管理工具下展示的disk0s4 - disk0s6与Linux的 sda5 - sda6 的大小并不完全相同。)

在设备选择处,我们这里只有一个内置的SSD,当然就选这个了。 然后,存储配置方式那里,我们选 Custom (自定义)。对于这种已经有数据的盘(双系统),我们必须选Custom 或者 Advanced Custom(Blivet-GUI)

这三个分区的数据我已经备份了,并且不需要了。因此,这一步主要是删除这3个分区。选中之后,点下面的-按钮删除即可。

可以看到,删除旧分区后,我们大概剩下 185GB 的空余的磁盘空间可用了。这些空余空间等会就给Fedora用。

删除前后的分区情况确认:

让Fedora自动分区,然后我们对于大小稍做调整,最终效果如下:

老灯根据以往自己的使用情况, 对这 185GB 空闲进行了一个合理的分配。

/boot分了1GB,方便以后往里面塞一些小的iso维护系统,由GRUB直接启动。

由于笔记本有16GB内存,因此对于swap的需求并不是很大,分配8GB左右即可。

/呢?由于要使用容器, /var一般会占用至少几十GB的空间。因此也不能分配太小了。 但是我这里由于容量有限,因此也没有必要把/var单独分出来持载了。

好了,剩下的尽量多的空间,都给/home来存文件了。

这是Fedora 31默认的分区策略。总共4个物理分区:/boot/efi(sda4, EFI) /boot/efi(sda5, HFS+ ESP), /boot(sda6) 和 LVM(sda7). 然后在LVM上面再分出/home, /swap 分区。

别的分区都没啥说的,这里有一个细节值得注意,那就是/boot/efi分区的文件系统格式:

对于Windows 10 + Linux双系统,一般我们的efi分区都是弄成vfat的。

但是这里,Fedora默认给我们设置好的分区格式是 HFS+ ESP

为什么?

The EFI system partition (also called ESP)

The default mac bootloader can only boot from HFS+ partitions. SO fedora creates that boot partition for you to use instead of a a normal fat32 partition so that you can keep the native mac bootloader.

因为默认情况下,Mac的启动管理器只能从HFS+分区启动,所以Fedora机智地给你自动设置好了这个文件系统。

最终确认:

从这个图可看出,在图形界面,实际上还有一个/boot/efi(sda4, EFI)分区没有显示出来,但是会自动创建。 这个EFI分区,跟HFS+ ESP的大小一样是600M.

但是后面系统安装完成后会发现,那个vfat格式的/boot/efi(sda4, EFI)分区并没有被使用。在mbp上,Fedora只使用了 /boot/efi(sda5, HFS+ ESP)

分区操作完成后,我们再进Terminal确认一下这个分区是否OK:

然后就开始安装了。

安装好之后我们再进Mac的启动管理器看看:

最后秀一个此次装机的御用U盘:

解决网络问题

由于Mac基本上是使用BCM的无线芯片居多,我这个mbp也不例外。

通过lspci可知是一块BCM4360的无线网卡(BCM4360 802.11ac Wireless Network Adapter (rev 03))。

而BCM向来是不开源驱动的,因此像Fedora这样的偏向于“非GPL不取”的系统(因为会引发legal问题,RHEL是商业公司), 自然是没办法内置BCM的驱动。

现在的问题是,mbp本身是没有以太网 RJ45接口的。 而我翻了一下电脑包,我的USB转RJ45 接口线也忘记带回来了。 要让Fedora连网的前提是无线驱动要工作,而要安装BCM的驱动的前提是Fedora必须连上网,而mbp本身现在没法直接连网。 怎么办?好像是个死循环。

办法当然是有的。山人自有妙计。

几乎所有的Android手机都会有 USB网络共享 的功能,简单来说,可以通过USB连接手机和电脑,然后使手机作为一个USB网卡设备。

OK, 成功连接网络,由于手机是直接使用了WIFI网络的,因此也不至于太慢。

换成国内镜像

联网成功之后最重要的一件事当然是安装无线网卡驱动,但是在安装东西之前,我们最好设置一下系统镜像。

老灯偏向于使用ustc或清华大学的源,非常稳, 阿里的源也很快,但是有时候会抽风。

https://mirror.tuna.tsinghua.edu.cn/help/fedora/

http://mirrors.ustc.edu.cn/help/fedora.html

为了方便退回原来的文件,老灯这里使用git来保存好原来的文件。然后就可以大胆修改了。

cd /etc/yum.repos.d
sudo git init .
sudo git add .
sudo git commit -m 'init commit'
sudo sed -e 's|^metalink=|#metalink=|g' \
         -e 's|^#baseurl=http://download.fedoraproject.org/pub/fedora/linux|baseurl=https://mirrors.tuna.tsinghua.edu.cn/fedora|g' \
         -i.bak \
         /etc/yum.repos.d/fedora.repo \
         /etc/yum.repos.d/fedora-modular.repo \
         /etc/yum.repos.d/fedora-updates.repo \
         /etc/yum.repos.d/fedora-updates-modular.repo

启用rpmfusion源

sudo dnf install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm

默认源还是慢,我们可以换成清华源的mirror https://mirror.tuna.tsinghua.edu.cn/help/rpmfusion/

cd /etc/yum.repos.d
sudo sed -e 's|^metalink=|#metalink=|g' \
         -e 's|^#baseurl=http://download1.rpmfusion.org/|baseurl=https://mirrors.tuna.tsinghua.edu.cn/rpmfusion/|g' \
         -i.bak \
         rpmfusion-free.repo \
         rpmfusion-free-updates.repo \
         rpmfusion-free-updates-testing.repo \
         rpmfusion-nonfree.repo \
         rpmfusion-nonfree-updates.repo \
         rpmfusion-nonfree-updates-testing.repo

ps: ustc也提供rpmfusion源的 https://mirrors.ustc.edu.cn/help/rpmfusion.html

无线驱动安装

我们先看下网卡硬件型号

[ttys3@HuangYeMacBookPro ~]$ lspci | grep -i Network
03:00.0 Network controller: Broadcom Inc. and subsidiaries BCM4360 802.11ac Wireless Network Adapter (rev 03)

OK, 型号是 BCM4360

Fedora下要使用BCM的无线网卡或蓝牙,我们需要安装 broadcom-wl 专有驱动.

注意akmod-wlbroadcom-wl包都是在@rpmfusion-nonfree仓库的,这就是为什么前面我们需要启用rpmfusion源。

sudo dnf install -y akmod-wl

显卡驱动安装

注意: mbp late 2013是个双显卡的机器,内置了Intel Iris Pro显卡,还有独立的NVIDIA GeForce 750M显卡。 lspci 可看到NVIDIA Corporation GK107M [GeForce GT 750M Mac Edition] (rev a1), 但是集成显卡Intel Iris Pro显卡默认对非Mac系统是隐藏的,所以在Linux下默认看不到这个硬件。需要hack方法才能开启这玩意, 还挺麻烦的,这里就先不折腾了,先用N卡吧。

Fedora对于N卡的机器,默认安装使用的是开源的nouveau驱动, 我安装完后使用不到半小时这个驱动就crash了, 还是换成专有驱动吧,这个时候,开源还是闭源无所谓了,咱不讲究了,能稳定使用就OK:

[ttys3@HuangYeMacBookPro ~]$ lspci | grep -E 'VGA|Video'
01:00.0 VGA compatible controller: NVIDIA Corporation GK107M [GeForce GT 750M Mac Edition] (rev a1)

nvidia驱动我们可以不用从官方网站下载,直接通过从rpmfusion源来安装

额外的操作:

sudo dnf groupupdate core
sudo dnf groupupdate multimedia --setop="install_weak_deps=False" --exclude=PackageKit-gstreamer-plugin
sudo dnf groupupdate sound-and-video

然后开始安装驱动

sudo dnf install akmod-nvidia # rhel/centos users can use kmod-nvidia instead
sudo dnf install xorg-x11-drv-nvidia-cuda #optional for cuda/nvdec/nvenc support
sudo dnf update -y
sudo dnf install xorg-x11-drv-nvidia-cuda-libs
sudo dnf install vdpauinfo libva-vdpau-driver libva-utils

更新GRUB2配置

/etc/grub2-efi.cfg is a symlink to the real grub.cfg (i.e. /boot/efi/EFI/fedora/grub.cfg)

grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg
#或者
grub2-mkconfig -o /etc/grub2-efi.cfg

https://fedoraproject.org/wiki/GRUB_2?rd=Grub2#Updating_GRUB_2_configuration_on_UEFI_systems

常用软件安装

安装实用命令行工具

sudo dnf install -y ncdu nload htop ripgrep xclip

# https://github.com/imsnif/bandwhich
sudo dnf copr enable atim/bandwhich -y && sudo dnf install bandwhich
#或者 cargo install bandwhich
#让普通用户可以不用sudo执行bandwhich
sudo setcap cap_sys_ptrace,cap_dac_read_search,cap_net_raw,cap_net_admin+ep `which bandwhich`

#https://github.com/timvisee/ffsend
sudo dnf install -y openssl-devel
cargo install ffsend -f

#https://github.com/mookid/diffr
cargo install diffr

ncdu 实用alias:

alias ncduroot='ncdu --exclude /dev --exclude /media --exclude /mnt --exclude /proc --exclude /sys --exclude /run /'

dnf 使用 proxy

使用了国内镜像之后,一般不太需要再使用proxy了,但是对于非官方镜像的 corp源 或一些第三方源(典型的比如vscode的),是没有国内镜像的。 编辑 /etc/dnf/dnf.conf 在[main]段添加上类似如下配置(如果不需要认证,可省略proxy_username 和 proxy_password)

proxy=http://地址:端口
proxy_username=用户名
proxy_password=密码

安装 vscode

sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
sudo sh -c 'echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/vscode.repo'

sudo dnf check-update
sudo dnf install code

安装视频播放器

sudo dnf install -y smplayer smplayer-themes smtube youtube-dl

安装图片浏览器

sudo dnf install -y gthumb qimgv

安装邮件客户端

sudo dnf install -y geary

java 环境

Fedora 默认安装的是java-1.8.0-openjdk-headless , 这个jdk是不带图形(比如awt)和音频支持的, 一般我们作为桌面环境来使用,需要安装java-1.8.0-openjdk

sudo dnf install -y java-1.8.0-openjdk

常用服务安装

mbp CPU 风扇控制

使用一段时间,发现CPU温度经常在80度以上,风扇也不怎么转. 还好找到一个专门为mbp而生的工具: mbpfan

https://ineed.coffee/992/mbpfan-v1-4-0-is-out/ https://ineed.coffee/projects/mbpfan/ https://github.com/linux-on-mac/mbpfan

# fancontrol 没法工作
# `lm_sensors`的sensors命令也没法为它生成配置文件
[root@HuangYeMacBookPro ttys3]# fancontrol
Loading configuration from /etc/fancontrol ...
Error: Can't read configuration file

/usr/sbin/pwmconfig: There are no pwm-capable sensor modules installed

看看没安装mbpfan之前空载的机器CPU温度:

[root@HuangYeMacBookPro ttys3]# sensors
coretemp-isa-0000
Adapter: ISA adapter
Package id 0: +83.0°C (high = +84.0°C, crit = +100.0°C)
Core 0: +81.0°C (high = +84.0°C, crit = +100.0°C)
Core 1: +83.0°C (high = +84.0°C, crit = +100.0°C)
Core 2: +80.0°C (high = +84.0°C, crit = +100.0°C)
Core 3: +80.0°C (high = +84.0°C, crit = +100.0°C)

安装之后温度瞬间降下来了:

[root@HuangYeMacBookPro ttys3]#dnf install -y mbpfan
[root@HuangYeMacBookPro ttys3]#systemctl enable --now mbpfan

[root@HuangYeMacBookPro ttys3]#sensors coretemp-isa-0000
coretemp-isa-0000
Adapter: ISA adapter
Package id 0: +63.0°C (high = +84.0°C, crit = +100.0°C)
Core 0: +61.0°C (high = +84.0°C, crit = +100.0°C)
Core 1: +63.0°C (high = +84.0°C, crit = +100.0°C)
Core 2: +61.0°C (high = +84.0°C, crit = +100.0°C)
Core 3: +60.0°C (high = +84.0°C, crit = +100.0°C)

mbpfan的默认配置在 /etc/mbpfan.conf ,默认的配置基本上不需要调整就可以工作得很好. 打开个kvm win10虚拟机,然后 用watch -n2 sensors coretemp-isa-0000 观察温度变量,基本上控制在60度左右。

安装 cockpit WEB UI

sudo dnf install -y cockpit cockpit-bridge cockpit-dashboard cockpit-networkmanager \
cockpit-packagekit cockpit-storaged cockpit-system cockpit-ws\
cockpit-selinux cockpit-podman cockpit-machines cockpit-kdump cockpit-sosreport

安装tuned (配合cockpit ui使用):

sudo dnf install -y tuned

kvm 虚拟机

准备工作: 因为windows默认不包含VirtIO driver,因此需要单独下载: stable https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso latest: https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/latest-virtio/virtio-win.iso

文件copy过去,会自动继承selinux label.

sudo rsync -avP ./virtio-win-0.1.173.iso /var/lib/libvirt/images/

创建vm: 登录cockpit WEB UI,然后在虚拟机那里新建一个windows 10虚拟机。

vm启动之后,直接关闭即可. 因为我们还要挂载设置virtio 驱动. 之所以要启动一次VM是因为如果不启动, cdrom 不会挂载上.

cockpit WEB UI功能比较简陋,因此我们要手动编辑虚拟机配置文件来挂载iso文件:

编辑vm xml配置文件,把virtio-win.iso 挂载上

[root@HuangYeMacBookPro libvirt]# virsh list --all
 Id Name State
------------------------
 - win10 shut off

[root@HuangYeMacBookPro libvirt]# virsh edit win10
Domain win10 XML configuration edited.

复制已有的配置:

    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/W10_RS5_LTSC'/>
      <target dev='sdb' bus='sata'/>
      <readonly/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>

稍修改下iso文件的路径(source file=)和设备名称(target dev=)及address unit=

    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/virtio-win-0.1.173.iso'/>
      <target dev='sdc' bus='sata'/>
      <readonly/>
      <address type='drive' controller='0' bus='0' target='0' unit='2'/>
    </disk>

保存好之后,我们再看disks部分已经有我们刚才添加的iso了:

然后,进入cockpit virtual machines管理界面,将.qow2 磁盘的bus从原来的sata改成virtio, 将网卡的model type 从原来的e1000e 改成 virtio. 然后点击run启动.

我们使用 remmina 来通过spice协议连接 127.0.0.1:5900

没有安装remmina的可以安装一下:

sudo dnf install -y remmina remmina-plugins-exec remmina-plugins-nx remmina-plugins-rdp remmina-plugins-secret remmina-plugins-spice remmina-plugins-st remmina-plugins-vnc remmina-plugins-xdmcp

iso文件权限设置 启用selinux的情况下, iso镜像文件需要有virt_image_t 类型才能被访问. 因此,通常情况,用户Home目录下的iso文件是无法访问的,最简单的解决办法是把iso文件复制到 /var/lib/libvirt/images/ 目录.

SELinux prevents guest images from loading if SELinux is enabled and the images are not correctly labeled. SELinux requires that image files have the virt_image_t label applied to them. The /var/lib/libvirt/images directory has this label applied to it and its contents by default. This does not mean that images must be stored in this directory; images can be stored anywhere, provided they are labeled with virt_image_t.

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/5/html/virtualization/sect-virtualization-security_for_virtualization-selinux_and_virtualization

由于我这个win安装盘的iso文件在ntfs分区(外挂的移动硬盘),因此其label为 fusefs_t,并且是不能修改的,所以我这里只能采用复制文件法.

[ttys3@HuangYeMacBookPro qb]$ ls -lhpZ ./W10_RS5_LTSC.iso
-rwxrwxrwx. 1 ttys3 ttys3 system_u:object_r:fusefs_t:s0 1.4G Jan 30 23:44 ./W10_RS5_LTSC.iso

#将其复制到`/var/lib/libvirt/images/`目录:
[ttys3@HuangYeMacBookPro qb]$ sudo cp MPBGamerElegantEdition.iso /var/lib/libvirt/images/
[ttys3@HuangYeMacBookPro qb]$ sudo ls -lhZ /var/lib/libvirt/images/
total 1.4G
-rwxr-xr-x. 1 root root unconfined_u:object_r:virt_image_t:s0 1.4G Jan 31 16:32 MPBGamerElegantEdition.iso
[ttys3@HuangYeMacBookPro qb]$

windows安装界面进去后会看不到任何磁盘. 安装好virtio scsi驱动后即可看到. 点击Load driver 后选择virtio-win iso文件挂载的cdrom下的amd64目录下的w10目录即可. 也可以顺便把virtio网卡驱动也安装一下(NetKVM目录).

只有一个PCI设备是未知设备:1af4:1045 经查询 https://pci-ids.ucw.cz/read/PC/1af4/1045 是 Virtio memory balloon 进入Balloon 目录,安装好驱动之后,执行 blnsvr -i 安装服务

进入 https://www.spice-space.org/download.html#windows-binaries 下载 Windows SPICE agent the SPICE guest agent (for copy and paste, automatic resolution switching, ...)

把下载的工具打包成一个iso,方便挂载给guest机用:

mkisofs -V ttys3-win10-tools -f -J -joliet-long -r -allow-lowercase -allow-multidot -o ttys3-win10-tools.iso .
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/ttys3-win10-tools.iso'/>
      <target dev='sdd' bus='sata'/>
      <readonly/>
      <address type='drive' controller='0' bus='0' target='0' unit='3'/>
    </disk>

qemu guest agent无法成功安装, 原因是 这个系统精简掉了这个程序依赖的VSS服务( Volume Shadow Copy Service)

samba文件共享

[ttys3@HuangYeMacBookPro /]$ sudo dnf install -y samba

[ttys3@HuangYeMacBookPro /]$ sudo systemctl enable --now smb
Created symlink /etc/systemd/system/multi-user.target.wants/smb.service → /usr/lib/systemd/system/smb.service.
[ttys3@HuangYeMacBookPro /]$ sudo systemctl enable --now nmb
Created symlink /etc/systemd/system/multi-user.target.wants/nmb.service → /usr/lib/systemd/system/nmb.service.

# 如果共享的目录就是当前登录DE的用户的话,其实不用额外加一个 winshare 用户了
[ttys3@HuangYeMacBookPro /]$ sudo useradd -c 'smb user for win share' -d /usr/share/empty -M -N -s /sbin/nologin winshare
[ttys3@HuangYeMacBookPro /]$ sudo smbpasswd -a winshare

# 允许kvm虚拟机连接本机的默认zone下的监听的smb (比如通过局域网IP)
[ttys3@HuangYeMacBookPro media]$ sudo firewall-cmd --permanent --add-service=samba
success

# 允许kvm虚拟机连接本机libvirt zone网卡上监听的smb(通过virbr0网卡的IP连接)
# win: net use z: \\192.168.122.1\winshare /user:ttys3 "密码" /persistent:yes
[ttys3@HuangYeMacBookPro media]$ sudo firewall-cmd --permanent --add-service=samba --zone=libvirt


[ttys3@HuangYeMacBookPro media]$ sudo firewall-cmd --reload
success

[root@HuangYeMacBookPro /]# setsebool -P samba_export_all_rw=1
[root@HuangYeMacBookPro /]# setsebool -P samba_share_nfs=1
setsebool -P samba_export_all_ro=1 samba_export_all_rw=1

smb配置常见错误:


客户端输入正确的用户名和密码后提示没有权限. 查看服务端日志可见:

Jan 31 21:13:12 HuangYeMacBookPro.padavan smbd[85205]: [2020/01/31 21:13:12.887831, 0] ../../source3/smbd/uid.c:448(change_to_user_internal)
Jan 31 21:13:12 HuangYeMacBookPro.padavan smbd[85205]: change_to_user_internal: chdir_current_service() failed!

问题的原因:smb用户对应的系统用户对于指定的共享目录没有访问权限.


smb 配置参考:

编辑 /etc/samba/smb.conf, 增加:

假设我们当前登录的用户是 ttys3 :

[winshare]
  comment = Media share accessible by kvm win guest
  path = /home/ttys3/winshare
  valid users = ttys3
  public = no
  writable = yes
  create mask = 0664
  directory mask = 2775
  force create mode = 0664
  force directory mode = 2775

虽然 Linux 已经有 ttys3 这个用户了,但是samba里面有另一套用户权限控制机制(注意:samba用户一定要是已经存在的Linux用户), 但是我们还是要将这个用户添加进samba:

smbpasswd -a ttys3
# 然后设置密码(注意这里的密钥是用于设置samba用户的密码,新设置的,并不是要你输入系统用户的)

参考文档

在 MacBook Air 上安装 Fedora 26 https://linux.cn/article-8690-1.html

http://blog.manton.im/2017/07/mac-book-air-installing-broadcom.html

https://fedoraproject.org/wiki/GRUB_2?rd=Grub2#Updating_GRUB_2_configuration_on_UEFI_systems

(Macbook Air)BCM4360网卡Linux(Ubuntu/Fedora)驱动安装总结 https://blog.csdn.net/zbjdonald/article/details/45015205

https://rpmfusion.org/Configuration

https://rpmfusion.org/Howto/NVIDIA

Fedora Linux – How to Use dnf Command With A Proxy Server https://www.cyberciti.biz/faq/how-to-use-dnf-command-with-a-proxy-server-on-fedora/

https://code.visualstudio.com/docs/setup/linux#_rhel-fedora-and-centos-based-distributions

https://docs.fedoraproject.org/en-US/fedora/f31/system-administrators-guide/servers/File_and_Print_Servers/

https://www.lisenet.com/2016/samba-server-on-rhel-7/

https://www.hiroom2.com/2018/11/30/fedora-29-samba-en/

https://www.tecmint.com/install-samba4-on-centos-7-for-file-sharing-on-windows/

https://wiki.archlinux.org/index.php/Samba

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/5/html/virtualization/sect-virtualization-security_for_virtualization-selinux_and_virtualization

https://wiki.archlinux.org/index.php/Fan_speed_control

https://ineed.coffee/992/mbpfan-v1-4-0-is-out/

https://ineed.coffee/projects/mbpfan/

https://github.com/linux-on-mac/mbpfan

https://docs.fedoraproject.org/en-US/quick-docs/creating-windows-virtual-machines-using-virtio-drivers/index.html

https://pve.proxmox.com/wiki/Windows_VirtIO_Drivers

https://github.com/virtio-win/kvm-guest-drivers-windows

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/virtualization_deployment_and_administration_guide/sect-managing_guest_virtual_machines_with_virsh-editing_a_guest_virtual_machines_configuration_file

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/5/html/virtualization/chap-virtualization-network_configuration#sect-Virtualization-Network_Configuration-Network_address_translation_NAT_with_libvirt

KVM虚拟机网络配置方式 (Bridge方式 Nat方式) https://blog.csdn.net/weixin_36820871/article/details/80595855