个人工具

“UbuntuHelp:MountWindowsSharesPermanently”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
(New page: {{From|https://help.ubuntu.com/community/MountWindowsSharesPermanently}} {{Languages|php5}} This page is being developed to fix a dead link on the InternetAndNetworking page. == Introdu...)
 
第14行: 第14行:
 
<pre><nowiki>
 
<pre><nowiki>
 
sudo apt-get install smbfs  
 
sudo apt-get install smbfs  
</nowiki></code>
+
</nowiki></pre>
  
 
You must have a windows machine (or other machine running Samba) with an accessable share.
 
You must have a windows machine (or other machine running Samba) with an accessable share.
第34行: 第34行:
 
username=MyUserName
 
username=MyUserName
 
password=MyPassword
 
password=MyPassword
</nowiki></code>
+
</nowiki></pre>
  
 
On the command line, in the directory of .smbpassword type
 
On the command line, in the directory of .smbpassword type
第40行: 第40行:
 
sudo chown root .smbpassword
 
sudo chown root .smbpassword
 
sudo chmod 600 .smbpassword  
 
sudo chmod 600 .smbpassword  
</nowiki></code>
+
</nowiki></pre>
 
this will ensure that only root can access this file.
 
this will ensure that only root can access this file.
  
第49行: 第49行:
 
<pre><nowiki>
 
<pre><nowiki>
 
//servername/sharename /mountdirectory smbfs credentials=/home/myhomedirectory/.smbpassword,gid=GIDFromAbove 0 0
 
//servername/sharename /mountdirectory smbfs credentials=/home/myhomedirectory/.smbpassword,gid=GIDFromAbove 0 0
</nowiki></code>
+
</nowiki></pre>
 
''I can't make the above show up on one line, but it MUST all be on one line in your fstab file''
 
''I can't make the above show up on one line, but it MUST all be on one line in your fstab file''
  
第58行: 第58行:
  
 
and then type / -followed by the username you are looking for-
 
and then type / -followed by the username you are looking for-
</nowiki></code>
+
</nowiki></pre>
  
 
Be sure to use unix "//" and "/" instead of windows "\\" and "\" in the windows share, otherwise it won't parse correctly.
 
Be sure to use unix "//" and "/" instead of windows "\\" and "\" in the windows share, otherwise it won't parse correctly.
第70行: 第70行:
 
<pre><nowiki>
 
<pre><nowiki>
 
sudo mount -a
 
sudo mount -a
</nowiki></code>
+
</nowiki></pre>
  
 
== Troubleshooting ==
 
== Troubleshooting ==
第81行: 第81行:
 
<pre><nowiki>
 
<pre><nowiki>
 
sudo /etc/init.d/samba restart
 
sudo /etc/init.d/samba restart
</nowiki></code>
+
</nowiki></pre>
  
 
If that doesn't work, or for some reason you can't do anything on the server side, then try
 
If that doesn't work, or for some reason you can't do anything on the server side, then try
 
<pre><nowiki>
 
<pre><nowiki>
 
sudo umount -lf /mount/point
 
sudo umount -lf /mount/point
</nowiki></code>
+
</nowiki></pre>
 
The <code><nowiki>-f</nowiki></code> option forces (possibly unclean) unmounting, and the <code><nowiki>-l</nowiki></code> option is for "lazy unmounting", and seems to work around "device is busy" errors that occur with just <code><nowiki>-f</nowiki></code>.   
 
The <code><nowiki>-f</nowiki></code> option forces (possibly unclean) unmounting, and the <code><nowiki>-l</nowiki></code> option is for "lazy unmounting", and seems to work around "device is busy" errors that occur with just <code><nowiki>-f</nowiki></code>.   
  

2007年5月13日 (日) 12:32的版本


This page is being developed to fix a dead link on the InternetAndNetworking page.

Introduction

This guide will show you how to setup a mount of a remote windows share, and have it always there when you startup.

Prerequisites

You must have smbfs installed on your machine. This should occur by default. If you don't have it, run

sudo apt-get install smbfs 

You must have a windows machine (or other machine running Samba) with an accessable share.

The 'samba' package itself is not necessary if you only need a smb client.

Setup

Read/Write Group

The first step is to create a group of users that you want to have read/write access to this share (by default only root can r/w). If there is only one user you want to give read/write access, then don't worry about this. If you have multiple users, and each user also has a windows account with individual permissions, do not add them to this group. Instead, repeat this set of instructions for each user, I would recommend making the mount point in this example somewhere in their home directory.

To create the group, go to the "System" menu, then to the "Administration" menu, then select "Users and Groups". Under the groups tab, create a new group. Then add the users you want to have read/write access to this group. Write down the GID for the group, you will need it later.

Credentials File

Warning- this method is not completely secure, any user with root access could see your password in plain text.

Create a file called .smbpassword, probably in the home directory of the primary user of the share. In this file put username an equals sign and the windows username (and domain if loging into a domain) on the first line, put password an equals sign and the password for that user account on the second line of the file. The file should look like:

username=MyUserName
password=MyPassword

On the command line, in the directory of .smbpassword type

sudo chown root .smbpassword
sudo chmod 600 .smbpassword 

this will ensure that only root can access this file.

Editing fstab

Warning- editing the fstab file can be dangerous, please back it up before continuing.

Add a line at the bottom of your \etc\fstab file that specifies:

//servername/sharename /mountdirectory smbfs credentials=/home/myhomedirectory/.smbpassword,gid=GIDFromAbove 0 0

I can't make the above show up on one line, but it MUST all be on one line in your fstab file

If you only want one user to have read/write access, use uid=UsersID instead of the gid. If you don't want anyone except root to have read/write access, leave that string out entirely. You can find the UsersID in /etc/passwd

less /etc/passwd

and then type / -followed by the username you are looking for-

Be sure to use unix "//" and "/" instead of windows "\\" and "\" in the windows share, otherwise it won't parse correctly.

Make sure the /mountdirector is a directory that exists (and is empty)

Completing Setup

Reload fstab or restart

Reloading fstab can be done by typing:

sudo mount -a

Troubleshooting

Server is down, filesystem is hung

If the client somehow loses contact with the Samba server, then the filesystem will probably get hung. Basically, it becomes a blackhole, eating things that try to read to/write from it (e.g. ls) and refusing to go away (e.g., umount says that the "device is busy").

Sometimes, all you need to do is restart the Samba daemon on the server machine.

sudo /etc/init.d/samba restart

If that doesn't work, or for some reason you can't do anything on the server side, then try

sudo umount -lf /mount/point

The -f option forces (possibly unclean) unmounting, and the -l option is for "lazy unmounting", and seems to work around "device is busy" errors that occur with just -f.


CategoryDocumentation