在 PVE 中创建虚拟机,打开高级选项。OS 选择 Ubuntu server 安装镜像,System 里机器选择 q35,BIOS 选择 UEFI 并且取消勾选 Pre-Enroll keys,这样安全启动默认是关闭的。最后勾选 Qemu Agent,开启后管理虚拟机会更方便。
关机
qm stop 101
添加显卡
sudo apt update
sudo apt install qemu-guest-agent dialog bash-completion nano
修改root登录
sudo passwd root
输入密码两次 ,在修改
sudo nano /etc/ssh/sshd_config
PermitRootLogin prohibit-password这行去注释,改为 PermitRootLogin yes
如果 Ubuntu 在安装时选择的是 HWE 内核,那么有可能通过 apt 更新就可以安装 6.8 内核。首先命令行执行 uname -r 查看内核版本号,如果返回结果类似 6.8.0-47-generic,证明已经安装 6.8 内核了,可以跳过这一步。如果返回版本不是,请按照下述步骤安装 6.8 内核。
lspci -nn 查看 DG1 的 PCI ID,这里以华硕圣旗全高 80EU 版本为例,返回值如下:
01:00.0 VGA compatible controller [0300]: Intel Corporation DG1 [Iris Xe Graphics] [8086:4908] (rev 01)
这里 [8086:4908] 前四位是制造商 ID,后四位就是我们需要的 PCI ID。然后修改 /etc/default/grub,找到 GRUB_CMDLINE_LINUX_DEFAULT 这一行,在已有参数后面添加 i915.force_probe=!4908 xe.force_probe=4908,记得新增参数要与原有参数以空格隔开。如果之前内核添加过其他 i915 相关参数(比如 i915.enable_guc=3),请删除,因为不会再使用 i915 内核模块驱动 DG1。
修改完成后保存,执行 sudo update-grub 更新 GRUB 启动文件,然后重启。重启完成后执行 sudo lspci -v 查看 DG1 对应信息:
查看 DG1 对应信息:
01:00.0 VGA compatible controller: Intel Corporation DG1 [Iris Xe Graphics] (rev 01) (prog-if 00 [VGA controller])
Subsystem: ASUSTeK Computer Inc. DG1 [Iris Xe Graphics]
Physical Slot: 0
Flags: bus master, fast devsel, latency 0, IRQ 45
Memory at 80000000 (64-bit, non-prefetchable) [size=16M]
Memory at 7000000000 (64-bit, prefetchable) [size=4G]
Expansion ROM at <ignored> [disabled]
Capabilities: [40] Vendor Specific Information: Len=0c <?>
Capabilities: [70] Express Endpoint, MSI 00
Capabilities: [ac] MSI: Enable+ Count=1/1 Maskable+ 64bit+
Capabilities: [d0] Power Management version 3
Capabilities: [100] Latency Tolerance Reporting
Kernel driver in use: xe
Kernel modules: i915, xe
如果出现 Kernel driver in use: xe 说明内核已经在使用 xe 内核模块驱动 DG1。驱动完成后就可以使用 Jellyfin 调用 DG1 硬件解码了。
添加第二块网卡,用户挂载飞牛磁盘
nano /etc/netplan/50-cloud-init.yaml
network:
version: 2
ethernets:
ens18:
dhcp4: true
ens19:
dhcp4: false
addresses:
- 192.168.172.3/24
routes:
- to: 192.168.172.0/24
via: 0.0.0.0
metric: 100
nameservers:
addresses: [8.8.8.8,114.114.114.114]
内网直接走内网流量
执行完以后执行netplan apply重载网络配置
接下来,安装宝塔,然后挂载 飞牛磁盘
Ubuntu 下安装 Jellyfin 有两种方式,一种是通过 apt 安装官方编译的 deb 包,另一种是使用 docker。这里选择 docker 安装,镜像选择 nyanmisaka 大佬制作的 Jellyfin 中国特供版。
首先查看自己用户和用户组的 ID,命令行输入 id 指令,查看显示的 uid 和 gid 的对应值,这里以两个值均是 1000 为例,请修改为自己机器上的数值。
再查看显卡对应用户组,输入 ls -l /dev/dri/ 指令,查看 renderD128 对应的用户组。这里显示为 render。
total 0
drwxr-xr-x 2 root root 80 5月 24 00:23 by-path
crw-rw----+ 1 root video 226, 0 5月 24 00:23 card0
crw-rw----+ 1 root render 226, 128 5月 24 00:23 renderD128
然后输入指令 getent group render | cut -d: -f3 查看 render 组对应的 ID。这里以 ID 是 110 为例,请修改为自己机器上的数值。
docker run -d \
--name jellyfin \
--user 0:0 \
--group-add="993" \
--net=host \
--add-host=api.themoviedb.org:13.225.174.30 \
--add-host=image.tmdb.org:13.227.73.57 \
--add-host=www.themoviedb.org:54.192.22.105 \
--volume /www/wwwroot/beizhi/jellyfin/config:/config \
--volume /www/wwwroot/beizhi/jellyfin/cache:/cache \
-v /www/wwwroot/nfs:/media \
--restart=unless-stopped \
-p 8096:8096 \
-p 8920:8920 \
--device /dev/dri/renderD128:/dev/dri/renderD128 \
--device /dev/dri/:/dev/dri/ \
nyanmisaka/jellyfin