'Vagrant Centos 8 with nfs - System hangs on any sync folder operation
Vagrant 2.2.18
Modules vagrant-timezone (1.3.0, global) vagrant-vbguest (0.30.0, global)
Host Macbook Pro with Montery, but also seen on Windows 11
Issue: When I do a vagrant up, it seems to load fine and gets past the "Mounting NFS shared folders..." output line fine too. At the end of my Vagrantfile is a path to a provision shell script that does a bunch of setup on the Guest. This also starts to run fine without error.
When it gets to a part of that script that simply copies conf files from the share directory to various locations (such as copying an apache conf to /etc/httpd/conf.d/), the whole process stalls. No error, no timeout, I can leave it for hours and it just stops at simple copy commands.
I can vagrant ssh to the VM and it's responsive, but even doing an ls in / hangs too. It also hangs if I try to cd into /vagrant. But I can ls /etc/httpd/conf.d/ (the file copied by my script is not there).
I'm picking this has something to do with the sync setup. But this was all working fine with a previous centos/7 box. But I have also updated Vagrant and guest additions since then. Can anyone see anything obvious in my Vagrantfile? Anything I could try?
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "centos/8"
config.vm.hostname = "mysite.local"
# Mount shared folder using NFS
config.vm.synced_folder ".", "/vagrant",
id: "core",
:nfs => true,
:mount_options => ['rw', 'vers=3', 'tcp', 'fsc', 'actimeo=2']
# The IP address of the VM
config.vm.network "private_network", ip: "192.168.100.130"
# Port forwarding for database. You can now connect to the VM DB using 'localhost' and port 65433
config.vm.network "forwarded_port", guest: 5432, host: 65434
# Assign a quarter of host memory and all available CPU's to VM
# Depending on host OS this has to be done differently.
config.vm.provider :virtualbox do |vb|
host = RbConfig::CONFIG['host_os']
# Mac
if host =~ /darwin/
cpus = `sysctl -n hw.ncpu`.to_i
mem = `sysctl -n hw.memsize`.to_i / 1024 / 1024 / 4
# Nix
elsif host =~ /linux/
cpus = `nproc`.to_i
mem = `grep 'MemTotal' /proc/meminfo | sed -e 's/MemTotal://' -e 's/ kB//'`.to_i / 1024 / 4
# Windows...
else
cpus = 4
mem = 2048
end
vb.customize ["modifyvm", :id, "--memory", mem]
vb.customize ["modifyvm", :id, "--cpus", cpus]
vb.customize ["modifyvm", :id, "--audio", "none"]
vb.customize ["guestproperty", "set", :id, "/VirtualBox/GuestAdd/VBoxService/--timesync-set-threshold", 1000]
end
if Vagrant.has_plugin?("vagrant-vbguest")
config.vbguest.auto_update = false
end
# BOOTSTRAP - The OS/Environment
config.vm.provision :shell, :path => "Vagrant.bootstrap.sh"
end
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
