“UbuntuHelp:MountWindowsSharesPermanently”的版本间的差异
来自Ubuntu中文
小 |
小 |
||
第1行: | 第1行: | ||
{{From|https://help.ubuntu.com/community/MountWindowsSharesPermanently}} | {{From|https://help.ubuntu.com/community/MountWindowsSharesPermanently}} | ||
− | {{Languages| | + | {{Languages|UbuntuHelp:MountWindowsSharesPermanently}} |
第90行: | 第90行: | ||
---- | ---- | ||
− | CategoryDocumentation | + | [[category:CategoryDocumentation]] |
[[category:UbuntuHelp]] | [[category:UbuntuHelp]] |
2007年5月14日 (一) 11:03的版本
点击翻译: |
English |
请不要直接编辑翻译本页,本页将定期与来源同步。 |
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
.