this fork of void-packages contains a linux5.7 kernel patched with the tkg patches which is aimed at improving gaming performance as well as making gpu passthrough easier with the acs override patch
set up my void-packages fork
git clone git://github.com/Francesco149/void-packages.git
cd void-packages
./xbps-src binary-bootstrap
build the kernel. you will be interactively asked to configure each tweak
./xbps-src clean linux5.7 && ./xbps-src pkg linux5.7
install
sudo xbps-install --force --repository=hostdir/binpkgs/linux5.7-tkg/ linux5.7 linux5.7-headers
now you can edit /etc/default/grub to enable features from the commandline
after the edits, regenerate your initramfs and grub and reboot
sudo dracut --force --regenerate-all
sudo grub-mkconfig -o /boot/grub/grub.cfg
to verify that you are booted into the modified kernel you can check that the config contains a PBS scheduler
gunzip < /proc/config.gz | grep SCHED_PDS
note that kernel updates beyond the patched version will install an un-patched kernel so you will
have to manually select the old version from grub if that happens. I have appended tkg
to the
version number in an attempt to prevent this, but I'm not sure
my personal gaming setup has acs override for gpu passthrough, iommu, 1ms kb/mouse/joystick poll rate, disabled all spectre/meltdown mitigations (use at your own risk), and reserves 1x8GB of hugepages for virtual machines at boot
#
# Configuration file for GRUB.
#
GRUB_DEFAULT=0
#GRUB_HIDDEN_TIMEOUT=0
#GRUB_HIDDEN_TIMEOUT_QUIET=false
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="Void"
cmdline="$cmdline loglevel=4 slub_debug=P page_poison=1"
cmdline="$cmdline radeon.si_support=0 amdgpu.si_support=1 radeon.cik_support=0 amdgpu.cik_support=1"
cmdline="$cmdline usbhid.kbpoll=1 usbhid.mousepoll=1 usbhid.jspoll=1"
cmdline="$cmdline noibrs noibpb nopti nospectre_v2 nospectre_v1 l1tf=off nospec_store_bypass_disable"
cmdline="$cmdline no_stf_barrier mds=off mitigations=off"
cmdline="$cmdline amd_iommu=on intel_iommu=on iommu=pt rd.driver.pre=vfio-pci"
cmdline="$cmdline pcie_acs_override=downstream,multifunction"
cmdline="$cmdline default_hugepagesz=1GB hugepagesz=1GB hugepages=8"
GRUB_CMDLINE_LINUX_DEFAULT="$cmdline"
# Uncomment to use basic console
#GRUB_TERMINAL_INPUT="console"
# Uncomment to disable graphical terminal
#GRUB_TERMINAL_OUTPUT=console
#GRUB_BACKGROUND=/usr/share/void-artwork/splash.png
#GRUB_GFXMODE=1920x1080x32
#GRUB_DISABLE_LINUX_UUID=true
#GRUB_DISABLE_RECOVERY=true
# Uncomment and set to the desired menu colors. Used by normal and wallpaper
# modes only. Entries specified as foreground/background.
#GRUB_COLOR_NORMAL="light-blue/black"
#GRUB_COLOR_HIGHLIGHT="light-cyan/blue"
I also have these scripts that load vfio and passthrough every gpu except the boot gpu
they are based on: https://qubitrenegade.com/virtualization/kvm/vfio/2019/07/17/VFIO-Fedora-Notes.html
cat > /etc/modprobe.d/vfio.conf << "EOF"
install vfio-pci /sbin/vfio-pci-override.sh
EOF
cat > /etc/dracut.conf.d/vfio.conf << "EOF"
add_drivers+="vfio vfio_iommu_type1 vfio_pci vfio_virqfd"
hostonly="yes"
hostonly_cmdline="amd_iommu=on iommu=pt"
force_drivers+="vfio_pci vfio vfio_iommu_type1 vfio_virqfd"
install_items+="/sbin/vfio-pci-override.sh /sbin/dirname"
EOF
cat > /sbin/vfio-pci-override.sh << "EOF"
#!/bin/bash
echo "vfio-pci-override running" > /dev/kmsg
set -u
for boot_vga in /sys/bus/pci/devices/*/boot_vga; do
echo "Found vga device: ${boot_vga}" > /dev/kmsg
if [ $(<"${boot_vga}") -eq 0 ]; then
echo "Found Boot VGA Device - false: ${boot_vga}" > /dev/kmsg
dir=$(dirname -- "${boot_vga}")
for dev in "${dir::-1}"*; do
echo "Registering Devices: ${dev}" > /dev/kmsg
echo 'vfio-pci' > "${dev}/driver_override"
done
else
echo "Found Boot VGA Device - true: ${boot_vga}" > /dev/kmsg
fi
done
modprobe -i vfio-pci
EOF
chmod +x /sbin/vfio-pci-override.sh
This repository contains the XBPS source packages collection to build binary packages for the Void Linux distribution.
The included xbps-src
script will fetch and compile the sources, and install its
files into a fake destdir
to generate XBPS binary packages that can be installed
or queried through the xbps-install(1)
and xbps-query(1)
utilities, respectively.
See Contributing for a general overview of how to contribute and the Manual for details of how to create source packages.
- Requirements
- Quick start
- chroot methods
- Install the bootstrap packages
- Configuration
- Directory hierarchy
- Building packages
- Package build options
- Sharing and signing your local repositories
- Rebuilding and overwriting existing local packages
- Enabling distcc for distributed compilation
- Distfiles mirrors
- Cross compiling packages for a target architecture
- Using xbps-src in a foreign Linux distribution
- Remaking the masterdir
- Keeping your masterdir uptodate
- Building 32bit packages on x86_64
- Building packages natively for the musl C library
- Building void base-system from scratch
- GNU bash
- xbps >= 0.56
- curl(1) - required by
xbps-src update-check
- flock(1) - util-linux
- bsdtar or GNU tar (in that order of preference)
- install(1) - GNU coreutils
- objcopy(1), objdump(1), strip(1): binutils
- other common POSIX utilities included by default in almost all UNIX systems.
xbps-src
requires a utility to chroot and bind mount existing directories
into a masterdir
that is used as its main chroot
directory. xbps-src
supports
multiple utilities to accomplish this task:
bwrap
- bubblewrap, see https://github.com/projectatomic/bubblewrap.ethereal
- only useful for one-shot containers, i.e docker (used with travis).xbps-uunshare(1)
- XBPS utility that usesuser_namespaces(7)
(part of xbps, default).xbps-uchroot(1)
- XBPS utility that usesnamespaces
and must besetgid
(part of xbps).proot(1)
- utility that implements chroot/bind mounts in user space, see https://proot-me.github.io/.
NOTE:
xbps-src
does not allow building as root anymore. Use one of the chroot methods shown above.
Clone the void-packages
git repository and install the bootstrap packages:
$ git clone git://github.com/void-linux/void-packages.git
$ cd void-packages
$ ./xbps-src binary-bootstrap
Build a package by specifying the pkg
target and the package name:
$ ./xbps-src pkg <package_name>
Use ./xbps-src -h
to list all available targets and options.
To build packages marked as 'restricted', modify etc/conf
:
$ echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
Once built, the package will be available in hostdir/binpkgs
or an appropriate subdirectory (e.g. hostdir/binpkgs/nonfree
). To install the package:
# xbps-install --repository hostdir/binpkgs <package_name>
Alternatively, packages can be installed with the xi
utility, from the xtools
package. xi
takes the repository of the current working directory into account.
# xi <package_name>
This utility requires these Linux kernel options:
- CONFIG_NAMESPACES
- CONFIG_IPC_NS
- CONFIG_UTS_NS
- CONFIG_USER_NS
This is the default method, and if your system does not support any of the required kernel
options it will fail with EINVAL (Invalid argument)
.
This utility requires these Linux kernel options:
- CONFIG_NAMESPACES
- CONFIG_IPC_NS
- CONFIG_PID_NS
- CONFIG_UTS_NS
Your user must be added to a special group to be able to use xbps-uchroot(1)
and the
executable must be setgid
:
# chown root:<group> xbps-uchroot
# chmod 4750 xbps-uchroot
# usermod -a -G <group> <user>
NOTE: by default in void you shouldn't do this manually, your user must be a member of the
xbuilder
group.
To enable it:
$ cd void-packages
$ echo XBPS_CHROOT_CMD=uchroot >> etc/conf
If for some reason it's erroring out as ERROR clone (Operation not permitted)
, check that
your user is a member of the required group
and that xbps-uchroot(1)
utility has the
proper permissions and owner/group as explained above.
The proot(1)
utility implements chroot and bind mounts support completely in user space,
and can be used if your Linux kernel does not have support for namespaces. See https://proot-me.github.io/.
for more information.
To enable it:
$ cd void-packages
$ echo XBPS_CHROOT_CMD=proot >> etc/conf
There is a set of packages that makes up the initial build container, called the bootstrap
.
These packages are installed into the masterdir
in order to create the container.
The primary and recommended way to set up this container is using the binary-bootstrap
command. This will use pre-existing binary packages, either from remote xbps
repositories
or from your local repository.
There is also the bootstrap
command, which will build all necessary bootstrap
packages from
scratch. This is usually not recommended, since those packages are built using your host system's
toolchain and are neither fully featured nor reproducible (your host system may influence the
build) and thus should only be used as a stage 0 for bootstrapping new Void systems.
If you still choose to use bootstrap
, use the resulting stage 0 container to rebuild all
bootstrap
packages again, then use binary-bootstrap
(stage 1) and rebuild the bootstrap
packages once more (to gain stage 2, and then use binary-bootstrap
again). Once you've done
that, you will have a bootstrap
set equivalent to using binary-bootstrap
in the first place.
Also keep in mind that a full source bootstrap
is time consuming and will require having an
assortment of utilities installed in your host system, such as binutils
, gcc
, perl
,
texinfo
and others.
The etc/defaults.conf
file contains the possible settings that can be overridden
through the etc/conf
configuration file for the xbps-src
utility; if that file
does not exist, will try to read configuration settings from $XDG_CONFIG_HOME/xbps-src.conf
, ~/.config/xbps-src.conf
, ~/.xbps-src.conf
.
If you want to customize default CFLAGS
, CXXFLAGS
and LDFLAGS
, don't override
those defined in etc/defaults.conf
, set them on etc/conf
instead i.e:
$ echo 'XBPS_CFLAGS="your flags here"' >> etc/conf
$ echo 'XBPS_LDFLAGS="your flags here"' >> etc/conf
Native and cross compiler/linker flags are set per architecture in common/build-profiles
and common/cross-profiles
respectively. Ideally those settings are good enough by default,
and there's no need to set your own unless you know what you are doing.
The etc/defaults.virtual
file contains the default replacements for virtual packages,
used as dependencies in the source packages tree.
If you want to customize those replacements, copy etc/defaults.virtual
to etc/virtual
and edit it accordingly to your needs.
The following directory hierarchy is used with a default configuration file:
/void-packages
|- common
|- etc
|- srcpkgs
| |- xbps
| |- template
|
|- hostdir
| |- binpkgs ...
| |- ccache ...
| |- distcc-<arch> ...
| |- repocache ...
| |- sources ...
|
|- masterdir
| |- builddir -> ...
| |- destdir -> ...
| |- host -> bind mounted from <hostdir>
| |- void-packages -> bind mounted from <void-packages>
The description of these directories is as follows:
masterdir
: master directory to be used as rootfs to build/install packages.builddir
: to unpack package source tarballs and where packages are built.destdir
: to install packages, aka fake destdir.hostdir/ccache
: to store ccache data if theXBPS_CCACHE
option is enabled.hostdir/distcc-<arch>
: to store distcc data if theXBPS_DISTCC
option is enabled.hostdir/repocache
: to store binary packages from remote repositories.hostdir/sources
: to store package sources.hostdir/binpkgs
: local repository to store generated binary packages.
The simplest form of building package is accomplished by running the pkg
target in xbps-src
:
$ cd void-packages
$ ./xbps-src pkg <pkgname>
When the package and its required dependencies are built, the binary packages will be created
and registered in the default local repository at hostdir/binpkgs
; the path to this local repository can be added to
any xbps configuration file (see xbps.d(5)) or by explicitly appending them via cmdline, i.e:
$ xbps-install --repository=hostdir/binpkgs ...
$ xbps-query --repository=hostdir/binpkgs ...
By default xbps-src will try to resolve package dependencies in this order:
- If a dependency exists in the local repository, use it (
hostdir/binpkgs
). - If a dependency exists in a remote repository, use it.
- If a dependency exists in a source package, use it.
It is possible to avoid using remote repositories completely by using the -N
flag.
The default local repository may contain multiple sub-repositories:
debug
,multilib
, etc.
The supported build options for a source package can be shown with xbps-src show-options
:
$ ./xbps-src show-options foo
Build options can be enabled with the -o
flag of xbps-src
:
$ ./xbps-src -o option,option1 pkg foo
Build options can be disabled by prefixing them with ~
:
$ ./xbps-src -o ~option,~option1 pkg foo
Both ways can be used together to enable and/or disable multiple options
at the same time with xbps-src
:
$ ./xbps-src -o option,~option1,~option2 pkg foo
The build options can also be shown for binary packages via xbps-query(1)
:
$ xbps-query -R --property=build-options foo