Ubuntu中利用samba将本地文件给vmware中的windows使用

VMware中跑的windows现在都正常,只是访问文件比较麻烦,因为空间不大,如果每次都要通过文件复制到vm中的硬盘的话空间肯定是不够的。解决方案就是用samba把文件提供给vmware使用

看了这篇文章,

HOWTO: Setup samba with Windows XP running as a VMWare server guest

The full title of this howto should be:

“How to setup samba peer to peer with Windows XP which is running as a VMWare server guest on a Ubuntu Dapper host to share files easily”

Using VMWare server to run Windows programs which are not available on Linux will enable you to never have to dual boot again to run your essential Windows applications.

To install VMWare server, follow the directions at:
http://www.ubuntuforums.org/showthre…ghlight=vmware

Once VMWare is successfully installed and you have Windows XP installed as a guest, you should read Stormbringer’s howto at:
http://www.ubuntuforums.org/showthre…ghlight=vmware

This howto is very largely based on Stormbringer’s work, but because I had so much difficulty in getting samba to connect to my Windows XP guest I thought some people might appreciate knowing what steps I finally used.

If you don’t use Gnome, you’ll have to make a few adjustments.

Ok, here we go…
1)Use Synaptic Package Manager to install samba, samba-common, smbclient and smbfs.

2)Use System -> Administration -> Shared folders to make a shared folder. I suggest you use /home/YOUR_NAME/samba. In Properties:
a) Share with: SMB
b) Name: MyFiles
c) Tick Allow browsing folder
d) In Windows sharing settings, “Domain/Workgroup” is MsHome (or whatever your guest XP machine is) and select “This computer is a WINS server”.
e) Press OK, OK

3)Set permissions on your shared file:

Code:
sudo chmod 0777 /home/YOUR_NAME/samba

4)Stop samba:

Code:
sudo /etc/init.d/samba stop

5)Backup the original smb.conf file:

Code:
sudo mv /etc/samba/smb.conf /etc/samba/smb.conf.backup

6)Make a new smb.conf file:

Code:
sudo touch /etc/samba/smb.conf

7)Open smb.conf for editing:

Code:
sudo gedit /etc/samba/smb.conf

Paste the following into your smb.conf file (mostly copied from Stormbringer)…
(I’ve put *** (no)against the entries you may need to change immediately. Please remove the ***(nos) when you’ve finished editing.)

Code:
[global]

;General server settings

netbios name = Ubuntu***(1)

workgroup = Mshome***(2)

announce version = 5.0

socket options = TCP_NODELAY IPTOS_LOWDELAY SO_KEEPALIVE SO_RCVBUF=8192 SO_SNDBUF=8192
passdb backend = tdbsam

security = user

null passwords = true

username map = /etc/samba/smbusers

name resolve order = hosts wins bcast

wins support = yes
printing = CUPS

printcap name = CUPS
syslog = 1

syslog only = yes
; NOTE: If you need access to the user home directories uncomment the

; lines below and adjust the settings to your hearts content.

;[homes]

;valid users = %S

;create mode = 0600

;directory mode = 0755

;browseable = no

;read only = no

;veto files = /*.{*}/.*/mail/bin/
; NOTE: Only needed if you run samba as a primary domain controller.

; Not needed as this config doesn't cover that matter.

;[netlogon]

;path = /var/lib/samba/netlogon

;admin users = Administrator

;valid users = %U

;read only = no
; NOTE: Again - only needed if you're running a primary domain controller.

;[Profiles]

;path = /var/lib/samba/profiles

;valid users = %U

;create mode = 0600

;directory mode = 0700

;writeable = yes

;browseable = no
; NOTE: Inside this place you may build a printer driver repository for Windows

[print$]

path = /var/lib/samba/printers

browseable = yes

guest ok = yes

read only = yes

write list = root

create mask = 0664

directory mask = 0775
[printers]

path = /tmp

printable = yes

guest ok = yes

browseable = no
; Uncomment if you need to share your CD-/DVD-ROM Drive

;[DVD-ROM Drive]

;path = /media/cdrom

;browseable = yes

;read only = yes

;guest ok = yes
[MyFiles]

path = /home/YOURNAME/samba***(3)

browseable = yes

read only = no

guest ok = no

create mask = 0644

directory mask = 0755

force user = paul***(4)

force group = paul***(5)

available = yes

public = yes

writable = yes

9)Personalise your new smb.conf file by editing the ***(nos). You can do any other editing you want to do later when everything is up and running.
***(1) Use any sensible name, but remember what it is.
***(2) Use the same workgroup name as Windows XP (usually Mshome).
***(3) This is the shared folder you created earlier
***(4 & 5) This is the username you use for Windows XP. Don’t use spaces. If necessary, modify the username you use for your guest XP machine (Explorer->Control Panel->User Accounts).

