【问题标题】:Vagrant shared folder not working/synchronizingVagrant 共享文件夹不工作/同步
【发布时间】:2021-11-01 13:10:58
【问题描述】:

所以我有一台流浪机器

m@m-ThinkPad-L15-Gen-2:~/Desktop/estudos/shellclass/localuser$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'jasonc/centos7'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'jasonc/centos7' version '1.4.4' is up to date...
==> default: Setting the name of the VM: localuser_default_1635771672344_69157
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: 
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default: 
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: The guest additions on this VM do not match the installed version of
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default: 
    default: Guest Additions Version: 5.2.6
    default: VirtualBox Version: 6.1
==> default: Mounting shared folders...
    default: /vagrant => /home/m/Desktop/estudos/shellclass/localuser

当我尝试在文件夹上创建测试文件时:

m@m-ThinkPad-L15-Gen-2:~/Desktop/estudos/shellclass/localuser$ vagrant ssh
[vagrant@localhost ~]$ ls
[vagrant@localhost ~]$ cd vagrant
-bash: cd: vagrant: No such file or directory
[vagrant@localhost ~]$ cd ..
[vagrant@localhost home]$ ls
vagrant
[vagrant@localhost home]$ cd vagrant
[vagrant@localhost ~]$ touch teste
[vagrant@localhost ~]$ ls -l
total 0
-rw-rw-r-- 1 vagrant vagrant 0 Nov  1 09:02 teste
[vagrant@localhost ~]$ ls -l
total 0
-rw-rw-r-- 1 vagrant vagrant 0 Nov  1 09:02 teste
[vagrant@localhost ~]$ vagrant rsync-auto
-bash: vagrant: command not found
[vagrant@localhost ~]$ rsync-auto
-bash: rsync-auto: command not found
[vagrant@localhost ~]$ 

当我尝试从普通的 linux 终端访问它时,我找不到文件:

m@m-ThinkPad-L15-Gen-2:~/Desktop/estudos/shellclass/localuser$ ls -l
ls: /lib/x86_64-linux-gnu/libselinux.so.1: no version information available (required by ls)
total 4
-rw-rw-r-- 1 m m 3020 nov  1 10:00 Vagrantfile

发生了什么事? 我以前创建过这台机器,直到上周五它都可以正常工作。但是现在,由于某种原因,我再也找不到文件了。当我在图形界面上打开它时,我也看不到我创建的文件。

【问题讨论】:

    标签: linux vagrant centos7


    【解决方案1】:

    没有看到你的 Vagrantfile 很难回答你的问题。但是在vagrant ssh 之后,您可能应该使用cd /vagrant 而不是cd vagrant(带有正斜杠)。

    此外,您的访客添加更多是针对不同版本的 virtualbox。 您可以安装 vbguest 插件进行更新:vagrant plugin install vagrant-vbguest

    virtualbox 终于从版本 6.1.26 更新到了 6.1.28。这也破坏了许多配置。另见Vagrant up failing for VirtualBox provider on Ubuntu

    【讨论】:

    • 谢谢!问题是 cd /vagrant
    猜你喜欢
    • 2016-03-21
    • 1970-01-01
    • 1970-01-01
    • 2016-05-11
    • 1970-01-01
    • 2017-01-01
    • 1970-01-01
    • 2016-09-08
    • 2017-08-20
    相关资源
    最近更新 更多