In the
first part, we created a virtual machine, installed Ubuntu, set up a network and SSH access to the guest OS (Ubuntu). Now, it's time to figure out how to synchronize our files. You can of course not bother with this, but simply copy files via sftp after each edit, but it will quickly get bored. Therefore, for complete happiness, it is worthwhile to adopt one of the methods described below.
Method number 1
Dignity: ease of setup.
Disadvantage: one-way synchronization.
The easiest way to solve our problem is to set up synchronization in
WinSCP . For this we need WinSCP and configured SSH. You already download the first one, and we configured the second one in the previous article, so we will immediately move on to setting up synchronization.
To set up synchronization, run WinSCP, set up an SSH connection with our Ubuntu (just like in putty) and connect. Now go to Commands> Synchronize a folder on the server (Ctrl + U) and set up synchronization (everything is very simple there).
')
PS This method has a very big drawback: the synchronization will be one-way - windows> Ubuntu.
Method number 2
Virtue: universal.
Disadvantage: problems with changing permissions on files and directories.
The second method is the most universal - it does not depend on a particular virtualization system and is very easy to configure.
To begin, go to Windows and create a new user with a password. Now we’ll select the folder for which we will open a shared access and in which our scripts will be stored (if you use Denver, you can open access to the / home folder).
Note
To enable sharing:
- Select a folder, go to the properties.
- Go to "Access"> "Sharing".
- Choose from the drop-down list of our created user and click "Add".
- We select our user in the table and set him “Permission Level” - “Reading and Writing”.
Go back to Ubuntu and install smbfs:
sudo apt-get install smbfs
Now we create a directory into which we will mount our remote folder:
mkdir ~/www
Create a file with the login and password of our windows user:
sudo touch /root/.smbclient
Open the created file and add our user's Windows data to it:
username= password=
Mount our remote folder (let it be the folder / home) in the directory ~ / www. To do this, we need to know the name of our Windows machine or its IP (how to find out the IP, see the first part).
sudo smbmount //192.168.80.1/home /home/claud/www -o credentials=/root/.smbclient,uid=claud,gid=claud,forceuid=claud,forcegid=claud,rw,_netdev, dir_mode=0777, file_mode=0666
Note
- 192.168.80.1 - this is my IP, replace it with your own.
- Claud - this is my user in Ubuntu, replace it with your own (be careful - replace everywhere).
Description of options
- credentials = / root / .smbclient - file that stores username and password for a user on a remote computer.
- uid = claud - UID for all files and directories transmitted by the server. If the server did not send a UID, this value is used. By default it is 0 (root), you can write the name or UID of the user.
- gid = claud is the same as UID only for groups.
- forceuid = claud - forcibly sets the UID for all directories and files.
- forcegid = claud - the same as forceuid for a group only.
- iocharset = utf8 - file encoding on the server.
- rw - read and write monitor. Can be changed to “ro” - mounts read-only.
- _netdev is an option indicating that this resource is a network resource. It is useful if there is no network at system start-up, then the system will not give an error message about the impossibility of mounting resources.
- file_mode = 0666 - permissions to access files on the server. In this case, files can be read and modified by all users of the system.
- dir_mode = 0777 - access rights to directories on the server. In this case, the directory can be changed by any user.
Everything is now our shared folder from Windows is available on Ubuntu and all changes made to it on one of the operating systems will be immediately available on the other. But there is one disadvantage: the change of access rights to files or directories in the shared folder is not fixed.
Adding to / etc / fstabIf you add an entry in / etc / fstab, then when you restart or shut down the system, you will see the following message:
1.CIFS VFS: No Response for Cmd number mid number
On the Internet, many different ways to treat this filth. For example:
But the easiest is:
I spat on all the dances with tambourines on the boot sequence and all win resources I mount in /etc/rc.local via smbmount
Method number 3
Advantage: in addition to shared folders, we get a few more useful additions.
Disadvantage: only suitable for VMware, problems with changing permissions on files and directories.
VMware has Vmware tools - a set of various utilities that are installed on the guest OS and provide additional improvements (shared folder, your network driver, etc.).
Note
Before starting the installation, I highly recommend making a backup of your VM or (if available) make a snapshot.
To install VMware tools, run our VM. After logging in to Ubuntu, open the Virtual Machine menu and click "Install VMware Tools".
Go to Ubuntu and create two directories:
mkdir ~/tmp sudo mkdir /mnt/cdrom
Mount our cdrom:
sudo mount /dev/cdrom /mnt/cdrom
Now attention. Check the version of VMware tools:
ls –l /mnt/cdrom/
If you have VMwareTools-8.4.6 or higher, then most likely the installation on Ubuntu 11.04 will pass without problems, otherwise you will have to sweat and smoke
it and maybe this
is it , well, this
one too.
Suppose we are lucky and we have VMwareTools-8.4.6:
tar -zxvf /mnt/cdrom/VMwareTools-*.tar.gz -C ~/tmp cd /tmp/vmware-tools-distrib/
Install:
sudo ./vmware-install.pl –d
After the installation is completed, go to the settings of our VM> Options> Shared Folders, set the switch to Always enabled and add what is the wrong directory (for example: / home from Denver). Save and close the settings.
We return to our Ubuntu and execute the command:
ls –l /mnt/hgfs
If everything was done correctly, then you will see your windows folders (in general, all your shared folders will be available in this directory).
Now let's mount the / home folder to the ~ www directory. To do this, run the command (claud is the name of my Ubuntu account, change it to your own):
sudo mount -t vmhgfs -o file_mode=0666,dir_mode=0777uid=claud,gid=claud,forceuid=claud,forcegid=claud,rw,_netdev .host:/home /home/claud/www
PS This method allows you to change the rights of only two types of rwxrwxrwx or r-xr-xr-x (still better than not at all).
Conclusion
As I wrote above, you can easily mount the / home folder (from Denver) and thus get the opportunity to test your scripts on both Windows and Linux.
PS If someone knows how to solve problems with the reassignment of rights, I would very much like to know them.
PPS Virtualbox-oats tell me how things are going with the reassignment of access rights in the Virtualbox implementation of Shared Folders.
Full replacement of Denwer or deploy Ubuntu-server on VMware (Part 1)