idvworkingtips2

System Installation

Ubuntu 22.04.2 iso, Install with HWE Kernel Selected.
English-> Ubuntu Server(mimimized) -> Skip Ubuntu Pro -> Install OpenSSH server.

sudo apt update
sudo apt install -y vim sddm libvirt-daemon qemu libvirt-daemon-system-systemd libvirt-daemon-driver-qemu libvirt-daemon-system libvirt0

Examine the version:

$ qemu-system-x86_64 --version
QEMU emulator version 6.2.0 (Debian 1:6.2+dfsg-2ubuntu6.6)
Copyright (c) 2003-2021 Fabrice Bellard and the QEMU Project developers

System Configuration

Kernel and modules:

# sudo vim /etc/default/grub
......
GRUB_CMDLINE_LINUX_DEFAULT="intel_iommu=on intel_iommu=pt kvm.ignore_msrs=1"
......
# sudo update-grub2
# sudo vim /etc/initramfs-tools/modules
......
vfio
vfio_iommu_type1
vfio_pci
vfio_virqfd
# update-initramfs -u -k all
# sudo reboot

Use mate for desktop session:

$ sudo apt install -y mate

libvirt hook should be the same.

sddm autologin :

# mkdir -p /etc/sddm.conf.d
# vim /etc/sddm.conf.d/autologin.conf
[Autologin]
User=idv
Session=mate

while the X Session could be viewd as:

l /usr/share/xsessions/
ubuntu.desktop  ubuntu-xorg.desktop

idvworkingtips

0. Hardware

/images/2023_03_28_08_27_44_715x718.jpg

Detailed info:

11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
16GB DDR4-3200(dual channel)
500GB PCIe4.0 ssd

1. System Installation

Downloads iso and write to flash disk(Above 8G):

wget https://mirrors.ustc.edu.cn/rocky/9.1/isos/x86_64/Rocky-9.1-20221214.1-x86_64-dvd.iso
sudo dd if=./Rocky-9.1-20221214.1-x86_64-dvd.iso of=/dev/sdb bs=1M && sudo sync

Install RockLinux 9.1 to nuc.

Installation configurations:

Select English->English(United States)
Set user passwd(Allow root SSH login with password)
Software Selection(Minimal Install)
Partition: Delete /home, shrink swap to 2GiB(example layout----/boot: 1024MiB, /:462.26GiB,/boot/efi: 512MiB, swap: 2GiB)
Create user: idv(make this user to be administrator)
Set hostname: rockyIDV

After installation, change default repo configuration:

$ sudo su
# sed -e 's|^mirrorlist=|#mirrorlist=|g' \
    -e 's|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl=https://mirrors.ustc.edu.cn/rocky|g' \
    -i.bak \
    /etc/yum.repos.d/rocky-extras.repo \
    /etc/yum.repos.d/rocky.repo
# dnf makecache

Instal mate desktop enviroment as the idv graphical UI:

sudo dnf config-manager --set-enabled crb
sudo dnf install epel-release
sudo dnf install NetworkManager-adsl NetworkManager-bluetooth NetworkManager-libreswan-gnome NetworkManager-openvpn-gnome NetworkManager-ovs NetworkManager-ppp NetworkManager-team NetworkManager-wifi NetworkManager-wwan adwaita-gtk2-theme alsa-plugins-pulseaudio atril atril-caja atril-thumbnailer caja caja-actions caja-image-converter caja-open-terminal caja-sendto caja-wallpaper caja-xattr-tags dconf-editor engrampa eom firewall-config gnome-disk-utility gnome-epub-thumbnailer gstreamer1-plugins-ugly-free gtk2-engines gucharmap gvfs-fuse gvfs-gphoto2 gvfs-mtp gvfs-smb initial-setup-gui libmatekbd libmatemixer libmateweather libsecret lm_sensors marco mate-applets mate-backgrounds mate-calc mate-control-center mate-desktop mate-dictionary mate-disk-usage-analyzer mate-icon-theme mate-media mate-menus mate-menus-preferences-category-menu mate-notification-daemon mate-panel mate-polkit mate-power-manager mate-screensaver mate-screenshot mate-search-tool mate-session-manager mate-settings-daemon mate-system-log mate-system-monitor mate-terminal mate-themes mate-user-admin mate-user-guide mozo network-manager-applet nm-connection-editor p7zip p7zip-plugins pluma seahorse seahorse-caja xdg-user-dirs-gtk pciutils vim
sudo dnf install lightdm-settings lightdm
sudo systemctl set-default graphical.target
sudo reboot

Enable the lightdm autologin:

sudo nano /etc/lightdm/lightdm.conf
autologin-user=idv

2. Virtualization Configuration

Install and configure libvirtd:

sudo dnf install libvirt-daemon qemu-kvm virt-top libguestfs-tools virt-install
sudo systemctl enable libvirtd
sudo virsh net-start default