10)Start samba:

Code:
sudo /etc/init.d/samba start

11)Add yourself as a samba user:
NOTE: You will be asked for a password – make sure you use the same as you use for login

Code:
sudo smbpasswd -L -a your_username

sudo smbpasswd -L -e your_username

That’s all for samba, now for the Windows part:

12)In the Windows XP machine VM -> Settings -> Ethernet, I chose Nat

13)Find out the ip of your linux box and the vmware connections by typing ifconfig in a Ubuntu terminal. You will probably see 4 or more ip addresses. Write down each of the 4 (or more) inet addr addresses.

14)In the Windows guest machine:
– Click “START”
– Click “Control Panel”
– Click “Network Connections”
– Find your “LAN Connection”
– Right-click the icon and select “Properties”
– Select the “TCP/IP” Protocol and click the “Properties” button
– Click “Advanced”
– Select the third Tab entitled “WINS”
– Click “Add”
– Type in each of the ip addresses you copied down from 13) above & click “Add” for each one
– Select “Use NetBIOS over TCP/IP”
– Click “OK”
– Click “OK”
– Click “OK”
– Reboot the guest Windows

15)In the Windows guestmachine:
– Click “Start”
– Right-click “My Computer”
– Click “Map Network Drive”
– Choose a folder letter
– In the Folder field type \\Ubuntu (or the netbios name you chose)\MyFiles(the name chosen for the Ubuntu shared folder)
– Tick “Reconnect at logon”
– Press “Finish”

If all has gone well, whatever you see in the Ubuntu shared drive will be seen in the nominated XP drive. Copying or moving files from/to Ubuntu and the XP guest is now very straightforward.

I’ve given these instructions in good faith and they represent what I had to do to get my samba connection working between my Ubuntu partition and its Win XP VMWare guest. If they don’t work for you, I’m sorry but I doubt if there’s a lot I can do to help because I am very new to Ubuntu. and I had to struggle for more than a day to get this working. Huge Credits to Peturr for the Howto:VMWare installation, and to Stormbringer for his Howto:Setup Samba Peer to Peer from which I borrowed freely.

注:原文中提到的System->Adminstration下的Shared Folder我没找到,为了便于理解我装了一个samba的软件,从Add/Remove里装的。其实估计也可不装。直接配置就行了。

贴一下我的配置

[global]

;General server settings

netbios name = Ubuntu

workgroup = Workgroup

announce version = 5.0

socket options = TCP_NODELAY IPTOS_LOWDELAY SO_KEEPALIVE SO_RCVBUF=8192 SO_SNDBUF=8192
passdb backend = tdbsam

security = user

null passwords = true

username map = /etc/samba/smbusers

name resolve order = hosts wins bcast

wins support = yes
printing = CUPS

printcap name = CUPS
syslog = 1

syslog only = yes
; NOTE: If you need access to the user home directories uncomment the

; lines below and adjust the settings to your hearts content.

;[homes]

;valid users = %S

;create mode = 0600

;directory mode = 0755

;browseable = no

;read only = no

;veto files = /*.{*}/.*/mail/bin/
; NOTE: Only needed if you run samba as a primary domain controller.

; Not needed as this config doesn't cover that matter.

;[netlogon]

;path = /var/lib/samba/netlogon

;admin users = Administrator

;valid users = %U

;read only = no
; NOTE: Again - only needed if you're running a primary domain controller.

;[Profiles]

;path = /var/lib/samba/profiles

;valid users = %U

;create mode = 0600

;directory mode = 0700

;writeable = yes

;browseable = no
; NOTE: Inside this place you may build a printer driver repository for Windows

[print$]

path = /var/lib/samba/printers

browseable = yes

guest ok = yes

read only = yes

write list = root

create mask = 0664

directory mask = 0775
[printers]

path = /tmp

printable = yes

guest ok = yes

browseable = no
; Uncomment if you need to share your CD-/DVD-ROM Drive

;[DVD-ROM Drive]

;path = /media/cdrom

;browseable = yes

;read only = yes

;guest ok = yes
[samba]

path = /home/billyqiu/samba

browseable = yes

read only = no

guest ok = no

create mask = 0644

directory mask = 0755

force user = billyqiu

force group = billyqiu

available = yes

public = yes

writable = yes
[Personal]

path = /media/Personal

browseable = yes

read only = no

guest ok = no

create mask = 0644

directory mask = 0755

force user = billyqiu

force group = billyqiu

available = yes

public = yes

writable = yes
[DATA]

path = /media/DATA

browseable = yes

read only = no

guest ok = no

create mask = 0644

directory mask = 0755

force user = billyqiu

force group = billyqiu

available = yes

public = yes

writable = yes

Leave a Comment

You must be logged in to post a comment.