https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&user=Androb&feedformat=atomAlpine Linux - User contributions [en]2024-03-29T12:05:47ZUser contributionsMediaWiki 1.40.0https://wiki.alpinelinux.org/w/index.php?title=Installing_Oracle_Java&diff=21890Installing Oracle Java2022-05-18T10:21:11Z<p>Androb: </p>
<hr />
<div>Using java requires having grsec play nice with the binaries. You may also want to install the JDK instead of the JRE depending on your needs.<br />
<br />
This guide assumes you're running as root.<br />
<br />
Download XXX-XXX-linux-x64.tar.gz from either the JRE or JDK section here:<br />
https://www.oracle.com/technetwork/java/javase/downloads/index.html<br />
<br />
mkdir -p /opt/java<br />
cd /opt/java<br />
sudo tar -zxvf XXX-XXX-linux-x64.tar.gz <br />
<br />
Take note of the directory, e.g. /opt/java/jdk1.8.0_121, create a symbolic link as the current version:<br />
<br />
ln -s /opt/java/jdk1.8.0_121 /opt/java/current<br />
<br />
Create a file in '''/etc/profile.d/java.sh''':<br />
export JAVA_HOME=/opt/java/current<br />
export PATH=$PATH:$JAVA_HOME/bin<br />
<br />
Execute this script or restart your shell:<br />
sh /etc/profile.d/java.sh<br />
<br />
Now we need manage grsec with paxctl. Use this command to check if its installed:<br />
which paxctl<br />
<br />
If nothing comes up install it:<br />
<br />
apk add paxctl<br />
<br />
Now in your /opt/java/XXX/bin folder, execute:<br />
paxctl -c java<br />
paxctl -m java<br />
<br />
If you have the JDK, you need to do the same to javac:<br />
paxctl -c javac<br />
paxctl -m javac<br />
<br />
You can do this for any other binary you need to use.<br />
<br />
NOTE: some users have reported they had to use this command to get it working:<br />
<br />
setfattr -n user.pax.flags -v "mr" java<br />
setfattr -n user.pax.flags -v "mr" javac<br />
<br />
<br />
'''Alternative installation of Oracle Java on Linux Alpine'''<br />
<br />
1. Run apk update && apk upgrade<br />
2. Edit vim /etc/profile, add the value before the string: append_path "/user/local/sbin", value: append_path "/opt/java/current/bin"<br />
3. Download XXX-XXX-linux-x64.tar.gz and jce_policy-8.zip from official oracle suite.<br />
4. Сreate a directory in the root: mkdir -p /opt/java<br />
5. Copy XXX-XXX-linux-x64.tar.gz in the java directory: scp /home/username/XXX-XXX-linux-x64.tar.gz /opt/java/<br />
6. Let's go to the catalog java: cd /opt/java and unpack the file: XXX-XXX-linux-x64.tar.gz, tar -zxvf XXX-XXX-linux-x64.tar.gz<br />
7. Create simlink: ln -s /opt/java/jdkX.X.X_XXX /opt/java/current<br />
8. Download and install the certificate: wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub<br />
9. Download glibc: wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.34-r0/glibc-2.34-r0.apk<br />
10. Install glibc: apk add glibc-2.34-r0.apk<br />
11. Download glibc-bin: wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.34-r0/glibc-bin-2.34-r0.apk<br />
12. Install glibc-bin: apk add glibc-bin-2.34-r0.apk<br />
13. Install the license jce_policy-8.zip, сopy the file: scp /home/username/jce_policy-8.zip /opt/java/current/jre/lib/security/<br />
14. Let's go to the folder /opt/java/current/jre/lib/security/: cd /opt/java/current/jre/lib/security/ and unpack it: unzip -o -j jce_policy-8.zip UnlimitedJCEPolicyJDK8/*.jar<br />
15. Delete the archive file: rm -f jce_policy-8.zip<br />
16. Restart the computer or virtual machine: reboot<br />
17. Let's check the version of Java installed: java -version<br />
18. If it displays: java version "X.X.X_XXX", then we did everything correctly.<br />
= =<br />
* [https://blog.overops.com/author/shahar_valiano/ Native Java Debugging on Alpine Linux: GDB, OpenJDK and the Mysterious Unknown Signal] Shahar Valiano 2019 <br />
<br />
[[Category:Programming]]</div>Androbhttps://wiki.alpinelinux.org/w/index.php?title=Installing_Oracle_Java&diff=21889Installing Oracle Java2022-05-18T10:19:51Z<p>Androb: </p>
<hr />
<div>Using java requires having grsec play nice with the binaries. You may also want to install the JDK instead of the JRE depending on your needs.<br />
<br />
This guide assumes you're running as root.<br />
<br />
Download XXX-XXX-linux-x64.tar.gz from either the JRE or JDK section here:<br />
https://www.oracle.com/technetwork/java/javase/downloads/index.html<br />
<br />
mkdir -p /opt/java<br />
cd /opt/java<br />
sudo tar -zxvf XXX-XXX-linux-x64.tar.gz <br />
<br />
Take note of the directory, e.g. /opt/java/jdk1.8.0_121, create a symbolic link as the current version:<br />
<br />
ln -s /opt/java/jdk1.8.0_121 /opt/java/current<br />
<br />
Create a file in '''/etc/profile.d/java.sh''':<br />
export JAVA_HOME=/opt/java/current<br />
export PATH=$PATH:$JAVA_HOME/bin<br />
<br />
Execute this script or restart your shell:<br />
sh /etc/profile.d/java.sh<br />
<br />
Now we need manage grsec with paxctl. Use this command to check if its installed:<br />
which paxctl<br />
<br />
If nothing comes up install it:<br />
<br />
apk add paxctl<br />
<br />
Now in your /opt/java/XXX/bin folder, execute:<br />
paxctl -c java<br />
paxctl -m java<br />
<br />
If you have the JDK, you need to do the same to javac:<br />
paxctl -c javac<br />
paxctl -m javac<br />
<br />
You can do this for any other binary you need to use.<br />
<br />
NOTE: some users have reported they had to use this command to get it working:<br />
<br />
setfattr -n user.pax.flags -v "mr" java<br />
setfattr -n user.pax.flags -v "mr" javac<br />
<br />
<br />
'''Alternative installation of Oracle Java on Linux Alpine'''<br />
<br />
1. Run apk update && apk upgrade<br />
2. Edit vim /etc/profile, add the value before the string: append_path "/user/local/sbin", value: append_path "/opt/java/current/bin"<br />
3. Download XXX-XXX-linux-x64.tar.gz and jce_policy-8.zip from official oracle suite.<br />
4. Сreate a directory in the root: mkdir -p /opt/java<br />
5. Copy XXX-XXX-linux-x64.tar.gz in the java directory: scp /home/username/XXX-XXX-linux-x64.tar.gz /opt/java/<br />
6. Let's go to the catalog java: cd /opt/java and unpack the file: XXX-XXX-linux-x64.tar.gz, tar -zxvf XXX-XXX-linux-x64.tar.gz<br />
7. Create simlink: ln -s /opt/java/jdkX.X.X_XXX /opt/java/current<br />
8. Download and install the certificate: wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub<br />
9. Download glibc: wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.34-r0/glibc-2.34-r0.apk<br />
10. Install glibc: apk add glibc-2.34-r0.apk<br />
11. Download glibc-bin: wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.34-r0/glibc-bin-2.34-r0.apk<br />
12. Install glibc-bin: apk add glibc-bin-2.34-r0.apk<br />
13. Install the license jce_policy-8.zip, сopy the file: scp /home/username/jce_policy-8.zip /opt/java/current/jre/lib/security/<br />
14. Let's go to the folder /opt/java/current/jre/lib/security/: cd /opt/java/current/jre/lib/security/ and unpack it: unzip -o -j jce_policy-8.zip UnlimitedJCEPolicyJDK8/*.jar<br />
15. Delete the archive file: rm -f jce_policy-8.zip<br />
16. Restart the computer or virtual machine: reboot<br />
17. Let's check the version of Java installed: java -version<br />
18. If it displays: java version "X.X.X_XXX", then we did everything correctly.<br />
= =<br />
* [https://blog.overops.com/author/shahar_valiano/ Native Java Debugging on Alpine Linux: GDB, OpenJDK and the Mysterious Unknown Signal] Shahar Valiano 2019 <br />
<br />
[[Category:Programming]]</div>Androbhttps://wiki.alpinelinux.org/w/index.php?title=Installing_Oracle_Java&diff=21888Installing Oracle Java2022-05-18T09:59:00Z<p>Androb: </p>
<hr />
<div>Using java requires having grsec play nice with the binaries. You may also want to install the JDK instead of the JRE depending on your needs.<br />
<br />
This guide assumes you're running as root.<br />
<br />
Download XXX-XXX-linux-x64.tar.gz from either the JRE or JDK section here:<br />
https://www.oracle.com/technetwork/java/javase/downloads/index.html<br />
<br />
mkdir -p /opt/java<br />
cd /opt/java<br />
sudo tar -zxvf XXX-XXX-linux-x64.tar.gz <br />
<br />
Take note of the directory, e.g. /opt/java/jdk1.8.0_121, create a symbolic link as the current version:<br />
<br />
ln -s /opt/java/jdk1.8.0_121 /opt/java/current<br />
<br />
Create a file in '''/etc/profile.d/java.sh''':<br />
export JAVA_HOME=/opt/java/current<br />
export PATH=$PATH:$JAVA_HOME/bin<br />
<br />
Execute this script or restart your shell:<br />
sh /etc/profile.d/java.sh<br />
<br />
Now we need manage grsec with paxctl. Use this command to check if its installed:<br />
which paxctl<br />
<br />
If nothing comes up install it:<br />
<br />
apk add paxctl<br />
<br />
Now in your /opt/java/XXX/bin folder, execute:<br />
paxctl -c java<br />
paxctl -m java<br />
<br />
If you have the JDK, you need to do the same to javac:<br />
paxctl -c javac<br />
paxctl -m javac<br />
<br />
You can do this for any other binary you need to use.<br />
<br />
NOTE: some users have reported they had to use this command to get it working:<br />
<br />
setfattr -n user.pax.flags -v "mr" java<br />
setfattr -n user.pax.flags -v "mr" javac<br />
<br />
'''Alternative installation of Oracle Java on Linux Alpine'''<br />
<br />
= =<br />
* [https://blog.overops.com/author/shahar_valiano/ Native Java Debugging on Alpine Linux: GDB, OpenJDK and the Mysterious Unknown Signal] Shahar Valiano 2019 <br />
<br />
[[Category:Programming]]</div>Androbhttps://wiki.alpinelinux.org/w/index.php?title=KVM&diff=21733KVM2022-04-18T16:13:50Z<p>Androb: /* Networking */</p>
<hr />
<div>[https://www.linux-kvm.org/page/Main_Page KVM] is an free and open source virtualization solution in a kernel module. Although it is often simply referred to as KVM, the actual hypervisor is [https://www.qemu.org QEMU]. QEMU runs from user-space, but can integrate with KVM, providing better performance by leveraging the hardware from kernel-space. QEMU can virtualize x86, PowerPC, and S390 guests, amongst others. [https://libvirt.org Libvirt] is a management framework that integrates with QEMU/KVM, [https://wiki.alpinelinux.org/wiki/LXC LXC], [https://wiki.alpinelinux.org/wiki/Xen_Dom0 Xen] and others.<br />
<br />
== Installation ==<br />
The following commands provide '''libvirt''' as well as '''QEMU with emulation for x86_64''' and '''qemu-img''', a necessary component for using various disk formats such as qcow2. Without qemu-img, only raw disks are available. It can also convert images between several formats like vhdx and vmdk. It also provides the metapackage '''qemu-modules''', which provides subpackages needed for special features. In versions of Alpine before 3.13.0 these features were covered by '''QEMU with emulation for x86_64'''.<br />
{{Cmd|<nowiki># apk add libvirt-daemon qemu-img qemu-system-x86_64 qemu-modules openrc<br />
# rc-update add libvirtd</nowiki>}}<br />
<br />
== Networking ==<br />
By default, libvirt uses NAT for VM connectivity. If you want to use the default configuration, you need to load the tun module.<br />
{{Cmd|# modprobe tun}}<br />
{{Cmd|add tun to autostart: # echo "tun" >> /etc/modules-load.d/tun.conf}}<br />
<br />
To make the tun module load on boot, use this command:<br />
{{Cmd|# cat /etc/modules {{!}} grep tun {{!}}{{!}} echo tun >> /etc/modules}}<br />
<br />
If you prefer bridging a guest over your Ethernet interface, you need to make a [https://wiki.alpinelinux.org/wiki/Bridge#Configuration_file bridge].<br />
<br />
It's quite common to use bridges with KVM environments. But when IPv6 is used, Alpine will assign itself a link-local address as well as an SLAAC address in case there's a router sending Router Advertisements. You don't want this because you don't want to have the KVM host an IP address in every network it serves to guests. Unfortunately IPv6 can not just be disabled for the bridge via a sysctl configuration file, because the bridge might not be up when the sysctl config is applied during boot. What works is to put a post-up hook into the /etc/network/interfaces file like this:<br />
auto brlan<br />
iface brlan inet manual<br />
bridge-ports eth1.5<br />
bridge-stp 0<br />
post-up ip -6 a flush dev brlan; sysctl -w net.ipv6.conf.brlan.disable_ipv6=1<br />
<br />
== Management ==<br />
For non-root management, you will need to add your user to the libvirt group.<br />
{{Cmd|# addgroup user libvirt}}<br />
<br />
You can use libvirt's virsh at the CLI. It can execute commands as well as run as an interactive shell. Read its manual page and/or use the "help" command for more info. Some basic commands are:<br />
<br />
{{Cmd|<nowiki>virsh help<br />
virsh list --all<br />
virsh start $domain<br />
virsh shutdown $domain</nowiki><br />
}}<br />
<br />
The libvirt project provides a GUI for managing hosts, called virt-manager. It handles local systems as well as remote ones via SSH.<br />
{{Cmd|<nowiki># apk add dbus polkit virt-manager terminus-font<br />
# rc-update add dbus</nowiki>}}<br />
<br />
In order to use libvirtd to remotely control KVM over ssh PolicyKit needs a .pkla informing it that this is allowed.<br />
Write the following file to /etc/polkit-1/localauthority/50-local.d/50-libvirt-ssh-remote-access-policy.pkla<br />
{{Cmd|<nowiki>[Remote libvirt SSH access]<br />
Identity=unix-group:libvirt<br />
Action=org.libvirt.unix.manage<br />
ResultAny=yes<br />
ResultInactive=yes<br />
ResultActive=yes</nowiki><br />
}}<br />
<br />
== Guest lifecycle management ==<br />
The libvirt-guests service (available from Alpine 3.13.5) allows running guests to be automatically suspended or shut down when the host is shut down or rebooted.<br />
<br />
The service is configured in /etc/conf.d/libvirt-guests. Enable the service with {{Cmd|# rc-update add libvirt-guests}}<br />
<br />
== vfio ==<br />
<br />
VFIO is more flexible way to do PCI passthrough. Let's suppose you want to use following ethernet card as PCI device in a VM.<br />
<br />
# lspci | grep 02:00.0<br />
02:00.0 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01)<br />
# lspci -n -s 02:00.0<br />
02:00.0 0200: 8086:10c9 (rev 01)<br />
<br />
First, create ''/etc/mkinitfs/features.d/vfio.modules'' with the following content, so mkinitfs includes the VFIO modules in the initramfs.<br />
<br />
kernel/drivers/vfio/vfio.ko.*<br />
kernel/drivers/vfio/vfio_virqfd.ko.*<br />
kernel/drivers/vfio/vfio_iommu_type1.ko.*<br />
kernel/drivers/vfio/pci/vfio-pci.ko.*<br />
<br />
Add ''vfio'' the the list of features in ''/etc/mkinitfs/mkinitfs.conf''.<br />
<br />
Modify following file to instruct ''mkinitfs'' to load following module with the options and rebuild kernel ramdisk.<br />
<br />
# cat /etc/modprobe.d/vfio.conf <<EOF<br />
options vfio-pci ids=8086:10c9<br />
options vfio_iommu_type1 allow_unsafe_interrupts=1<br />
softdep igb pre: vfio-pci<br />
EOF<br />
# mkinitfs<br />
<br />
Now we need to edit the "default_kernel_opts" and "modules" sections in the update-extlinux.conf file. Edit the "default_kernel_opts" to include ''intel_iommu=o iommu=pt'' for Intel platform (AMD uses ''amd_iommu=on''), and add the VFIO modules to the "modules" section.<br />
<br />
# grep '^default_kernel_opts\|^modules' /etc/update-extlinux.conf<br />
default_kernel_opts="quiet rootfstype=ext4 intel_iommu=on iommu=pt"<br />
modules=sd-mod,usb-storage,ext4,raid1,vfio,vfio-pci,vfio_iommu_type1,vfio_virqfd<br />
<br />
For syslinux/extlinux, run:<br />
<br />
# update-extlinux<br />
<br />
For GRUB (which [https://git.alpinelinux.org/aports/tree/main/grub/alpine-mkconfig.patch#n9 now also uses] the update-extlinux.conf if present), run:<br />
<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
Reboot and check dmesg.<br />
<br />
# grep -i -e DMAR -e IOMMU /var/log/dmesg<br />
[ 0.343795] DMAR: Host address width 36<br />
[ 0.343797] DMAR: DRHD base: 0x000000fed90000 flags: 0x1<br />
[ 0.343804] DMAR: dmar0: reg_base_addr fed90000 ver 1:0 cap c90780106f0462 ecap f020e3<br />
[ 0.343806] DMAR: RMRR base: 0x000000000ed000 end: 0x000000000effff<br />
[ 0.343807] DMAR: RMRR base: 0x000000bf7ed000 end: 0x000000bf7fffff<br />
[ 0.553830] iommu: Default domain type: Passthrough (set via kernel command line)<br />
[ 0.902477] DMAR: No ATSR found<br />
[ 0.902563] DMAR: dmar0: Using Queued invalidation<br />
...<br />
[ 0.903256] pci 0000:02:00.0: Adding to iommu group 12<br />
...<br />
[ 0.903768] DMAR: Intel(R) Virtualization Technology for Directed I/O<br />
<br />
If you do not run libvirt VMs under ''root'' (''egrep '^#*user' /etc/libvirt/qemu.conf''), then you must have correct permission on ''/dev/vfio/<iommu_group>'', eg. ''/dev/vfio/12''. You have to tune ''/etc/mdev.conf'' or UDEV rules. Also note that if there are multiple PCI devices in the same iommu group, you always have to add all of them to the VM otherwise you'll get an error message like "Please ensure all devices within the iommu_group are bound to their vfio bus driver"<br />
<br />
# virsh dumpxml vm01 | xmllint --xpath '//*/hostdev' -<br />
<hostdev mode="subsystem" type="pci" managed="yes"><br />
<driver name="vfio"/><br />
<source><br />
<address domain="0x0000" bus="0x02" slot="0x00" function="0x0"/><br />
</source><br />
<alias name="hostdev0"/><br />
<address type="pci" domain="0x0000" bus="0x00" slot="0x06" function="0x0"/><br />
</hostdev><br />
<hostdev mode="subsystem" type="pci" managed="yes"><br />
<driver name="vfio"/><br />
<source><br />
<address domain="0x0000" bus="0x02" slot="0x00" function="0x1"/><br />
</source><br />
<alias name="hostdev1"/><br />
<address type="pci" domain="0x0000" bus="0x00" slot="0x08" function="0x0"/><br />
</hostdev><br />
<br />
If you directly use QEMU without libvirt and are trying to pass a GPU to your VM, you may get a "VFIO_MAP_DMA failed: Out of memory" error, when starting the VM as a non-root user. One way to fix it is to install the ''shadow'' package, and increase the amount of memory the user can lock via the ''/etc/security/limits.conf'' file:<br />
{{Cmd|<nowiki># apk add shadow<br />
# echo "youruser soft memlock RAMamount \<br />
youruser hard memlock RAMamount" >> /etc/security/limits.conf<br />
# reboot</nowiki>}}<br />
<br />
Replace "youruser" with the user you wish to run the VM as, and "RAMamount" with how much RAM your VM will need (in KB). The exact amount may throw the same error in the end, so you probably want to increase this value by a few dozen MB (typically +40).<br />
<br />
A lot of info at [https://wiki.archlinux.org/index.php/PCI_passthrough_via_OVMF].<br />
<br />
[[Category:Virtualization]]</div>Androbhttps://wiki.alpinelinux.org/w/index.php?title=KVM&diff=21732KVM2022-04-18T16:12:46Z<p>Androb: /* Networking */</p>
<hr />
<div>[https://www.linux-kvm.org/page/Main_Page KVM] is an free and open source virtualization solution in a kernel module. Although it is often simply referred to as KVM, the actual hypervisor is [https://www.qemu.org QEMU]. QEMU runs from user-space, but can integrate with KVM, providing better performance by leveraging the hardware from kernel-space. QEMU can virtualize x86, PowerPC, and S390 guests, amongst others. [https://libvirt.org Libvirt] is a management framework that integrates with QEMU/KVM, [https://wiki.alpinelinux.org/wiki/LXC LXC], [https://wiki.alpinelinux.org/wiki/Xen_Dom0 Xen] and others.<br />
<br />
== Installation ==<br />
The following commands provide '''libvirt''' as well as '''QEMU with emulation for x86_64''' and '''qemu-img''', a necessary component for using various disk formats such as qcow2. Without qemu-img, only raw disks are available. It can also convert images between several formats like vhdx and vmdk. It also provides the metapackage '''qemu-modules''', which provides subpackages needed for special features. In versions of Alpine before 3.13.0 these features were covered by '''QEMU with emulation for x86_64'''.<br />
{{Cmd|<nowiki># apk add libvirt-daemon qemu-img qemu-system-x86_64 qemu-modules openrc<br />
# rc-update add libvirtd</nowiki>}}<br />
<br />
== Networking ==<br />
By default, libvirt uses NAT for VM connectivity. If you want to use the default configuration, you need to load the tun module.<br />
{{Cmd|# modprobe tun}}<br />
{{Cmd|# add tun to autostart: echo "tun" >> /etc/modules-load.d/tun.conf}}<br />
<br />
To make the tun module load on boot, use this command:<br />
{{Cmd|# cat /etc/modules {{!}} grep tun {{!}}{{!}} echo tun >> /etc/modules}}<br />
<br />
If you prefer bridging a guest over your Ethernet interface, you need to make a [https://wiki.alpinelinux.org/wiki/Bridge#Configuration_file bridge].<br />
<br />
It's quite common to use bridges with KVM environments. But when IPv6 is used, Alpine will assign itself a link-local address as well as an SLAAC address in case there's a router sending Router Advertisements. You don't want this because you don't want to have the KVM host an IP address in every network it serves to guests. Unfortunately IPv6 can not just be disabled for the bridge via a sysctl configuration file, because the bridge might not be up when the sysctl config is applied during boot. What works is to put a post-up hook into the /etc/network/interfaces file like this:<br />
auto brlan<br />
iface brlan inet manual<br />
bridge-ports eth1.5<br />
bridge-stp 0<br />
post-up ip -6 a flush dev brlan; sysctl -w net.ipv6.conf.brlan.disable_ipv6=1<br />
<br />
== Management ==<br />
For non-root management, you will need to add your user to the libvirt group.<br />
{{Cmd|# addgroup user libvirt}}<br />
<br />
You can use libvirt's virsh at the CLI. It can execute commands as well as run as an interactive shell. Read its manual page and/or use the "help" command for more info. Some basic commands are:<br />
<br />
{{Cmd|<nowiki>virsh help<br />
virsh list --all<br />
virsh start $domain<br />
virsh shutdown $domain</nowiki><br />
}}<br />
<br />
The libvirt project provides a GUI for managing hosts, called virt-manager. It handles local systems as well as remote ones via SSH.<br />
{{Cmd|<nowiki># apk add dbus polkit virt-manager terminus-font<br />
# rc-update add dbus</nowiki>}}<br />
<br />
In order to use libvirtd to remotely control KVM over ssh PolicyKit needs a .pkla informing it that this is allowed.<br />
Write the following file to /etc/polkit-1/localauthority/50-local.d/50-libvirt-ssh-remote-access-policy.pkla<br />
{{Cmd|<nowiki>[Remote libvirt SSH access]<br />
Identity=unix-group:libvirt<br />
Action=org.libvirt.unix.manage<br />
ResultAny=yes<br />
ResultInactive=yes<br />
ResultActive=yes</nowiki><br />
}}<br />
<br />
== Guest lifecycle management ==<br />
The libvirt-guests service (available from Alpine 3.13.5) allows running guests to be automatically suspended or shut down when the host is shut down or rebooted.<br />
<br />
The service is configured in /etc/conf.d/libvirt-guests. Enable the service with {{Cmd|# rc-update add libvirt-guests}}<br />
<br />
== vfio ==<br />
<br />
VFIO is more flexible way to do PCI passthrough. Let's suppose you want to use following ethernet card as PCI device in a VM.<br />
<br />
# lspci | grep 02:00.0<br />
02:00.0 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01)<br />
# lspci -n -s 02:00.0<br />
02:00.0 0200: 8086:10c9 (rev 01)<br />
<br />
First, create ''/etc/mkinitfs/features.d/vfio.modules'' with the following content, so mkinitfs includes the VFIO modules in the initramfs.<br />
<br />
kernel/drivers/vfio/vfio.ko.*<br />
kernel/drivers/vfio/vfio_virqfd.ko.*<br />
kernel/drivers/vfio/vfio_iommu_type1.ko.*<br />
kernel/drivers/vfio/pci/vfio-pci.ko.*<br />
<br />
Add ''vfio'' the the list of features in ''/etc/mkinitfs/mkinitfs.conf''.<br />
<br />
Modify following file to instruct ''mkinitfs'' to load following module with the options and rebuild kernel ramdisk.<br />
<br />
# cat /etc/modprobe.d/vfio.conf <<EOF<br />
options vfio-pci ids=8086:10c9<br />
options vfio_iommu_type1 allow_unsafe_interrupts=1<br />
softdep igb pre: vfio-pci<br />
EOF<br />
# mkinitfs<br />
<br />
Now we need to edit the "default_kernel_opts" and "modules" sections in the update-extlinux.conf file. Edit the "default_kernel_opts" to include ''intel_iommu=o iommu=pt'' for Intel platform (AMD uses ''amd_iommu=on''), and add the VFIO modules to the "modules" section.<br />
<br />
# grep '^default_kernel_opts\|^modules' /etc/update-extlinux.conf<br />
default_kernel_opts="quiet rootfstype=ext4 intel_iommu=on iommu=pt"<br />
modules=sd-mod,usb-storage,ext4,raid1,vfio,vfio-pci,vfio_iommu_type1,vfio_virqfd<br />
<br />
For syslinux/extlinux, run:<br />
<br />
# update-extlinux<br />
<br />
For GRUB (which [https://git.alpinelinux.org/aports/tree/main/grub/alpine-mkconfig.patch#n9 now also uses] the update-extlinux.conf if present), run:<br />
<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
Reboot and check dmesg.<br />
<br />
# grep -i -e DMAR -e IOMMU /var/log/dmesg<br />
[ 0.343795] DMAR: Host address width 36<br />
[ 0.343797] DMAR: DRHD base: 0x000000fed90000 flags: 0x1<br />
[ 0.343804] DMAR: dmar0: reg_base_addr fed90000 ver 1:0 cap c90780106f0462 ecap f020e3<br />
[ 0.343806] DMAR: RMRR base: 0x000000000ed000 end: 0x000000000effff<br />
[ 0.343807] DMAR: RMRR base: 0x000000bf7ed000 end: 0x000000bf7fffff<br />
[ 0.553830] iommu: Default domain type: Passthrough (set via kernel command line)<br />
[ 0.902477] DMAR: No ATSR found<br />
[ 0.902563] DMAR: dmar0: Using Queued invalidation<br />
...<br />
[ 0.903256] pci 0000:02:00.0: Adding to iommu group 12<br />
...<br />
[ 0.903768] DMAR: Intel(R) Virtualization Technology for Directed I/O<br />
<br />
If you do not run libvirt VMs under ''root'' (''egrep '^#*user' /etc/libvirt/qemu.conf''), then you must have correct permission on ''/dev/vfio/<iommu_group>'', eg. ''/dev/vfio/12''. You have to tune ''/etc/mdev.conf'' or UDEV rules. Also note that if there are multiple PCI devices in the same iommu group, you always have to add all of them to the VM otherwise you'll get an error message like "Please ensure all devices within the iommu_group are bound to their vfio bus driver"<br />
<br />
# virsh dumpxml vm01 | xmllint --xpath '//*/hostdev' -<br />
<hostdev mode="subsystem" type="pci" managed="yes"><br />
<driver name="vfio"/><br />
<source><br />
<address domain="0x0000" bus="0x02" slot="0x00" function="0x0"/><br />
</source><br />
<alias name="hostdev0"/><br />
<address type="pci" domain="0x0000" bus="0x00" slot="0x06" function="0x0"/><br />
</hostdev><br />
<hostdev mode="subsystem" type="pci" managed="yes"><br />
<driver name="vfio"/><br />
<source><br />
<address domain="0x0000" bus="0x02" slot="0x00" function="0x1"/><br />
</source><br />
<alias name="hostdev1"/><br />
<address type="pci" domain="0x0000" bus="0x00" slot="0x08" function="0x0"/><br />
</hostdev><br />
<br />
If you directly use QEMU without libvirt and are trying to pass a GPU to your VM, you may get a "VFIO_MAP_DMA failed: Out of memory" error, when starting the VM as a non-root user. One way to fix it is to install the ''shadow'' package, and increase the amount of memory the user can lock via the ''/etc/security/limits.conf'' file:<br />
{{Cmd|<nowiki># apk add shadow<br />
# echo "youruser soft memlock RAMamount \<br />
youruser hard memlock RAMamount" >> /etc/security/limits.conf<br />
# reboot</nowiki>}}<br />
<br />
Replace "youruser" with the user you wish to run the VM as, and "RAMamount" with how much RAM your VM will need (in KB). The exact amount may throw the same error in the end, so you probably want to increase this value by a few dozen MB (typically +40).<br />
<br />
A lot of info at [https://wiki.archlinux.org/index.php/PCI_passthrough_via_OVMF].<br />
<br />
[[Category:Virtualization]]</div>Androbhttps://wiki.alpinelinux.org/w/index.php?title=KVM&diff=21731KVM2022-04-18T16:12:03Z<p>Androb: /* Networking */</p>
<hr />
<div>[https://www.linux-kvm.org/page/Main_Page KVM] is an free and open source virtualization solution in a kernel module. Although it is often simply referred to as KVM, the actual hypervisor is [https://www.qemu.org QEMU]. QEMU runs from user-space, but can integrate with KVM, providing better performance by leveraging the hardware from kernel-space. QEMU can virtualize x86, PowerPC, and S390 guests, amongst others. [https://libvirt.org Libvirt] is a management framework that integrates with QEMU/KVM, [https://wiki.alpinelinux.org/wiki/LXC LXC], [https://wiki.alpinelinux.org/wiki/Xen_Dom0 Xen] and others.<br />
<br />
== Installation ==<br />
The following commands provide '''libvirt''' as well as '''QEMU with emulation for x86_64''' and '''qemu-img''', a necessary component for using various disk formats such as qcow2. Without qemu-img, only raw disks are available. It can also convert images between several formats like vhdx and vmdk. It also provides the metapackage '''qemu-modules''', which provides subpackages needed for special features. In versions of Alpine before 3.13.0 these features were covered by '''QEMU with emulation for x86_64'''.<br />
{{Cmd|<nowiki># apk add libvirt-daemon qemu-img qemu-system-x86_64 qemu-modules openrc<br />
# rc-update add libvirtd</nowiki>}}<br />
<br />
== Networking ==<br />
By default, libvirt uses NAT for VM connectivity. If you want to use the default configuration, you need to load the tun module.<br />
{{Cmd|# modprobe tun}}<br />
add tun to autostart: echo "tun" >> /etc/modules-load.d/tun.conf<br />
<br />
To make the tun module load on boot, use this command:<br />
{{Cmd|# cat /etc/modules {{!}} grep tun {{!}}{{!}} echo tun >> /etc/modules}}<br />
<br />
If you prefer bridging a guest over your Ethernet interface, you need to make a [https://wiki.alpinelinux.org/wiki/Bridge#Configuration_file bridge].<br />
<br />
It's quite common to use bridges with KVM environments. But when IPv6 is used, Alpine will assign itself a link-local address as well as an SLAAC address in case there's a router sending Router Advertisements. You don't want this because you don't want to have the KVM host an IP address in every network it serves to guests. Unfortunately IPv6 can not just be disabled for the bridge via a sysctl configuration file, because the bridge might not be up when the sysctl config is applied during boot. What works is to put a post-up hook into the /etc/network/interfaces file like this:<br />
auto brlan<br />
iface brlan inet manual<br />
bridge-ports eth1.5<br />
bridge-stp 0<br />
post-up ip -6 a flush dev brlan; sysctl -w net.ipv6.conf.brlan.disable_ipv6=1<br />
<br />
== Management ==<br />
For non-root management, you will need to add your user to the libvirt group.<br />
{{Cmd|# addgroup user libvirt}}<br />
<br />
You can use libvirt's virsh at the CLI. It can execute commands as well as run as an interactive shell. Read its manual page and/or use the "help" command for more info. Some basic commands are:<br />
<br />
{{Cmd|<nowiki>virsh help<br />
virsh list --all<br />
virsh start $domain<br />
virsh shutdown $domain</nowiki><br />
}}<br />
<br />
The libvirt project provides a GUI for managing hosts, called virt-manager. It handles local systems as well as remote ones via SSH.<br />
{{Cmd|<nowiki># apk add dbus polkit virt-manager terminus-font<br />
# rc-update add dbus</nowiki>}}<br />
<br />
In order to use libvirtd to remotely control KVM over ssh PolicyKit needs a .pkla informing it that this is allowed.<br />
Write the following file to /etc/polkit-1/localauthority/50-local.d/50-libvirt-ssh-remote-access-policy.pkla<br />
{{Cmd|<nowiki>[Remote libvirt SSH access]<br />
Identity=unix-group:libvirt<br />
Action=org.libvirt.unix.manage<br />
ResultAny=yes<br />
ResultInactive=yes<br />
ResultActive=yes</nowiki><br />
}}<br />
<br />
== Guest lifecycle management ==<br />
The libvirt-guests service (available from Alpine 3.13.5) allows running guests to be automatically suspended or shut down when the host is shut down or rebooted.<br />
<br />
The service is configured in /etc/conf.d/libvirt-guests. Enable the service with {{Cmd|# rc-update add libvirt-guests}}<br />
<br />
== vfio ==<br />
<br />
VFIO is more flexible way to do PCI passthrough. Let's suppose you want to use following ethernet card as PCI device in a VM.<br />
<br />
# lspci | grep 02:00.0<br />
02:00.0 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01)<br />
# lspci -n -s 02:00.0<br />
02:00.0 0200: 8086:10c9 (rev 01)<br />
<br />
First, create ''/etc/mkinitfs/features.d/vfio.modules'' with the following content, so mkinitfs includes the VFIO modules in the initramfs.<br />
<br />
kernel/drivers/vfio/vfio.ko.*<br />
kernel/drivers/vfio/vfio_virqfd.ko.*<br />
kernel/drivers/vfio/vfio_iommu_type1.ko.*<br />
kernel/drivers/vfio/pci/vfio-pci.ko.*<br />
<br />
Add ''vfio'' the the list of features in ''/etc/mkinitfs/mkinitfs.conf''.<br />
<br />
Modify following file to instruct ''mkinitfs'' to load following module with the options and rebuild kernel ramdisk.<br />
<br />
# cat /etc/modprobe.d/vfio.conf <<EOF<br />
options vfio-pci ids=8086:10c9<br />
options vfio_iommu_type1 allow_unsafe_interrupts=1<br />
softdep igb pre: vfio-pci<br />
EOF<br />
# mkinitfs<br />
<br />
Now we need to edit the "default_kernel_opts" and "modules" sections in the update-extlinux.conf file. Edit the "default_kernel_opts" to include ''intel_iommu=o iommu=pt'' for Intel platform (AMD uses ''amd_iommu=on''), and add the VFIO modules to the "modules" section.<br />
<br />
# grep '^default_kernel_opts\|^modules' /etc/update-extlinux.conf<br />
default_kernel_opts="quiet rootfstype=ext4 intel_iommu=on iommu=pt"<br />
modules=sd-mod,usb-storage,ext4,raid1,vfio,vfio-pci,vfio_iommu_type1,vfio_virqfd<br />
<br />
For syslinux/extlinux, run:<br />
<br />
# update-extlinux<br />
<br />
For GRUB (which [https://git.alpinelinux.org/aports/tree/main/grub/alpine-mkconfig.patch#n9 now also uses] the update-extlinux.conf if present), run:<br />
<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
Reboot and check dmesg.<br />
<br />
# grep -i -e DMAR -e IOMMU /var/log/dmesg<br />
[ 0.343795] DMAR: Host address width 36<br />
[ 0.343797] DMAR: DRHD base: 0x000000fed90000 flags: 0x1<br />
[ 0.343804] DMAR: dmar0: reg_base_addr fed90000 ver 1:0 cap c90780106f0462 ecap f020e3<br />
[ 0.343806] DMAR: RMRR base: 0x000000000ed000 end: 0x000000000effff<br />
[ 0.343807] DMAR: RMRR base: 0x000000bf7ed000 end: 0x000000bf7fffff<br />
[ 0.553830] iommu: Default domain type: Passthrough (set via kernel command line)<br />
[ 0.902477] DMAR: No ATSR found<br />
[ 0.902563] DMAR: dmar0: Using Queued invalidation<br />
...<br />
[ 0.903256] pci 0000:02:00.0: Adding to iommu group 12<br />
...<br />
[ 0.903768] DMAR: Intel(R) Virtualization Technology for Directed I/O<br />
<br />
If you do not run libvirt VMs under ''root'' (''egrep '^#*user' /etc/libvirt/qemu.conf''), then you must have correct permission on ''/dev/vfio/<iommu_group>'', eg. ''/dev/vfio/12''. You have to tune ''/etc/mdev.conf'' or UDEV rules. Also note that if there are multiple PCI devices in the same iommu group, you always have to add all of them to the VM otherwise you'll get an error message like "Please ensure all devices within the iommu_group are bound to their vfio bus driver"<br />
<br />
# virsh dumpxml vm01 | xmllint --xpath '//*/hostdev' -<br />
<hostdev mode="subsystem" type="pci" managed="yes"><br />
<driver name="vfio"/><br />
<source><br />
<address domain="0x0000" bus="0x02" slot="0x00" function="0x0"/><br />
</source><br />
<alias name="hostdev0"/><br />
<address type="pci" domain="0x0000" bus="0x00" slot="0x06" function="0x0"/><br />
</hostdev><br />
<hostdev mode="subsystem" type="pci" managed="yes"><br />
<driver name="vfio"/><br />
<source><br />
<address domain="0x0000" bus="0x02" slot="0x00" function="0x1"/><br />
</source><br />
<alias name="hostdev1"/><br />
<address type="pci" domain="0x0000" bus="0x00" slot="0x08" function="0x0"/><br />
</hostdev><br />
<br />
If you directly use QEMU without libvirt and are trying to pass a GPU to your VM, you may get a "VFIO_MAP_DMA failed: Out of memory" error, when starting the VM as a non-root user. One way to fix it is to install the ''shadow'' package, and increase the amount of memory the user can lock via the ''/etc/security/limits.conf'' file:<br />
{{Cmd|<nowiki># apk add shadow<br />
# echo "youruser soft memlock RAMamount \<br />
youruser hard memlock RAMamount" >> /etc/security/limits.conf<br />
# reboot</nowiki>}}<br />
<br />
Replace "youruser" with the user you wish to run the VM as, and "RAMamount" with how much RAM your VM will need (in KB). The exact amount may throw the same error in the end, so you probably want to increase this value by a few dozen MB (typically +40).<br />
<br />
A lot of info at [https://wiki.archlinux.org/index.php/PCI_passthrough_via_OVMF].<br />
<br />
[[Category:Virtualization]]</div>Androbhttps://wiki.alpinelinux.org/w/index.php?title=Bonding&diff=20378Bonding2021-11-25T10:13:02Z<p>Androb: /* Configuration */</p>
<hr />
<div>This article shows how to bond (or aggregate) multiple ethernet interfaces into a bond0 interface.<br />
{{Note| Alpine Linux v2.4 or later is required}}<br />
==Installation==<br />
First, install the ''bonding'' package. This will give you support for bonding in the ''/etc/network/interfaces'' file.<br />
{{Cmd|apk add bonding}}<br />
<br />
==Configuration==<br />
Edit the ''/etc/network/interfaces'' file:<br />
<pre><br />
auto bond0<br />
iface bond0 inet static<br />
address 192.168.0.2<br />
netmask 255.255.255.0<br />
gateway 192.168.0.1<br />
# specify the ethernet interfaces that should be bonded<br />
bond-slaves eth0 eth1 eth2 eth3<br />
</pre><br />
<br />
The keyword is ''bond-slaves'' that will make ifup add the slaves to the bond0 interface.<br />
<br />
References: http://www.kernel.org/doc/Documentation/networking/bonding.txt<br />
<br />
[[Category:Networking]]<br />
<br />
<br />
<br />
Bonding with br0 (LACP)<br />
<pre><br />
<br />
auto bond0<br />
iface bond0 inet manual<br />
bond-slaves eth0 eth1<br />
bond-mode 802.3ad<br />
bond-xmit-hash-policy layer2+3<br />
<br />
auto br0<br />
iface br0 inet dhcp<br />
bridge-ports bond0<br />
bridge-stp 0<br />
hostname alpine<br />
<pre></div>Androbhttps://wiki.alpinelinux.org/w/index.php?title=Bonding&diff=20377Bonding2021-11-25T10:11:34Z<p>Androb: /* Configuration */</p>
<hr />
<div>This article shows how to bond (or aggregate) multiple ethernet interfaces into a bond0 interface.<br />
{{Note| Alpine Linux v2.4 or later is required}}<br />
==Installation==<br />
First, install the ''bonding'' package. This will give you support for bonding in the ''/etc/network/interfaces'' file.<br />
{{Cmd|apk add bonding}}<br />
<br />
==Configuration==<br />
Edit the ''/etc/network/interfaces'' file:<br />
<pre><br />
auto bond0<br />
iface bond0 inet static<br />
address 192.168.0.2<br />
netmask 255.255.255.0<br />
gateway 192.168.0.1<br />
# specify the ethernet interfaces that should be bonded<br />
bond-slaves eth0 eth1 eth2 eth3<br />
</pre><br />
<br />
The keyword is ''bond-slaves'' that will make ifup add the slaves to the bond0 interface.<br />
<br />
References: http://www.kernel.org/doc/Documentation/networking/bonding.txt<br />
<br />
[[Category:Networking]]<br />
<br />
<br />
<br />
Bonding with br0 (LACP)<br />
<pre><br />
<br />
auto bond0<br />
iface bond0 inet manual<br />
bond-slaves eth0 eth1<br />
bond-mode 802.3ad<br />
bond-xmit-hash-policy layer2+3<br />
<br />
auto br0<br />
iface br0 inet dhcp<br />
bridge-ports bond0<br />
bridge-stp 0<br />
<pre></div>Androbhttps://wiki.alpinelinux.org/w/index.php?title=Bonding&diff=20376Bonding2021-11-25T10:08:09Z<p>Androb: /* Configuration */</p>
<hr />
<div>This article shows how to bond (or aggregate) multiple ethernet interfaces into a bond0 interface.<br />
{{Note| Alpine Linux v2.4 or later is required}}<br />
==Installation==<br />
First, install the ''bonding'' package. This will give you support for bonding in the ''/etc/network/interfaces'' file.<br />
{{Cmd|apk add bonding}}<br />
<br />
==Configuration==<br />
Edit the ''/etc/network/interfaces'' file:<br />
<pre><br />
auto bond0<br />
iface bond0 inet static<br />
address 192.168.0.2<br />
netmask 255.255.255.0<br />
gateway 192.168.0.1<br />
# specify the ethernet interfaces that should be bonded<br />
bond-slaves eth0 eth1 eth2 eth3<br />
</pre><br />
<br />
The keyword is ''bond-slaves'' that will make ifup add the slaves to the bond0 interface.<br />
<br />
References: http://www.kernel.org/doc/Documentation/networking/bonding.txt<br />
<br />
[[Category:Networking]]<br />
<br />
<br />
<br />
Bonding with br0<br />
<pre><br />
<br />
auto bond0<br />
iface bond0 inet manual<br />
bond-slaves eth0 eth1<br />
bond-mode 802.3ad<br />
bond-xmit-hash-policy layer2+3<br />
<br />
auto br0<br />
iface br0 inet dhcp<br />
bridge-ports bond0<br />
bridge-stp 0<br />
<pre></div>Androbhttps://wiki.alpinelinux.org/w/index.php?title=Bonding&diff=20375Bonding2021-11-25T10:07:52Z<p>Androb: /* Configuration */</p>
<hr />
<div>This article shows how to bond (or aggregate) multiple ethernet interfaces into a bond0 interface.<br />
{{Note| Alpine Linux v2.4 or later is required}}<br />
==Installation==<br />
First, install the ''bonding'' package. This will give you support for bonding in the ''/etc/network/interfaces'' file.<br />
{{Cmd|apk add bonding}}<br />
<br />
==Configuration==<br />
Edit the ''/etc/network/interfaces'' file:<br />
<pre><br />
auto bond0<br />
iface bond0 inet static<br />
address 192.168.0.2<br />
netmask 255.255.255.0<br />
gateway 192.168.0.1<br />
# specify the ethernet interfaces that should be bonded<br />
bond-slaves eth0 eth1 eth2 eth3<br />
</pre><br />
<br />
The keyword is ''bond-slaves'' that will make ifup add the slaves to the bond0 interface.<br />
<br />
References: http://www.kernel.org/doc/Documentation/networking/bonding.txt<br />
<br />
[[Category:Networking]]<br />
<br />
<br />
<br />
Bonding with br0<br />
<pre><br />
<br />
auto bond0<br />
iface bond0 inet manual<br />
bond-slaves eth0 eth1<br />
bond-mode 802.3ad<br />
bond-xmit-hash-policy layer2+3<br />
<br />
auto br0<br />
iface br0 inet dhcp<br />
bridge-ports bond0<br />
bridge-stp 0</div>Androbhttps://wiki.alpinelinux.org/w/index.php?title=Bonding&diff=20374Bonding2021-11-25T10:06:43Z<p>Androb: /* Configuration */</p>
<hr />
<div>This article shows how to bond (or aggregate) multiple ethernet interfaces into a bond0 interface.<br />
{{Note| Alpine Linux v2.4 or later is required}}<br />
==Installation==<br />
First, install the ''bonding'' package. This will give you support for bonding in the ''/etc/network/interfaces'' file.<br />
{{Cmd|apk add bonding}}<br />
<br />
==Configuration==<br />
Edit the ''/etc/network/interfaces'' file:<br />
<pre><br />
auto bond0<br />
iface bond0 inet static<br />
address 192.168.0.2<br />
netmask 255.255.255.0<br />
gateway 192.168.0.1<br />
# specify the ethernet interfaces that should be bonded<br />
bond-slaves eth0 eth1 eth2 eth3<br />
</pre><br />
<br />
The keyword is ''bond-slaves'' that will make ifup add the slaves to the bond0 interface.<br />
<br />
References: http://www.kernel.org/doc/Documentation/networking/bonding.txt<br />
<br />
[[Category:Networking]]<br />
<br />
<br />
<br />
Bonding with br0<br />
<br />
auto bond0<br />
iface bond0 inet manual<br />
bond-slaves eth0 eth1<br />
bond-mode 802.3ad<br />
bond-xmit-hash-policy layer2+3<br />
<br />
auto br0<br />
iface br0 inet dhcp<br />
bridge-ports bond0<br />
bridge-stp 0</div>Androbhttps://wiki.alpinelinux.org/w/index.php?title=Bonding&diff=20373Bonding2021-11-25T10:05:35Z<p>Androb: /* Configuration */</p>
<hr />
<div>This article shows how to bond (or aggregate) multiple ethernet interfaces into a bond0 interface.<br />
{{Note| Alpine Linux v2.4 or later is required}}<br />
==Installation==<br />
First, install the ''bonding'' package. This will give you support for bonding in the ''/etc/network/interfaces'' file.<br />
{{Cmd|apk add bonding}}<br />
<br />
==Configuration==<br />
Edit the ''/etc/network/interfaces'' file:<br />
<pre><br />
auto bond0<br />
iface bond0 inet static<br />
address 192.168.0.2<br />
netmask 255.255.255.0<br />
gateway 192.168.0.1<br />
# specify the ethernet interfaces that should be bonded<br />
bond-slaves eth0 eth1 eth2 eth3<br />
</pre><br />
<br />
The keyword is ''bond-slaves'' that will make ifup add the slaves to the bond0 interface.<br />
<br />
References: http://www.kernel.org/doc/Documentation/networking/bonding.txt<br />
<br />
[[Category:Networking]]<br />
<br />
Bonding with br0<br />
<br />
auto bond0<br />
iface bond0 inet manual<br />
bond-slaves eth0 eth1<br />
bond-mode 802.3ad<br />
bond-xmit-hash-policy layer2+3<br />
<br />
auto br0<br />
iface br0 inet dhcp<br />
bridge-ports bond0<br />
bridge-stp 0</div>Androb