开机挂载smaba共享文件夹.md


* 安装samba smbfs

sudo apt-get install cifs-utils
  • 创建目录
sudo mkdir /media/feng/feng_smb/
  • 编辑fstab加入一行,开机自动挂载
sudo vim /etc/fstab
//192.168.31.138/servershare/Users/feng_smb/ /media/feng/feng_smb/ cifs defaults,username=feng,passward=Helab401,rw 0 2
  • 保存后
sudo mount -a

相关命令及文件解释

/etc/fstab

  • fstab(/etc/fstab)Linux下比较重要的配置文件,它包含了系统在启动时挂载文件系统和存储设备的详细信息。下面是我机子上的 fstab文件:
$ cat /etc/fstab 
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
#                
# / was on /dev/sda7 during installation
UUID=f34aaf23-3ab7-4b4c-a211-1090dfe61c16 /               ext4    errors=remount-ro 0       1
# /boot was on /dev/sda6 during installation
UUID=d46bdea4-c82a-4cd2-8c46-34007e4aac29 /boot           ext4    defaults        0       2
# /boot/efi was on /dev/nvme0n1p1 during installation
UUID=000F-39B4  /boot/efi       vfat    defaults        0       1
# /home was on /dev/sda8 during installation
UUID=e2bc040d-1eda-4d33-90e9-4bbdd64bbd75 /home           ext4    defaults        0       2
# swap was on /dev/sda5 during installation
UUID=c4d98929-dd3e-4436-94b1-7b65f91fddb0 none            swap    sw              0       0
//192.168.31.138/servershare/Users/feng_smb/ /media/feng/feng_smb/ cifs defaults,username=feng,passward=Helab401,rw 0 2
  • 详细解释

命令行手动挂载

  • 有两个命令可以用来手工挂载samba文件系统,一个是mount,一个是smbmount
  • mount就是用于挂载文件系统的,SMB做为网络文件系统的一种,也能用`mount挂载 一般挂载的用法为:
mount -t smbfs -o codepage=cp936,username=,password=, -l //192.168.31.138/path/want/to/share/ /path/to/mount/
mount -t cifs //192.168.31.138/servershare/Users/feng_smb/ /media/feng/feng_smb/ -o defaults,username=feng,passward=Helab401,rw
  • 若没有设置用户名和密码,则可以简化为:
mount -t smbfs -o codepage=cp936 //192.168.31.138/servershare/Users/feng_smb/ /media/feng/feng_smb/
  • 使用smbmount命令挂载
  • smbmount说到底也是用mount的一个变种,因此,类似于mount命令,smbmount的用法为:
    smbmount -o username=用户名,password=密码, -l //ip地址/共享文件夹名 挂载点
    smbmount -o username=用户名,password=密码, -l //计算机名/共享文件夹名 挂载点
    smbmount //ip地址或计算机名/共享文件夹名 挂载点
  • ubuntu12.10之后,smbfscifs代替。因此需要
    1. 安装cifs-utils
sudo apt-get install cifs-utils
  1. 将上面命令中的smbfs改为cifs
  2. 若系统启动时报挂载smbfs/cifs失败,请检查是否安装了autofs服务

你可能感兴趣的:(ubuntu)