root@pve:~# vim /etc/default/grub
root@pve:~#
root@pve:~# cat /etc/default/grub
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
# info -f grub -n 'Simple configuration'
GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on video=efifb:off"
GRUB_CMDLINE_LINUX=""
# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"
# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console
# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480
# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true
# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"
# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"
root@pve:~#
开启IOMMU支持:
GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on video=efifb:off"
如果是AMD的CPU:
GRUB_CMDLINE_LINUX_DEFAULT="quiet amd_iommu=on video=efifb:off"
更新GRUB:
root@pve:~# update-grub
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.11.22-5-pve
Found initrd image: /boot/initrd.img-5.11.22-5-pve
Found linux image: /boot/vmlinuz-5.11.22-4-pve
Found initrd image: /boot/initrd.img-5.11.22-4-pve
Found memtest86+ image: /boot/memtest86+.bin
Found memtest86+ multiboot image: /boot/memtest86+_multiboot.bin
done
root@pve:~#
添加所需的系统模块(驱动):
root@pve:~#
root@pve:~# echo "vfio" >> /etc/modules
root@pve:~# echo "vfio_iommu_type1" >> /etc/modules
root@pve:~# echo "vfio_pci" >> /etc/modules
root@pve:~# echo "vfio_virqfd" >> /etc/modules
root@pve:~#
root@pve:~# cat /etc/modules
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
# Generated by sensors-detect on Fri Sep 24 17:22:44 2021
# Chip drivers
coretemp
vfio
vfio_iommu_type1
vfio_pci
vfio_virqfd
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
/sbin/ethtool -s enp3s0 wol g
exit 0
比较新的Linux发行版已经没有rc.local文件了。因为已经将其服务化了。
解决方法:
1、设置rc-local.service
1 2 3 4 5 6 7 8 9 10 11 12 13
sudo vim /etc/systemd/system/rc-local.service[Unit]Description=/etc/rc.local CompatibilityConditionPathExists=/etc/rc.local[Service]Type=forkingExecStart=/etc/rc.local startTimeoutSec=0StandardOutput=ttyRemainAfterExit=yesSysVStartPriority=99[Install]WantedBy=multi-user.target
2、激活rc-local.service
1
sudo systemctl enable rc-local.service
3、添加启动服务
手工创建或者拷贝已有的/etc/rc.local,并赋予执行权限
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#!/bin/sh -e## rc.local## This script is executed at the end of each multiuser runlevel.# Make sure that the script will "exit 0" on success or any other# value on error.## In order to enable or disable this script just change the execution# bits.## By default this script does nothing.# 下面这条是要开机启动的命令/home/selfcs/anaconda3/bin/python /home/selfcs/t.py > /home/selfcs/auto.logexit 0#给予脚本执行权限sudo chmod +x /etc/rc.local