Coder, Entrepreneur, Blogger, and Coffee Addict
It is often required to mount a shared Windows drive instead of browsing the share through nautilus or smbclient. For example you may want to set up a backup script that copies a local linux directory and uploads it to a windows share each night. This can be easily accomplished with a simple bash script; however, the script needs to be able to browse to the share through a normal directory. Since the bash script can only interact with regular directories we have to simulate a directory by mounting the share as a pretend linux filesystem (smbfs). This is what we are going to do today.
Ubuntu/Debian – sudo apt-get install samba
Gentoo – emerge samba
Ubuntu/Debian – sudo apt-get install smbfs
Gentoo – emerge smbfs
As root:
mkdir /mnt/windowsShare
nano -w /etc/fstab
Add the following line near the bottom
//192.168.x.x/My\040Share /mnt/windowsShare smbfs username=user,password=pass 0 0
Replace 192.168.x.x with the host’s ip address (Find Your IP Address)
Replace My\040Share with the share name (the ‘\040‘ is the linux way of making a space.)
Replace user with your actual username and pass with your password.
Now the next time you boot your computer you will automatically have a directory ‘/mnt/windowsShare‘ that will contain the files/folders from the host computer. You can interact with this directory just as you would with any other directory.
To force the change now with having to reboot type this command:
sudo mount -a
This command will simulate a reboot by remounting everything in fstab that isn’t mounted.
Pingback: Introduction to fstab
© 2011 All rights reserved