Account Links: Cart | Register | Log In

Skip to content

Red Hat Knowledgebase
Red Hat Knowledgebase Search
Article translations:
Currently Being Moderated

如何配置/etc/fstab或autofs让系统去自动挂载Samba共享?

Article ID: 11562 - Created on: Jul 22, 2008 6:00 PM - Last Modified:  Sep 16, 2009 2:09 AM

[英文原文] How do I configure a system to automount a Samba share with /etc/fstab or autofs?

 

相关版本:Red Hat Enterprise Linux 3,Red Hat Enterprise Linux 4,Red Hat Enterprise Linux 5

 

为了使机器在启动的时候自动挂载Samba共享,修改/etc/fstab添加一行:

 

//server/share /mount/point smbfs username=[username],password=[password] 0 0

 

server是Samba服务器的名称或者IP地址。 share是Samba的共享目录。 /mount/point是本机挂载的目录。 username和password是访问Samba服务器的用户名和密码。

 

编辑文件/etc/fstab:

 

LABEL=/                 /                       ext3    defaults        1 1
LABEL=/boot             /boot                   ext3    defaults        1 2
none                    /dev/pts                devpts  gid=5,mode=620  0 0
none                    /proc                   proc    defaults        0 0
none                    /dev/shm                tmpfs   defaults        0 0
/dev/hda3               swap                    swap    defaults        0 0
/dev/cdrom              /mnt/cdrom              udf,iso9660 noauto,owner,kudzu,ro 0 0
/dev/fd0                /mnt/floppy             auto    noauto,owner,kudzu 0 0
//server/share          /mount/point            smbfs   username=[username],password=[password] 0 0

 

用您的有效用户名和密码替换[username] and [password].

 

如果您想通过autofs服务来自动挂载Samba共享,可参考下面的信息.

 

编辑文件/etc/auto.master

 

# $Id: auto.master,v 1.2 1997/10/06 21:52:03 hpa Exp $
# Sample auto.master file
# Format of this file:
# mountpoint map options
# For details of the format look at autofs(8).
/misc   /etc/auto.misc  --timeout=60

 

编辑文件/etc/auto.misc

 

# $Id: auto.misc,v 1.2 1997/10/06 21:52:04 hpa Exp $
# This is an automounter map and it has the following format
# key [ -mount-options-separated-by-comma ] location
# Details may be found in the autofs(5) manpage

cd              -fstype=iso9660,ro,nosuid,nodev :/dev/cdrom

samba           -fstype=smbfs,username=[username],password=[password] ://server/share

# the following entries are samples to pique your imagination
#linux          -ro,soft,intr           ftp.example.org:/pub/linux
#boot           -fstype=ext2            :/dev/hda1
#floppy         -fstype=auto            :/dev/fd0
#floppy         -fstype=ext2            :/dev/fd0
#e2floppy       -fstype=ext2            :/dev/fd0
#jaz            -fstype=ext2            :/dev/sdc1
#removable      -fstype=ext2            :/dev/hdd

 

编辑完成以后,需要重新启动autofs服务才可以生效,运行命令service autofs restart 或 /etc/init.d/autofs restart.

 

浏览/misc/samba目录可以看见您的Samba共享目录.

 

注意,在Red Hat Enterprise Linux 3和Red Hat Enterprise Linux 4中,samba的共享的文件系统类型是smbfs,在Red Hat Enterprise Linux 5中则请使用cifs类型替换上述的smbfs。

Feedback from users like yourself is a critical factor in helping us make the Red Hat Knowledgebase as useful as possible.

More Like This

  • Retrieving data ...