---
title: "gentoo share net  folder (网络共享文件夹)"
author: "iammonster"
date: "2011-10-02T17:49:02Z"
tags: []
categories: ["操作系统"]
slug: "gentoo-share-net-folder"
draft: false
lastmod: "2013-04-20T21:15:02Z"
id: 1184562
url: "https://jiajun.iteye.com/blog/1184562"
---

**服务端：**

 

安装samba

emerge -av net-fs/samba

 

配置：

```
cp /etc/samba/smb.conf.default /etc/samba/smb.conf
nano /etc/samba/smb.conf
```

内容：

```
[global]

   workgroup = MYGROUP
   server string = Samba Server

   security = user
  guest account = user_test1

   log file = /var/log/samba/log.%m
   max log size = 50
   dns proxy = no
[homes]
   comment = Home Directories
   browseable = no
   writable = yes
[nfs_backup]
        comment = share folder for backup
        path = /var/cloud/nfs_backup
        guest ok = no
        browseable = yes
        writable = yes
        valid users = user_test1

```

 

创建账户：

```
useradd user_test1
passwd user_test1
```

设置共享账户密码：

```
smbpasswd -a user_test1
```

添加用户：

```
nano /etc/samba/smbusers
```

添加部分：

```
user_test1 = user_test1
```

 启动：

```
/etc/init.d/samba start
```

 

-------------------------------------------------------我是分割线--------------------------------------------------------

 

**客户端：**

 

重新编译内核

 

**Linux Kernel Configuration:** Samba Client Kernel Config

```
File systems  --->
  Network File Systems  --->
    <M> CIFS support
```

安装挂载程序

emerge -av net-fs/mount-cifs

准备挂载目录：

mkdir /mnt/nfs/name

chown user\_test1:user\_test1 /mnt/nfs/name

 

添加启动自动挂载

```
nano /etc/fstab
```

 添加内容：

```
//192.168.0.203/nfs_backup      /mnt/nfs/name   cifs    credentials=/etc/nfs.credentials,noatime    0 0
```

 

 设置账户和密码

```
nano /etc/nfs.credentials
```

添加内容：

```
username=user_test1
password=user_test1
```

 

挂载

```
mount -a 
```

 This will mount everything, not mounted, in /etc/fstab .

 

尝试读写，不管root帐号还是usert\_test1帐号，都可以在共享文件夹上写目录和文件，默认权限为：

-rw-r--r--     1 user\_test1 user\_test1 7 Oct  2 17:39 a  
drwxrwxr-x 2 user\_test1 user\_test1 0 Oct  2  2011 b

 

 

参考：http://en.gentoo-wiki.com/wiki/Samba