added multiple new features and fixing of network issues
This commit is contained in:
parent
6d0309141f
commit
a04c4f552a
@ -1,6 +1,52 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
echo "=== [1/5] Updating system and installing tools ==="
|
||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt -y upgrade
|
sudo apt -y upgrade
|
||||||
sudo apt install -y qemu-guest-agent util-linux haveged
|
sudo apt install -y qemu-guest-agent util-linux haveged ethtool
|
||||||
sudo fstrim -av
|
|
||||||
|
echo "=== [2/5] Enabling qemu-guest-agent ==="
|
||||||
sudo systemctl enable --now qemu-guest-agent
|
sudo systemctl enable --now qemu-guest-agent
|
||||||
|
|
||||||
|
echo "=== [3/5] Trimming filesystems ==="
|
||||||
|
sudo fstrim -av || true
|
||||||
|
|
||||||
|
echo "=== [4/5] Detecting VM network interfaces ==="
|
||||||
|
NIC_LIST=$(ls /sys/class/net | grep -Ev '^(lo|docker|br|vmbr|tap|veth)' | xargs)
|
||||||
|
|
||||||
|
echo "VM NICs detected: $NIC_LIST"
|
||||||
|
|
||||||
|
echo "=== [5/5] Creating persistent systemd service to disable offloads ==="
|
||||||
|
SERVICE_FILE="/etc/systemd/system/disable-vm-nic-offloads.service"
|
||||||
|
|
||||||
|
sudo tee "$SERVICE_FILE" > /dev/null <<EOF
|
||||||
|
[Unit]
|
||||||
|
Description=Disable all VM NIC offloads at boot
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=/bin/bash -c '
|
||||||
|
$(for nic in $NIC_LIST; do
|
||||||
|
echo "/usr/sbin/ethtool -K $nic tx off rx off tso off gso off gro off;"
|
||||||
|
echo "/sbin/ip link set $nic txqueuelen 10000;"
|
||||||
|
done)
|
||||||
|
'
|
||||||
|
RemainAfterExit=yes
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
EOF
|
||||||
|
|
||||||
|
echo "=== Enabling and starting NIC offload disable service ==="
|
||||||
|
sudo systemctl daemon-reload
|
||||||
|
sudo systemctl enable --now disable-vm-nic-offloads.service
|
||||||
|
|
||||||
|
echo "=== ✅ VM NIC setup complete ==="
|
||||||
|
for nic in $NIC_LIST; do
|
||||||
|
echo "--- $nic ---"
|
||||||
|
ethtool -k "$nic" | grep -E 'segmentation|offload|scatter|checksum'
|
||||||
|
ip link show "$nic" | grep txqueuelen
|
||||||
|
done
|
||||||
|
Loading…
x
Reference in New Issue
Block a user