2011年7月25日 星期一

Ubuntu auto mount SMB folder

First you have to install smbfs:

sudo apt-get install smbfs

Then create a folder inside of the /media directory to mount the share on:

sudo mkdir /media/Storage

then you can run the following command to mount a share manually:

sudo mount -t smbfs //fileserver/Storage /media/Storage -o uid=USER,gid=users

Note: Change USER to your linux username. The uid=USER,gid=users is important because if you dont use that, only root will have access to write files to the mounted share.

Or you can edit the mount list in /etc/fstab to have the drive mount on boot

sudo gedit /etc/fstab

And add this line to the bottom of the fstab file, but change //fileserver/Storage to the path to your share on your server.

//fileserver/Storage /media/Storage smbfs credentials=/.smbcredentials,uid=USER,gid=users 0 0

In the above line change USER to your user account in both spots. Before this will work you also have to create the .smbcredentials file in the above users home directory.

sudo gedit ~/.smbcredentials

Add the following information to the file, but change Guest to your SMB username and add your SMB password.

username=Guest
password=

If you have a permission problem , you can add "noperm" .

Now you got it.