Forward: mounting Windows SMB file shares using CIFS

Source: Internet
Author: User

Reference: http://ubuntuforums.org/showthread.php? T = 288534

In the world of Linux and Samba file shares, there are essential two ways to mount your smb shares. of course, you can always access your shares via the places-> network dialog, where you can go to town looking through your shared drives. of course, this has some major downfalls. primarily, most ap Plications don't recognize the network folders as legitimately mounted disks (because They're not ). in other words, try opening up a shared music file in audacious (or your favorite music player ). did it work? Well, if you're more clever than me, perhaps. the true way to handle your shared files is by mounting them. then we'll have a legitimately mounted drive, with which we can do whatever we want.

Like I said, there are two ways to mount your filesystem. the first is the original smbfs, and the latter is the newer and more preferred method of CIFS. while I originally used smbfs (it made sense, its name looks just like what I'm trying to mount), today (Nov 16,200 7), when I did the Ubuntu system update, everything went crazy. all of a sudden, my smbfs mounted drives ground to a halt-each request took about 1-2 minutes to fulfill. I cocould still browse the files quickly through places-> network, but my smbfs shares were crawler.

But then I remembered that there's an alternative, and now that I have it up and running, I can say that it's quite easy and quite fast. here's what you do:

Firs, We need to install CIFS, which comes right alongside smbfs. If you have smbfs, then you have CIFS. If you don't, open up a terminal and get it:

 
Sudo apt-Get install smbfs

Next, all mounted drives need to mount to some folder on your local drive. I prefer to mount mine in the/media folder, which makes sense, as your CDROM is mounted there along with other drives, including things like external and thumb drives. type the following, replacing my_share with whatever folder name you want your share to be (this doesn't matter at all, it can be called anything and go anywhere ).

 
Sudo mkdir/Mount/my_share

Now, while we're re going to perform some permanent mounts later (so that the disk mounts after a restart), let's start with a manual mount.

 
Sudo Mount-t cifs // 192.168.1.102/cmd_name/Media/my_share-O username = theuser, password = thepass, iocharset = utf8, file_mode = 0777, dir_mode = 0777

let me explain. the Mount-t cifs command simply instructs the system to mount the following parameters via CIFS. the next argument: // 192.168.1.102/inclu_name consists of 2 parts. the first is the IP address of the computer with the shares. this can also be "Net BIOS name", but since that was giving me a headache, I simply used the IP address. the second part: parameter _name is the name of the share on the hosting computer. under places-> network, you should see the computer that you are trying to connect. if you double click into that computer, you will see (You may have multiple) the name of the share (something like my-external-drive perhaps ). use that value in place of partition _name.

the next part of the command:/Media/my_share is that directory that we created earlier. after the mount is successful, the contents of the share will be accessible via this directory.

finally, everything that comes after the-O are the options. first, we have the username and password. these shoshould be set to the username and password of the Windows computer to which you are trying to connect. for me, my "Windows" computer was a Windows computer at all, but rather an Ubuntu server (we have authentication types of computers needing to connect to it ). in this case, I used the username and password of my Ubuntu use. exact same idea. the things after that shouldn't need modification. they set the charset to utf8 (so that we're nice to foreign character sets), and make the Mount read/write.

now, if it worked, you shocould see your mount right on the desktop. browse through it, play music from it, watch movies from it (network speed permitting ). here are some common errors:

    • Mount error: can not change Directory into Mount target...-Either you didn't create your/Media/my_share directory or specified it wrong in your mount command.
    • Mount error 13 = permission denied-your username and password are being rejected. Try some other combinations
    • Mount Error 6 = no such device or address-the specified _name that you specified in your mount command is not being found on the host computer. browse the network, find that computer, and check to make sure you see the exact share name.

 

We now have proof of concept, but we want the drive to mount automatically on restart. first, let's unmount the drive so that we can test our Remounting of it later. the following shoshould do it.

 
Sudo umount // 192.168.1.102/cmd_name

The share shoshould 've disappeared from your desktop. important, we will use the/etc/fstab file to mount the share by inserting a similar command as abve into that file. this file can be read by anyone on your computer, which wocould mean that anyone cocould read the username and password you specify for you mount. if you don't care (Come on guys, care a little), then simply do the following:

Sudo nano/etc/fstab... and add the following to the bottom, updating as necessary: // 192.168.1.102/pai_name/Media/my_share CIFS username = theuser, password = thepass, iocharset = utf8, file_mode = 0777, dir_mode = 0777 0 0

For the rest of us who desire a little more security, the following is the clever way of hiding the username and password.

 
Sudo nano/root/. smbcredentialsand enter in the file: username = theuserpassword = thepass

Now, let's make sure only root can read this file:

 
Sudo chmod 700/root/. smbcredentials

Now, we simply need to replace the username and password portion of the fstab file with a handly credential option.

 
Sudo nano/etc/fstaband make your mount command look like this: // 192.168.1.102/share_name/Media/my_share CIFS credentials =/root /. smbcredentials, iocharset = utf8, file_mode = 0777, dir_mode = 0777 0 0

And we're done. you can now either restart to test, or simple run the following command, which remounts all the drives in the/etc/fstab file that are not currently mounted (very handy ):

 
Sudo Mount-

If you saw your share pop up on the desktop, then you're done. Your brand new CIFS file share will mount each time you boot up your computer.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.