I found a solution for while googling. You have to put a script in rc.local
specifying which VGA you want to use.
This link explains everything.
I will post important notes here:
First install needed driver and script from git
sudo apt-get install git && cd ~/
git clone https://github.com/mkottman/acpi_call.git
cd acpi_call && make
sudo insmod acpi_call.ko
chmod a+x test_off.sh
de-activate ATI VGA
sh test_off.sh
Now you can check if your ATI VGA is already disabled by lspci -vnnn | grep VGA
.
It will show the following output:
00:02.0 VGA compatible controller [0300]: Intel Corporation 2nd Generation Core Processor Family Integrated Graphics Controller [8086:0116] (rev 09) (prog-if 00 [VGA controller])
01:00.0 VGA compatible controller [0300]: ATI Technologies Inc NI Seymour [AMD Radeon HD 3650M] [1002:6760] (rev ff) (prog-if ff)
If it works, to make this run at boot, edit /etc/rc.local
:
sudo insmod /acpi_call/acpi_call.ko
sudo sh /acpi_call/test_off.sh
Also, remove radeon blacklisting by editing /etc/modprobe.d/blacklist.conf
:
#blacklist radeon
You should have xorg.conf
like this to make VGA detectable :
Section "ServerLayout"
Identifier "aticonfig Layout"
Screen 0 "aticonfig-Screen[0]-0" 0 0
EndSection
Section "Module"
Load "glx"
EndSection
Section "Monitor"
Identifier "aticonfig-Monitor[0]-0"
Option "VendorName" "ATI Proprietary Driver"
Option "ModelName" "Generic Autodetecting Monitor"
Option "DPMS" "true"
EndSection
Section "Device"
Identifier "aticonfig-Device[0]-0"
# Driver "fglrx"
BusID "PCI:1:0:0"
EndSection
# Section "Screen"
# Identifier "Default Screen"
# DefaultDepth 24
# EndSection
Section "Screen"
Identifier "aticonfig-Screen[0]-0"
Device "aticonfig-Device[0]-0"
Monitor "aticonfig-Monitor[0]-0"
DefaultDepth 24
SubSection "Display"
Viewport 0 0
Depth 24
EndSubSection
EndSection
Note: To activate ATI/AMD radeon VGA again:
Just comment what we've added to rc.local
Solution 2
I found this solution from askubuntu.com, I might be easier to put into practice:
This question assumes using vga_switcheroo.
Add this to /etc/fstab
:
none /sys/kernel/debug debugfs defaults 0 0
Starting with this tutorial I got AMD 5450 passthrough of primary
graphics card (host runs headless) working with the below script.
- Doing the standard vfio preparation
- add
video=efifb:off
to cmdline otherwise efifb would grab the PCI bar before vfio.
- Guest UEFI (OVMF image from
apt-get install ovmf
)
-vga qlx
used and later qlx Monitor is disabled inside Windows (Display Settings)
- no romfiles for AMD 5450.
I also tried with a NVidia 710b, however whas permanently stuck with "Code 43".
Probably because romfiles are needed there when trying to passthrough the primary card.
Script:
#!/bin/bash
b=$(pwd)
passthrough=0
qxl=1
uefi=1
ovmf=0
net=0
while getopts "bpQUon" opt; do
case $opt in
p) passthrough=1 ;;
Q) qxl=0 ;;
U) uefi=0 ;;
n) net=1 ;;
o) ovmf=1 ;;
esac
done
cp ${b}/uefi/usr/share/edk2.git/ovmf-x64/OVMF_VARS-pure-efi.fd .
OPTS=""
# Basic CPU settings.
OPTS="$OPTS -cpu host,kvm=off"
OPTS="$OPTS -smp 4,sockets=1,cores=4,threads=1"
# Enable KVM full virtualization support.
OPTS="$OPTS -enable-kvm"
# Assign memory to the vm.
OPTS="$OPTS -m 4000"
# VFIO GPU and GPU sound passthrough.
if [ "$passthrough" == "1" ]; then
#,multifunction=on,romfile=/mnt/nvidia_efi.rom" ,romfile=${b}/bioses/XFX.HD5450.1024.110612.rom
#OPTS="$OPTS -device vfio-pci,host=05:00.0,multifunction=on,romfile=${b}/bioses/XFX.HD5450.1024.110612.rom"
#,romfile=${b}/bioses/XFX.HD5450.1024.110612_1.rom
OPTS="$OPTS -device vfio-pci,host=01:00.0,multifunction=on"
#,romfile=/mnt/data-n0/vms-win/romfile_radeon.bin
#,romfile=/mnt/nvidia_efi.rom"
OPTS="$OPTS -device vfio-pci,host=01:00.1"
fi
# Supply OVMF (general UEFI bios, needed for EFI boot support with GPT disks).
if [ "$uefi" == "1" ]; then
if [ "$ovmf" == "0" ]; then
OPTS="$OPTS -drive if=pflash,format=raw,readonly,file=${b}/uefi/usr/share/edk2.git/ovmf-x64/OVMF_VARS-pure-efi.fd"
OPTS="$OPTS -drive if=pflash,format=raw,file=${b}/OVMF_VARS-pure-efi.fd"
else
mkdir -p ${b}/hda-contents
#OPTS="$OPTS -pflash ${b}/ovmf_pkg/OVMF.fd"
OPTS="$OPTS -drive if=pflash,format=raw,readonly,file=${b}/ovmf_pkg/OVMF.fd"
OPTS="$OPTS -drive if=pflash,format=raw,file=${b}/OVMF_VARS-pure-efi.fd"
fi
fi
# Load our created VM image as a harddrive.
OPTS="$OPTS -hda ${b}/win10_uefi_cpu_host_qemu_vm.qcow2"
# Load our OS setup image e.g. ISO file.
#OPTS="$OPTS -cdrom ${b}/windows_10.iso"
OPTS="$OPTS -cdrom ${b}/virtio-win-0.1.141.iso"
if [ "$qxl" == "1" ]; then
# Use the following emulated video device (use none for disabled).
OPTS="$OPTS -vga qxl"
else
# Use an emulated video device (use none for disabled).
# -vga none -device qxl
OPTS="$OPTS -vga none -device qxl "
fi
OPTS="$OPTS -spice port=5900,addr=127.0.0.1,disable-ticketing "
# Redirect QEMU's console input and output.
OPTS="$OPTS -monitor stdio"
if [ "${net}" == "1" ]; then
# Improve the network performance by utilizing virtio-net.
OPTS="$OPTS -device virtio-net,netdev=net0,mac=de:ad:be:ef:33:4a"
OPTS="$OPTS -netdev tap,id=net0,ifname=vmtap0,script=./qemu-ifup,downscript=./qemu-ifdown"
else
OPTS="$OPTS -net none "
fi
#Bus 003 Device 004: ID 1c4f:0002 SiGma Micro Keyboard TRACER Gamma Ivory
#Bus 003 Device 002: ID 1a40:0201 Terminus Technology Inc. FE 2.1 7-port Hub
# USB mouse
if [ "$passthrough" == "1" ]; then
OPTS="$OPTS -usb"
OPTS="$OPTS -device usb-ehci,id=ehci"
OPTS="$OPTS -device usb-host,bus=usb-bus.0,vendorid=0x17ef,productid=0x6019 "
OPTS="$OPTS -device usb-host,bus=usb-bus.0,vendorid=0x1c4f,productid=0x0002 "
fi
#if [ "$passthrough" == "1" ]; then
# OPTS="$OPTS -usb"
# OPTS="$OPTS -device usb-ehci,id=ehci"
# OPTS="$OPTS -device usb-host,bus=usb-bus.0,vendorid=0x17ef,productid=0x6019 "
# OPTS="$OPTS -device usb-host,bus=usb-bus.0,vendorid=0x1c4f,productid=0x0002 "
#fi
#OPTS="$OPTS -device usb-host,hostbus=3,hostaddr=4"
#OPTS="$OPTS -device usb-host,hostbus=3,hostaddr=2"
#OPTS="$OPTS -device usb-host,bus=xhci.0,vendorid=0x1c4f,productid=0x0002 "
#OPTS="$OPTS -device usb-host,bus=xhci.0,vendorid=0x1a40,productid=0x0201 "
#OPTS="$OPTS -usbdevice host:1c4f:0002"
# USB keyboard
#OPTS="$OPTS -usbdevice host:1a40:0201"
sudo qemu-system-x86_64 $OPTS
Best Answer
Your question is a bit ambigous. If you want to install ubuntu without any keyboard/monitor present, then you need to automate the installation. You'll generally find a lot of information about that if you look for "preseed" file and netinstallation. Please be aware that this may require some pre-existing infrastructure, depending on the exact method chosen (such as DHCP, TFTP services). You also want to do this with ubuntu server.
However please note that even KVM guests generally do have (virtualized) keyboard, mouse and monitor outputs and the KVM host on which the KVM guests run on generally have the ability to give you access to those via VNC connection. The end result is that you have a "headless" server but still console control over it remotely via VNC and you can perform the installation as if you had a monitor and keyboard on a real physical server.
Unless you really want to learn to automate an ubuntu server installation with no questions asked I strongly suggest investing time to see how you can get the console of KVM guests to appear whereever it is you are working from.