view qemu version:

# /usr/libexec/qemu-kvm --version
QEMU emulator version 7.0.0 (qemu-kvm-7.0.0-13.el9_1.2)
Copyright (c) 2003-2022 Fabrice Bellard and the QEMU Project developers

Kernel default options:

# vi /etc/default/grub
......
GRUB_CMDLINE_LINUX_DEFAULT="intel_iommu=on intel_iommu=pt kvm.ignore_msrs=1"
# grub2-mkconfig -o /boot/efi/EFI/rocky/grub.cfg
# cat /proc/cmdline
Examine the iommu
# sudo dmesg | grep iommu
# sudo dmesg | grep -i dmar

Edit dracut for adding vfio modules:

[idv@rockyIDV ~]$ sudo vim /etc/dracut.conf.d/vfio.conf
add_drivers+="vfio vfio_iommu_type1 vfio_pci vfio_virqfd"
[idv@rockyIDV ~]$ sudo dracut -f --kver  `uname -r`
[idv@rockyIDV ~]$ sudo reboot

3. libvirtd Hooks

Refers to other material.

4. issue

On rocky linux, we got following issues:

[idv@rockyIDV ~]$ ./test_10thFV_win10.sh 
2023-03-28T05:53:46.994085Z qemu-system-x86_64: -device vfio-pci,host=0000:00:02.0,x-igd-gms=2,id=hostdev0,bus=pci.0,addr=2,rombar=0,x-igd-opregion=on: IGD device 0000:00:02.0 does not support OpRegion access,legacy mode disabled
2023-03-28T05:53:46.995006Z qemu-system-x86_64: -device vfio-pci,host=0000:00:02.0,x-igd-gms=2,id=hostdev0,bus=pci.0,addr=2,rombar=0,x-igd-opregion=on: vfio 0000:00:02.0: does not support requested IGD OpRegion feature: No such device

Now change back to Ubuntu22.04.

Also spice-server is removed for rhel9, so got lots of time for building spice related libs.

amdgpupassthrough

Install virt-io drivers:

/images/2023_03_21_11_53_28_763x591.jpg

/images/2023_03_21_11_53_54_593x400.jpg

Then the amd gpu:

/images/2023_03_21_11_54_24_330x162.jpg

Get the driver:

/images/2023_03_21_11_56_45_732x511.jpg

/images/2023_03_21_11_57_03_847x445.jpg

Copy the file into :

/images/2023_03_21_14_59_59_792x170.jpg

Then add it into shutdown items:

/images/2023_03_21_15_00_37_919x622.jpg

Edit its sequence:

/images/2023_03_21_15_01_51_470x422.jpg

eject script:

Function Check-RunAsAdministrator()
{
  #Get current user context
  $CurrentUser = New-Object Security.Principal.WindowsPrincipal $([Security.Principal.WindowsIdentity]::GetCurrent())
  
  #Check user is running the script is member of Administrator Group
  if($CurrentUser.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator))
  {
       Write-host "Script is running with Administrator privileges!"
  }
  else
    {
       #Create a new Elevated process to Start PowerShell
       $ElevatedProcess = New-Object System.Diagnostics.ProcessStartInfo "PowerShell";
 
       # Specify the current script path and name as a parameter
       $ElevatedProcess.Arguments = "& '" + $script:MyInvocation.MyCommand.Path + "'"
 
       #Set the Process to elevated
       $ElevatedProcess.Verb = "runas"
 
       #Start the new elevated process
       [System.Diagnostics.Process]::Start($ElevatedProcess)
 
       #Exit from the current, unelevated, process
       Exit
 
    }
}
 
#Check Script is running with Elevated Privileges
Check-RunAsAdministrator
 
#Place your script here.
     $deviceName="AMD Radeon(TM) Graphics"
foreach ($dev in (Get-PnpDevice | Where-Object{$_.Name -eq $deviceName})) {
  &"pnputil" /remove-device $dev.InstanceId 
}
# sleep for 8 seconds
Start-Sleep -Seconds 8

#Read more: https://www.sharepointdiary.com/2015/01/run-powershell-script-as-administrator-automatically.html#ixzz7wTuWTBny% 

RecoveryFromUEFI

Use archlinux installation disk for entering the command line, then:

mkdir /mnt/arch
mount -t auto /dev/sda2 /mnt/arch
mount -t auto /dev/sda1 /mnt/arch/boot/
arch-chroot /mnt/arch

Re-install grub:

grub-install --efi-directory=/boot/efi --target=x86_64-efi /dev/sda

Then reboot the machine we could see the archlinux reback again.

WorkingTipsOnExtractingBiosItems

from https://www.laomaotao.net/doc/udiskwinpe.html, download the LaoMaoTao and extract it to usb disk .
Use winpe for startup the system.

uefitool for generating the vbt.bin and gop file, but failed.