How to Mount Samba or Windows Shares at Boot Time via /etc/fstab

I will be cleaning up this article this week. I published it early for a friend who needed the info. I originally posted this on www.linuxquestions.org

I used smb4k when I first came back to Linux - I looked for an SMB utility that worked because at the time KDE's SMB browser/mounting mechanism was very flaky.
What I found was that smb4k does work, but it is very buggy, has memory leaks, high CPU utilization, and will sometimes hang during the unmounting process. KDE has since been fixed and it works very, very well, but when working in development environments on shares it's far easier to have the share bound to a mount point (e.g,, have it mounted) so I went back to old school shell prompt even for daily tasks.
With that said, smb4k is nothing more than a front end to smbmount and smbumount. However I use mount/umount since it allows me to provide additional options to the mount in addition to smbfs'
How to mount from a shell prompt using mount:
In this example: \\winserver\public used to be P: on Windows
\\winserver is the server hostname, \public is the sharename
active directory username = kim@domain.local
active directory password = foo
/mnt/public will be the mount point, with attributes drwxrwxrwx (777)
1. First create or choose your mount point, for example, I created /mnt/public with permissions of 777 for what USED to be my P: drive in Windows nomenclature
2. type the following (as root or su to root):
    code:
mkdir /mnt/public
chmod -R 777 /mnt/public
mount //winserver/public /mnt/public -t smbfs -o username=kim,password=foo -o gid=users,dmask=777,fmask=777,rw
This mounts the \\winserver\public share on /meow using the smbfs files
I used smb4k when I first came back to Linux - I looked for an SMB utility that worked because at the time KDE's SMB browser/mounting mechanism was very flaky.
I used smb4k when I first came back to Linux - I looked for an SMB utility that worked because at the time KDE's SMB browser/mounting mechanism was very flaky.
What I found was that smb4k does work, but it is very buggy, has memory leaks, high CPU utilization, and will sometimes hang during the unmounting process. KDE has since been fixed and it works very, very well, but when working in development environments on shares it's far easier to have the share bound to a mount point (e.g,, have it mounted) so I went back to old school shell prompt even for daily tasks.
With that said, smb4k is nothing more than a front end to smbmount and smbumount. However I use mount/umount since it allows me to provide additional options to the mount in addition to smbfs'
How to mount from a shell prompt using mount:
In this example: \\winserver\public used to be P: on Windows
\\winserver is the server hostname, \public is the sharename
active directory username = kim@domain.local
active directory password = foo
/mnt/public will be the mount point, with attributes drwxrwxrwx (777)
1. First create or choose your mount point, for example, I created /mnt/public with permissions of 777 for what USED to be my P: drive in Windows nomenclature
2. type the following (as root or su to root):
    code:
