ubuntu挂载局域网共享文件

感谢dbott67


原文地址:http://ubuntuforums.org/showthread.php?t=280473


HOWTO: Mounting SMB/CIFS Shares


A few of the downsides on the Nexstar LX NAS device that I purchased is that:

1. It does not support CIFS

2. It does not support SATA drives (IDE only)

3. It is 10/100 Mbps (no gigabit)

4. It does not have any fault tolerance.

It is, however, an inexpensive device that can be used to share data among many computers. Anyhow, I have been in the process of upgrading my home network to gigabit and wanted to purchase a better NAS device that had some redundancy & expandability, as well as support for gigabit, CIFS and SATA drives (hot-swappable, no less). I ended up purchasing a Netgear (formerly Infrant) ReadyNAS NV+ 4250 and am providing an update to my original instructions using CIFS rather than smbfs:

Steps 1 and 2 remain the same.

In step 3, test mount the share using CIFS as noted:

Code:

dbott@gutsy:~$ sudo mount -t cifs //192.168.1.2/Music /home/dbott/Music -o iocharset=utf8,file_mode=0777,dir_mode=0777 


Step 4 remains the same.

Step 5, add the mount point(s) to your /etc/fstab file:

Code:

//192.168.1.2/Music /home/dbott/Music cifs credentials=/root/.credentials,iocharset=utf8,file_mode=0777,dir_mode=0777 0 0 

//192.168.1.2/dbott /home/dbott/Data cifs credentials=/root/.credentials,iocharset=utf8,file_mode=0777,dir_mode=0777 0 0

//192.168.1.2/Archive /home/dbott/Archive cifs credentials=/root/.credentials,iocharset=utf8,file_mode=0777,dir_mode=0777 0 0



The only issue that I encountered was with regards to UIDs. My user account on Ubuntu (dbott) has a UID of 1000, while my user account on the NAS has a UID of 1004. To fix this, I changed my Ubuntu UID to match the UID on the Netgear NAS using the following command:

Code:

[quote]sudo usermod --uid 1004 dbott[/quote]

After a couple of minutes and a reboot, everything was working properly.

Original Post: October 2006

I purchased a NexStar LX NAS device and wanted to mount some of the shares on my linux computers. I configured my NAS device with a static IP (192.168.1.2) and created a number of shares to store my data. This process can be used to mount any SMB or Windows shared folder:

1. Install 'smbfs' & 'smbclient' (Samba File System & Samba client)

Code:

sudo apt-get install smbfs smbclient


After installing the above, issue the command smbclient -L 192.168.1.2 -U% to generate a list of available shares (replace 192.168.1.2 with the IP or name of your SMB server):

Code:
dbott@thedrake:~$ smbclient -L 192.168.1.2 -U% 


2. Create new folder for the 'mount point'. In my case, I wanted the shared music folder to be mounted to the following location /home/dbott/music

Code:

cd ~ mkdir music 


3. Mounting the share from the command line (to verify that it works):

Code:

sudo smbmount //192.168.1.2/Music /home/dbott/music -o username=dbott,password=mysecretpassword,iocharset=utf8 


4. Un-mounting the share from the command line:

Code:
sudo smbumount /home/dbott/music 


5. Add the mount point to fstab (making it 'automatic'):

The unsafe way (fstab is world-readable, meaning that anyone can see your SMB username and password):

Code:

//192.168.1.2/Music /home/dbott/music smbfs auto,username=dbott,password=mysecretpassword,uid=1000,umask=000,user 0 0 

The better way (storing your username & password in a file only readable by root):

Code:

//192.168.1.2/Music /home/dbott/music smbfs auto,credentials=/root/.credentials,uid=1000,umask=000,user 0 0 


/root/.credentials is a text file that contains your smb username and password.

To create the file, type:

Code:

sudo gedit /root/.credentials 


and add the following text:

Code:

username=your_smb_username password=your_smb_password 


Now, make the file only readable by root:

Code:

sudo chmod 600 /root/.credentials 


6. At this point, you can either reboot or reload your fstab:

Code:

sudo shutdown -r now 


Code:

sudo mount -a 7. 


Now, when I browse to /home/dbott/music, I have access to all the shared MP3s on my NAS device.

-Dave
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
局域网文件共享是指在一个局域网内,通过特定的软件或协议,将存储在不同设备中的文件进行共享和访问的过程。CSDN是中国最大的IT技术社区,也提供了局域网文件共享的解决方案。 在局域网中,多台计算机可以通过路由器或交换机连接在一起,形成一个内部网络。通过CSDN提供的文件共享功能,用户可以在局域网内直接访问其他设备上的共享文件,无需通过互联网或外部服务器。 CSDN的文件共享功能通常需要安装相应的软件或配置特定的协议。用户可以在CSDN的官方网站下载和安装相关软件,然后在计算机上设置共享文件夹。将需要共享的文件夹设置为共享状态后,其他局域网内的计算机就可以通过CSDN提供的功能进行访问了。 局域网文件共享的好处是可以提高团队协作的效率。例如,一个团队成员在自己的电脑上更新了某个文件,其他成员可以通过局域网文件共享功能迅速获得最新版本的文件,避免了使用传统的复制和传递文件的方式。 此外,局域网文件共享也可以增强数据的安全性。由于仅在局域网共享文件,而不是通过互联网,因此可以减少外部黑客或不明访问的风险。 总之,局域网文件共享通过CSDN的解决方案,可以帮助团队提高工作效率和数据安全性,对于需要频繁共享文件的团队来说是一个非常有效的工具。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值