无法在 Vagrant 中挂载文件
Unable to mount files in Vagrant
错误描述
我无法在 Vagrant 或 Docker 中挂载文件,所以这似乎是由某种权限错误引起的问题。
我的 OS 是 Ubuntu 18.04 LTS (Bionic Beaver)
,据我所知,我没有 运行 任何访问控制模块,例如 SELinux
。
错误的Docker相关讨论在另一个问题中找到:
Unable to mount files in Docker
Vagrant 疑难解答
因此我无法将文件装载到 Vagrant 盒子中(即使我有 vboxsf):
Vagrant was unable to mount VirtualBox shared folders. This is usually
because the filesystem "vboxsf" is not available. This filesystem is
made available via the VirtualBox Guest Additions and kernel module.
Please verify that these guest additions are properly installed in the
guest. This is not a bug in Vagrant and is usually caused by a faulty
Vagrant box. For context, the command attempted was:
mount -t vboxsf -o uid=1000,gid=1000 srv_salt /srv/salt
The error output from the command was:
/sbin/mount.vboxsf: mounting failed with the error: No such device
我在 Vagrantfile 中指定了这些语句,它适用于我同事的本地构建,但在我的构建中,这些文件没有被装载或复制到框中:
host.vm.synced_folder "salt/", "/srv/salt"
host.vm.synced_folder "pillar/", "/srv/pillar"
结论
在复制文件时,我的本地计算机上似乎有些混乱,可能与我的用户的配置方式以及将文件装载到 VM 和容器中所具有的访问权限有关。
如果有人能对此有所了解,我将不胜感激。
更新
1)
正如用户@BMitch 建议的那样,我完成了 "Virtualbox Guest Additions" 安装。
每当我更新我的包时,我都会将其记录到日志文件中,这是大约 2 个月前从 update-20180405_153850.txt
中找到的。
Preparing to unpack .../virtualbox-guest-additions-iso_5.1.34-0ubuntu1.16.04.2_all.deb ...
Unpacking virtualbox-guest-additions-iso (5.1.34-0ubuntu1.16.04.2) over (5.0.40-0ubuntu1.16.04.1) ...
但这对我来说没有意义..我的引导脚本(vagrant up'ing the boxes)在我第一次 运行 时失败了:
Vagrant was unable to mount VirtualBox shared folders. This is usually
because the filesystem "vboxsf" is not available. This filesystem is
made available via the VirtualBox Guest Additions and kernel module.
Please verify that these guest additions are properly installed in the
guest. This is not a bug in Vagrant and is usually caused by a faulty
Vagrant box. For context, the command attempted was:
mount -t vboxsf -o uid=1000,gid=1000 srv_salt /srv/salt
The error output from the command was:
/sbin/mount.vboxsf: mounting failed with the error: No such device
Traceback (most recent call last):
File "launch-vagrant.py", line 166, in <module>
main()
File "launch-vagrant.py", line 120, in main
vagrant()
File "launch-vagrant.py", line 95, in vagrant
main()
File "launch-vagrant.py", line 67, in main
start()
File "launch-vagrant.py", line 83, in start
_exec('vagrant', 'up')
File "launch-vagrant.py", line 129, in _exec
subprocess.check_call(list(args))
File "/usr/lib/python3.6/subprocess.py", line 291, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['vagrant', 'up']' returned non-zero exit status 1.
我第二次 运行 它成功了,但出现以下警告消息:
Copy iso file /usr/share/virtualbox/VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso
Mounting Virtualbox Guest Additions ISO to: /mnt
mount: /dev/loop0 is write-protected, mounting read-only
Installing Virtualbox Guest Additions 5.2.11 - guest version is unknown
Verifying archive integrity... All good.
Uncompressing VirtualBox 5.2.11 Guest Additions for Linux........
VirtualBox Guest Additions installer
Removing installed version 5.2.11 of VirtualBox Guest Additions...
Copying additional installer modules ...
Installing additional modules ...
VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel modules.
This system is currently not set up to build kernel modules.
Please install the Linux kernel "header" files matching the current kernel
for adding new hardware support to the system.
The distribution packages containing the headers are probably:
kernel-devel kernel-devel-3.10.0-693.21.1.el7.x86_64
VirtualBox Guest Additions: Starting.
VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel modules.
This system is currently not set up to build kernel modules.
Please install the Linux kernel "header" files matching the current kernel
for adding new hardware support to the system.
The distribution packages containing the headers are probably:
kernel-devel kernel-devel-3.10.0-693.21.1.el7.x86_64
An error occurred during installation of VirtualBox Guest Additions 5.2.11. Some functionality may not work as intended.
In most cases it is OK that the "Window System drivers" installation failed.
很明显,这是安装在实际盒子中的 VBox Guest Additions,而不是在我的本地机器上。
但是我确实更改了 /usr/share/virtualbox/VBoxGuestAdditions.iso
的文件模式,所以也许这会解决问题:
petrus@DD-XPS-15-9550:/usr/share/virtualbox$ ll
total 56656
drwxr-xr-x 3 root root 4096 maj 14 00:28 ./
drwxr-xr-x 384 root root 16384 maj 16 12:58 ../
drwxr-xr-x 2 root root 12288 maj 13 23:06 nls/
-rw-r--r-- 1 root root 57970688 apr 20 15:50 VBoxGuestAdditions.iso
-rwxr-xr-x 1 root root 2600 nov 29 2016 VBox.sh*
-rwxr-xr-x 1 root root 4163 apr 13 18:37 VBoxSysInfo.sh*
petrus@DD-XPS-15-9550:/usr/share/virtualbox$ sudo chmod ugo+w VBoxGuestAdditions.iso
[sudo] password for petrus:
petrus@DD-XPS-15-9550:/usr/share/virtualbox$ ll
total 56656
drwxr-xr-x 3 root root 4096 maj 14 00:28 ./
drwxr-xr-x 384 root root 16384 maj 16 12:58 ../
drwxr-xr-x 2 root root 12288 maj 13 23:06 nls/
-rw-rw-rw- 1 root root 57970688 apr 20 15:50 VBoxGuestAdditions.iso
-rwxr-xr-x 1 root root 2600 nov 29 2016 VBox.sh*
-rwxr-xr-x 1 root root 4163 apr 13 18:37 VBoxSysInfo.sh*
对于流浪者问题:
默认情况下,Vagrant 将主机 Vagrant 文件的文件夹挂载到 '/vagrant'。如果基本文件系统挂载有效,请测试 'ls -l /vagrant' 的输出。
'ls' 命令应该至少在“/vagrant”中显示你的 Vagrantfile。
如果 Vagrantfile 在虚拟机中可见,基本上挂载与 vagrant 一起工作。
host.vm.synced_folder "salt/", "/srv/salt"
host.vm.synced_folder "pillar/", "/srv/pillar"
您似乎相对于 Vagrantfile 安装了其他文件夹。在这种情况下,您可以在内部修改您的 VM 以 link 它们到所需的目标文件夹。
例如,您可以在 VM 的配置状态下执行此操作。
# Vagrantfile snippet
config.vm.provision "shell", inline: <<-SHELL
ln -s /vagrant/salt /srv/salt
ln -s /vagrant/pillar /srv/pillar
SHELL
也许这个文件在提供时不可用,然后 运行 在您第一次登录后将它们作为一次性任务,或者放置类似于 /etc/rc.local 的内容
错误描述
我无法在 Vagrant 或 Docker 中挂载文件,所以这似乎是由某种权限错误引起的问题。
我的 OS 是 Ubuntu 18.04 LTS (Bionic Beaver)
,据我所知,我没有 运行 任何访问控制模块,例如 SELinux
。
错误的Docker相关讨论在另一个问题中找到: Unable to mount files in Docker
Vagrant 疑难解答
因此我无法将文件装载到 Vagrant 盒子中(即使我有 vboxsf):
Vagrant was unable to mount VirtualBox shared folders. This is usually
because the filesystem "vboxsf" is not available. This filesystem is
made available via the VirtualBox Guest Additions and kernel module.
Please verify that these guest additions are properly installed in the
guest. This is not a bug in Vagrant and is usually caused by a faulty
Vagrant box. For context, the command attempted was:
mount -t vboxsf -o uid=1000,gid=1000 srv_salt /srv/salt
The error output from the command was:
/sbin/mount.vboxsf: mounting failed with the error: No such device
我在 Vagrantfile 中指定了这些语句,它适用于我同事的本地构建,但在我的构建中,这些文件没有被装载或复制到框中:
host.vm.synced_folder "salt/", "/srv/salt"
host.vm.synced_folder "pillar/", "/srv/pillar"
结论
在复制文件时,我的本地计算机上似乎有些混乱,可能与我的用户的配置方式以及将文件装载到 VM 和容器中所具有的访问权限有关。
如果有人能对此有所了解,我将不胜感激。
更新
1)
正如用户@BMitch 建议的那样,我完成了 "Virtualbox Guest Additions" 安装。
每当我更新我的包时,我都会将其记录到日志文件中,这是大约 2 个月前从 update-20180405_153850.txt
中找到的。
Preparing to unpack .../virtualbox-guest-additions-iso_5.1.34-0ubuntu1.16.04.2_all.deb ...
Unpacking virtualbox-guest-additions-iso (5.1.34-0ubuntu1.16.04.2) over (5.0.40-0ubuntu1.16.04.1) ...
但这对我来说没有意义..我的引导脚本(vagrant up'ing the boxes)在我第一次 运行 时失败了:
Vagrant was unable to mount VirtualBox shared folders. This is usually
because the filesystem "vboxsf" is not available. This filesystem is
made available via the VirtualBox Guest Additions and kernel module.
Please verify that these guest additions are properly installed in the
guest. This is not a bug in Vagrant and is usually caused by a faulty
Vagrant box. For context, the command attempted was:
mount -t vboxsf -o uid=1000,gid=1000 srv_salt /srv/salt
The error output from the command was:
/sbin/mount.vboxsf: mounting failed with the error: No such device
Traceback (most recent call last):
File "launch-vagrant.py", line 166, in <module>
main()
File "launch-vagrant.py", line 120, in main
vagrant()
File "launch-vagrant.py", line 95, in vagrant
main()
File "launch-vagrant.py", line 67, in main
start()
File "launch-vagrant.py", line 83, in start
_exec('vagrant', 'up')
File "launch-vagrant.py", line 129, in _exec
subprocess.check_call(list(args))
File "/usr/lib/python3.6/subprocess.py", line 291, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['vagrant', 'up']' returned non-zero exit status 1.
我第二次 运行 它成功了,但出现以下警告消息:
Copy iso file /usr/share/virtualbox/VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso
Mounting Virtualbox Guest Additions ISO to: /mnt
mount: /dev/loop0 is write-protected, mounting read-only
Installing Virtualbox Guest Additions 5.2.11 - guest version is unknown
Verifying archive integrity... All good.
Uncompressing VirtualBox 5.2.11 Guest Additions for Linux........
VirtualBox Guest Additions installer
Removing installed version 5.2.11 of VirtualBox Guest Additions...
Copying additional installer modules ...
Installing additional modules ...
VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel modules.
This system is currently not set up to build kernel modules.
Please install the Linux kernel "header" files matching the current kernel
for adding new hardware support to the system.
The distribution packages containing the headers are probably:
kernel-devel kernel-devel-3.10.0-693.21.1.el7.x86_64
VirtualBox Guest Additions: Starting.
VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel modules.
This system is currently not set up to build kernel modules.
Please install the Linux kernel "header" files matching the current kernel
for adding new hardware support to the system.
The distribution packages containing the headers are probably:
kernel-devel kernel-devel-3.10.0-693.21.1.el7.x86_64
An error occurred during installation of VirtualBox Guest Additions 5.2.11. Some functionality may not work as intended.
In most cases it is OK that the "Window System drivers" installation failed.
很明显,这是安装在实际盒子中的 VBox Guest Additions,而不是在我的本地机器上。
但是我确实更改了 /usr/share/virtualbox/VBoxGuestAdditions.iso
的文件模式,所以也许这会解决问题:
petrus@DD-XPS-15-9550:/usr/share/virtualbox$ ll
total 56656
drwxr-xr-x 3 root root 4096 maj 14 00:28 ./
drwxr-xr-x 384 root root 16384 maj 16 12:58 ../
drwxr-xr-x 2 root root 12288 maj 13 23:06 nls/
-rw-r--r-- 1 root root 57970688 apr 20 15:50 VBoxGuestAdditions.iso
-rwxr-xr-x 1 root root 2600 nov 29 2016 VBox.sh*
-rwxr-xr-x 1 root root 4163 apr 13 18:37 VBoxSysInfo.sh*
petrus@DD-XPS-15-9550:/usr/share/virtualbox$ sudo chmod ugo+w VBoxGuestAdditions.iso
[sudo] password for petrus:
petrus@DD-XPS-15-9550:/usr/share/virtualbox$ ll
total 56656
drwxr-xr-x 3 root root 4096 maj 14 00:28 ./
drwxr-xr-x 384 root root 16384 maj 16 12:58 ../
drwxr-xr-x 2 root root 12288 maj 13 23:06 nls/
-rw-rw-rw- 1 root root 57970688 apr 20 15:50 VBoxGuestAdditions.iso
-rwxr-xr-x 1 root root 2600 nov 29 2016 VBox.sh*
-rwxr-xr-x 1 root root 4163 apr 13 18:37 VBoxSysInfo.sh*
对于流浪者问题: 默认情况下,Vagrant 将主机 Vagrant 文件的文件夹挂载到 '/vagrant'。如果基本文件系统挂载有效,请测试 'ls -l /vagrant' 的输出。
'ls' 命令应该至少在“/vagrant”中显示你的 Vagrantfile。
如果 Vagrantfile 在虚拟机中可见,基本上挂载与 vagrant 一起工作。
host.vm.synced_folder "salt/", "/srv/salt"
host.vm.synced_folder "pillar/", "/srv/pillar"
您似乎相对于 Vagrantfile 安装了其他文件夹。在这种情况下,您可以在内部修改您的 VM 以 link 它们到所需的目标文件夹。
例如,您可以在 VM 的配置状态下执行此操作。
# Vagrantfile snippet
config.vm.provision "shell", inline: <<-SHELL
ln -s /vagrant/salt /srv/salt
ln -s /vagrant/pillar /srv/pillar
SHELL
也许这个文件在提供时不可用,然后 运行 在您第一次登录后将它们作为一次性任务,或者放置类似于 /etc/rc.local 的内容