问题
When starting my vagrant box with a small 15MB Busybox image, the first time I get an error during the phase
Mounting shared folders...
It seems vagrant is trying something with sudo, which isn't istalled. I get this error:
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
mkdir -p /vagrant
Stdout from the command:
Stderr from the command:
ash: sudo: not found
It works so far, I can login as root with the password vagrant, but I guess this is not perfect?
This is my setup: https://github.com/rubo77/ffnord-example/blob/pyddhcpd/Vagrantfile
config.ssh.username = 'root'
config.ssh.password = 'vagrant'
config.ssh.insert_key = 'true'
config.ssh.shell = 'ash'
(0..9).each do |i|
config.vm.define "gc-node0#{i}" do |node|
end
end
回答1:
By default vagrant share/sync the directory /vagrant
(guest) with the current project directory, the one containing the Vagrantfile
(host), more directories can be shared using config.vm.synced_folder
, I don't know if the default /vagrant
can be disabled.
If you aren't using the shared directories feature then the missing sudo
isn't a problem.
If your filesystem is writeable you can create the /vagrant
directory once, so on next up
vagrant shouldn't try to sudo mkdir
again;
but assuming you're using VirtualBox (I don't know about others emulator behavior/architecture) you'll face another problem, shared directories require the kernel modules vboxsf
and vboxguest
(from VirtualBox Guest Additions) to be built (against the running kernel sources) and loaded (insmod), and the command mount.vboxsf
to be built and installed in /sbin
, plus your busybox require the option mount helpers enabled because vagrant use mount -t vboxsf
and not mount.vboxsf
directly, when vagrant try to mount the shared directories and those requirements aren't matched there is a long timeout before failing with error (a minute/two or more).
Notice that busybox (current stable) support sudo
, is just disabled by default.
If you're building the buildroot yourself from sources I can tell that the shared feature works (I managed to get an image with busybox to work as vagrant expect), if you're using some pre-built kernel/busybox... may be a problem, you have to find matching binaries for vboxsf
, vboxguest
, mount.vboxsf
and if the mount helpers option is disabled in your busybox you need to find a workaround (perhaps modifying vagrant to use mount.vboxsf
).
来源:https://stackoverflow.com/questions/31173472/vagrant-ash-sudo-not-found