Synchronize the folders between Windows and Ubuntu in VirtualBox

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

image

Adding the port forwarding for ssh, as such:

 image

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:

image

Have fun!

转载于:https://www.cnblogs.com/Jerry-Chou/archive/2012/06/08/2541771.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值