mkdir /mnt/public
chmod -R 777 /mnt/public
mount //winserver/public /mnt/public -t smbfs -o username=kim,password=foo -o gid=users,dmask=777,fmask=777,rw
This mounts the \\winserver\public share on /meow using the smbfs filesystem, using the Active Directory (Windows) username kim, password foo, making all newly created files under the users group, and applying permissions of 777 (world, group, and user-writable, readable, executable, etc).
Naturally once you get the knack of mounting the share, you will want to knock the permissions down only to what you need, but for the short time you are staging (testing) this process you can use the open permissions to test creation/deletion of directories and files as a normal user.
What I found was that smb4k does work, but it is very buggy, has memory leaks, high CPU utilization, and will sometimes hang during the unmounting process. KDE has since been fixed and it works very, very well, but when working in development environments on shares it's far easier to have the share bound to a mount point (e.g,, have it mounted) so I went back to old school shell prompt even for daily tasks.
With that said, smb4k is nothing more than a front end to smbmount and smbumount. However I use mount/umount since it allows me to provide additional options to the mount in addition to smbfs'
How to mount from a shell prompt using mount:
In this example: \\winserver\public used to be P: on Windows
\\winserver is the server hostname, \public is the sharename
active directory username = kim@domain.local
active directory password = foo
/mnt/public will be the mount point, with attributes drwxrwxrwx (777)
1. First create or choose your mount point, for example, I created /mnt/public with permissions of 777 for what USED to be my P: drive in Windows nomenclature
2. type the following (as root or su to root):
I used smb4k when I first came back to Linux - I looked for an SMB utility that worked because at the time KDE's SMB browser/mounting mechanism was very flaky.
What I found was that smb4k does work, but it is very buggy, has memory leaks, high CPU utilization, and will sometimes hang during the unmounting process. KDE has since been fixed and it works very, very well, but when working in development environments on shares it's far easier to have the share bound to a mount point (e.g,, have it mounted) so I went back to old school shell prompt even for daily tasks.
With that said, smb4k is nothing more than a front end to smbmount and smbumount. However I use mount/umount since it allows me to provide additional options to the mount in addition to smbfs'
How to mount from a shell prompt using mount:
In this example: \\winserver\public used to be P: on Windows
\\winserver is the server hostname, \public is the sharename
active directory username = kim@domain.local
active directory password = foo
/mnt/public will be the mount point, with attributes drwxrwxrwx (777)
1. First create or choose your mount point, for example, I created /mnt/public with permissions of 777 for what USED to be my P: drive in Windows nomenclature
2. type the following (as root or su to root):
    code:
mkdir /mnt/public
chmod -R 777 /mnt/public
mount //winserver/public /mnt/public -t smbfs -o username=kim,password=foo -o gid=users,dmask=777,fmask=777,rw
This mounts the \\winserver\public share on /meow using the smbfs filesystem, using the Active Directory (Windows) username kim, password foo, making all newly created files under the users group, and applying permissions of 777 (world, group, and user-writable, readable, executable, etc).
Naturally once you get the knack of mounting the share, you will want to knock the permissions down only to what you need, but for the short time you are staging (testing) this process you can use the open permissions to test creation/deletion of directories and files as a normal user.
    code:
mkdir /mnt/public
chmod -R 777 /mnt/public
mount //winserver/public /mnt/public -t smbfs -o username=kim,password=foo -o gid=users,dmask=777,fmask=777,rw
This mounts the \\winserver\public share on /meow using the smbfs filesystem, using the Active Directory (Windows) username kim, password foo, making all newly created files under the users group, and applying permissions of 777 (world, group, and user-writable, readable, executable, etc).
Naturally once you get the knack of mounting the share, you will want to knock the permissions down only to what you need, but for the short time you are staging (testing) this process you can use the open permissions to test creation/deletion of directories and files as a normal user.
ystem, using the Active Directory (Windows) username kim, password foo, making all newly created files under the users group, and applying permissions of 777 (world, group, and user-writable, readable, executable, etc).
Naturally once you get the knack of mounting the share, you will want to knock the permissions down only to what you need, but for the short time you are staging (testing) this process you can use the open permissions to test creation/deletion of directories and files as a normal user.
Create a quick script similar to the following in /etc/init.d (I named mine mountsamba)
    code:
#! /bin/sh
# mountsamba
### BEGIN INIT INFO
# Provides: mountsamba
# Required-Start: smb #this tells insserve how to order the script
# X-UnitedLinux-Should-Start:
# Required-Stop:
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Description: mounting drives kim defined in fstab
### END INIT INFO
echo -n "Mounting /mnt/public . . ."
mount /mnt/public
echo "Mounted."
echo -n "Mounting /mnt/linuxweb . . ."
mount /mnt/linuxweb
echo "Mounted."
echo -n "Mounting /mnt/software. . ."
mount /mnt/software
echo "Mounted."
chmod mountsamba with a+rx (or you can use the numerical)
now go to /etc/init.d and run this command:
    code:
 insserv mountsamba
NOW when you reboot it will mount automagically. I'm really sorry I forgot about this step. My machine was Just Working(tm) and when I had to reconfigure a few things today I noticed that script I'd created