Ubuntu 16.04 LTS无头VPS部署KVM遇libvirt-sock不存在问题求助
Hey Joe, let's work through this missing libvirt-sock issue step by step. Since you've already confirmed VMX support is enabled, that's a solid starting point—let's focus on libvirt's service status and configuration first.
libvirt-sock on Ubuntu 16.04 LTS KVM Setup 1. Check if the Libvirt Daemon is Running
The libvirt-sock file is created automatically when the libvirtd daemon starts. Let's first verify if the service is active:
sudo systemctl status libvirtd
- If it's inactive, start it immediately:
sudo systemctl start libvirtd - Enable it to launch on system boot (so you don't hit this issue again):
sudo systemctl enable libvirtd
If the service fails to start, pull the logs to find error details:
sudo journalctl -u libvirtd
Look for lines like "Failed to start" or configuration-related warnings—these will tell us exactly why the daemon isn't initializing properly.
2. Verify Libvirt Socket Configuration
By default, libvirt-sock lives at /var/run/libvirt/libvirt-sock. Let's check the main libvirt config to ensure socket creation is enabled:
Open the config file with your preferred editor:
sudo nano /etc/libvirt/libvirtd.conf
Look for these lines and make sure they're uncommented (remove the # if present):
unix_sock_group = "libvirt" unix_sock_ro_perms = "0777" unix_sock_rw_perms = "0770" unix_sock_dir = "/var/run/libvirt"
If you make any changes, restart the daemon to apply them:
sudo systemctl restart libvirtd
Then check if the socket exists:
ls -l /var/run/libvirt/libvirt-sock
3. Confirm User Group Permissions
Even if the socket is created, your user might not have access to it. Ensure you're part of the libvirt group:
sudo usermod -aG libvirt $USER
Log out and back in for the group changes to take effect, then try accessing the socket again.
4. Does /etc/network/interfaces Matter?
In most cases, this config isn't directly linked to the missing socket—unless you set up a bridged network for KVM and made a syntax error there. If you modified this file for bridging, check for issues:
sudo ifup --verbose <your-bridge-name>
Or verify the bridge exists:
brctl show
A misconfigured bridge can prevent libvirtd from starting up correctly. Fix any network errors and restart the daemon if needed.
5. Reinstall Libvirt Packages (Last Resort)
If all else fails, corrupted package files might be the culprit. Reinstall the core libvirt packages:
sudo apt-get purge libvirt-bin libvirt-daemon sudo apt-get install libvirt-bin libvirt-daemon sudo systemctl start libvirtd
Let me know what the service status and log outputs show—we can narrow down the issue further from there!
内容的提问来源于stack exchange,提问作者Maxim

