Synchronize the folders between Windows and Ubuntu in VirtualBox

來源:互聯網
上載者:User
文章目錄
  • 1, Why do this
  • 2, Preparations
  • 3, Well done
1, Why do this

Recently, I keep working in my guest operating system which is Ubuntu 12.4 LTS. I got some project documents from my co-workers. It’s better to read the documents from Ubuntu directly, instead of switch between guest operating system(Ubuntu) and host operating system(Windows 7).

A simple idea came out: I want a way to sync a folder between Ubuntu and Windows. rsync maybe a handy tools intended for sync files and folder across different machines.

2, Preparations

1, Install the rsync

I am cygwin fan, there is package built with the cygwin, we just use it. We can get and install the package by cygwin’s setup.exe.

2, Install the ssh daemon in Ubuntu(guest operating system)

$sudo apt-get install ssh

$ss –l    #check ssh daemon is running

3, Enable the VirtualBox port forwarding

Adding the port forwarding for ssh, as such:

 

4,Create the sync folder

We also need create the sync folder both in Windows 7 and Ubunt, in which our file keep sync.

$mkdir –p /cygdrive/c/VirtualBox/Rsync/data/    #cyginw on Windows 7

$mkdir –p /home/jerry/Rsync/data/        #Ubuntu

3, Well done

It’s time to show off. I put some files in the folder of “/cygdrive/c/VirtualBox/Rsync/data/”.  I want the guest operating system, Ubuntu, can also sync all of this file. Just type:

$rsync.exe -avzP  --rsh='ssh -p 2222' /cygdrive/c/VirtualBox/Rsync/data/ jerry@localhost:/home/jerry/Rsync/data/

When system prompt you typing the jerry’s password, just type it and enter.

All things done! Now you can view/edit the file in Ubuntu. Wow? You edited file and you want to sync this to Windows? No problem. Open the cygwin on Windows, type:

$rsync.exe -avzP  --rsh='ssh -p 2222' jerry@localhost:/home/jerry/Rsync/data/ /cygdrive/c/VirtualBox/Rsync/data/

Even more, You may want a small shell scripting to make it automatically. Like this:

Have fun!

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.