源地址:http://ubuntuforums.org/showthread.php?t=280473&
Update: November 18, 2007

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
(鱼漂提醒:-o参数,还可以带上user=administrator,iocharset不是cp936,而是utf8)
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:
 
sudo usermod --uid 1004 dbott
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%

       Sharename       Type      Comment
       ---------       ----      -------
       PUBLIC          Disk
       Data            Disk
       Archive         Disk
       Music           Disk
       IPC$            IPC

       Server               Comment
       ---------            -------

       Workgroup            Master
       ---------            -------
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,uid=1000,mask=000
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.
OS | 评论(0) | 引用(0) | 阅读(7601)