Mount CIFS shares
From TheLinuxVault
Shared folders that use the SMB/CIFS protocol (i.e. Samba shares, Microsoft Windows shares) can be mounted on the filesystem. This is the Linux equivalent of mapping a network drive on Windows.
To open up fstab for editing in GNOME, press Alt+F2 and type
gksu gedit /etc/fstab
In KDE, press Alt+F2 and type
kdesu kwrite /etc/fstab
Contents |
[edit] Column 1: What to mount
Column 1 should have the name of the server and share, as in:
//spaceship/files //192.168.1.2/Documents
If the share name contains spaces, replace them with \040, as in:
//musicman/My\040Music
If you know that the IP address of the server within your network is static (doesn't change), use it instead of the hostname, as it is more reliable.
[edit] Column 2: Where to mount it
Column 2 will be the folder on your system where the share is mounted. This is usually a folder inside /media or /mnt, such as:
/media/myshare /media/music /media/spaceship/files
Make sure these folders exist first. To open a file manager as root in GNOME, press Alt+F2 and type:
gksu nautilus /
or for KDE:
kdesu konqueror /
[edit] Column 3: Filesystem type
In our case, Column 3 should usually say:
cifs
If you experience problems with cifs, install the smbfs package (on Debian/Ubuntu) and change it to say
smbfs
[edit] Column 4: Options
Multiple mounting options go in column 4, seperated by colons and in the form
option=value
The most common cifs options are:
- username - your username on the server
- password - your password on the server (if your shared folders are password-protected)
- uid - the ID of the user on your Linux machine who "owns" the shared folder
- gid - the ID of the group on your Linux machine who "owns" the shared folder
- umask - deals with file permissions
If you are using Ubuntu/Debian, I recommend your options include:
umask=007,gid=46
This will give read/write permissions to the "plugdev" group (which you are probably a part of) and no permissions to other users. This is the same as what Ubuntu uses for FAT32 and NTFS drives.
Another way to approach this would be using:
uid=1000,gid=1000
This way, you (assuming you are uid #1000, the user made at install time) can read and write, and everyone else can just read.
If you put it all together, an example options column might be:
umask=007,gid=46,username=Owner,password=parfait
[edit] Columns 5 and 6
Columns 5 and 6 should be 0, as we are mounting a network filesystem.
[edit] Examples
//downstairs/Documents /media/sharedstuff cifs umask=007,gid=46,username=Andy 0 0
This line mounts the folder "Documents" from the computer "downstairs" (with user "Andy") onto the folder "/media/sharedstuff", and lets anybody in group 46 (plugdev) write to it.
//192.168.1.2/My\040Music /media/music cifs uid=1000,gid=1000,username=Owner 0 0
This line mounts the folder "My Music" from the computer with the IP address 192.168.1.2 (with user "Owner") onto the folder "/media/music", and lets user 1000 (probably you) write to it.

