Could not copy the config file to Vagrant

This is with respect to the configuration file lab. I have the config file in /shared folder. But I am not able to access it from the vagrant environment. The deadline to complete the lesson is Sep 24. I am stuck at this lab. Please advise.

Why you cannot access config file if you have created it under /shared?
/shared is on vagrant which corresponds to your shared dir under vagrant-env in Windows

Yes. I have created the configFile.conf in /shared folder. From vagrant when I try to access it says : cp: cannot stat ‘/shared/configFile.conf’: No such file or directory

Can you please list your /shared dir contents from vagrant@m103
ls -lrt /shared
Did you create cfg file on Windows shared dir or vagrant shared dir?
Looks like you are trying to copy the file which is failing as file does not exist
Can you paste screenshots or terminal logs

My vagrant file is in D:/M103. When I launch the virtual box, it is showing that there are 3 shared folders:
vagrant%20shares
I am creating my config file in D:/M103/shared.
I could not figure out how to access it from the vagrant.
I opened the command prompt and changed the path to D:/M103 and then executed the command vagrant ssh to connect to the VM.
When I run ls, I see only two file data and first_mongod. No other folders are visible.

By default when you login to unix box you will be in your home dir i,e /home/vagrant
You are searching in a wrong directory
I want you to go to /shared bu issuing the command
cd /shared and list the files by ls -lrt

You should be able to see your cfg file created on Windows here


Even that is not showing any files. But I can see the config file in my Windows Explorer.

Please create your cfgfile under
D:\Users\your_user_name\M003\m103-vagrant-env\shared>
You can create a test file on Unix /shared dir by command
touch test
Then check this zero byte file at above windows folder

Should I move the entire M1103 folder into D:\Users\my_user_name?
Where do I find m103-vagrant-env folder? Or should I create one?

When I try to create a file in /shared dir by touch test, it says permission denied.

No
You Don’t have to move anything.It should come automatically
May be the process changed.Mine is a old one
How did you start vagrant up?
Usually we do it from vagrant-env dir
I saw your other post.In that Steeve clearly mentioned cfg file should be under sub directory shared for the same issue faced by another user
I am not sure why it is not showing up
May be the synching of folders not happening
or installation was done in D:?
In my case i used C:
From you vagrant up mesages can you identify your shared folder?
like below
==> mongod-m103: Mounting shared folders…
mongod-m103: /shared => C:/Users/user_name/M003/m103-vagrant-env/shared

You should be able to create file on your unix shared folder
Not sure why it is failing
What does id command show

When I bring up the VM the following are the messages displayed:

D:\M103>vagrant up
Bringing machine ‘mongod-m103’ up with ‘virtualbox’ provider…
==> mongod-m103: Clearing any previously set forwarded ports…
==> mongod-m103: Clearing any previously set network interfaces…
==> mongod-m103: Preparing network interfaces based on configuration…
mongod-m103: Adapter 1: nat
mongod-m103: Adapter 2: hostonly
==> mongod-m103: Forwarding ports…
mongod-m103: 22 (guest) => 2222 (host) (adapter 1)
==> mongod-m103: Running ‘pre-boot’ VM customizations…
==> mongod-m103: Booting VM…
==> mongod-m103: Waiting for machine to boot. This may take a few minutes…
mongod-m103: SSH address: 127.0.0.1:2222
mongod-m103: SSH username: vagrant
mongod-m103: SSH auth method: private key
mongod-m103: Warning: Connection aborted. Retrying…
==> mongod-m103: Machine booted and ready!
==> mongod-m103: Checking for guest additions in VM…
mongod-m103: The guest additions on this VM do not match the installed version of
mongod-m103: VirtualBox! In most cases this is fine, but in rare cases it can
mongod-m103: prevent things such as shared folders from working properly. If you see
mongod-m103: shared folder errors, please make sure the guest additions within the
mongod-m103: virtual machine match the version of VirtualBox you have installed on
mongod-m103: your host and reload your VM.
mongod-m103:
mongod-m103: Guest Additions Version: 4.3.40
mongod-m103: VirtualBox Version: 6.0
==> mongod-m103: Setting hostname…
==> mongod-m103: Configuring and enabling network interfaces…
==> mongod-m103: Mounting shared folders…
mongod-m103: /shared => D:/M103/shared
mongod-m103: /vagrant => D:/M103
mongod-m103: /dataset => D:/M103/dataset
==> mongod-m103: Machine already provisioned. Run vagrant provision or use the --provision
==> mongod-m103: flag to force provisioning. Provisioners marked to run always will still run.

This is your shared dir
mongod-m103: /shared => D:/M103/shared

Left side is Unix and right side one is Windows
So it should work
Try creating another file on Windows abc.txt or xyz.conf and see if can find it on /shared on Unix box

I removed the entire VM and reinstalled it, still no luck. I can see the /shared folder, but the file is not visible from the vagrant.

I went through the log as I executed the vagrant up command. It gave the following message. I have downloaded the version as per the link given in the course.

==> mongod-m103: Checking for guest additions in VM…
mongod-m103: The guest additions on this VM do not match the installed version of
mongod-m103: VirtualBox! In most cases this is fine, but in rare cases it can
mongod-m103: prevent things such as shared folders from working properly. If you see
mongod-m103: shared folder errors, please make sure the guest additions within the
mongod-m103: virtual machine match the version of VirtualBox you have installed on
mongod-m103: your host and reload your VM.

Hi @jnvdasa,

Please confirm if you have followed all the steps mentioned in the post given below to set up your vagrant environment.


The doc lists all the steps including creation of m103 directory downloading m103-vagrant-env zip file. You need to navigate to m103-vagrant-env folder as explained in the doc.
That should help.

Also, for the following error,

Can you please run the following set of commands and let me know if it works for you?

vagrant plugin update vagrant-vbguest
vagrant destroy
vagrant up 

Thanks,
Muskan
Curriculum Support Engineer

Hi,

Please check the output of command ‘vagrant up’. If the /shared path is not being mounted, then consider performing the following steps:

  • Install vagrant plugin: vagrant-vbguest

vagrant plugin install vagrant-vbguest

  • Reload OS

vagrant reload

Moreover, as an alternative you can use ‘scp’ command to copy files between host and guest machines.
Winscp software for Windows
or from CLI
scp -rv <mongod.conf> vagrant@<IP_Address>:/data/mongodb/

1 Like