automating smbmount
automating smbmount
>> Running smbmount manually is unacceptable ...
So here's how to get it done at boot time OR to put it into a safe script
for use when Windows is available.
Most modern Linux systems use the /etc/rc system to control system startup.
The system start is controlled using the /etc/inittab to process runlevels
The runlevel scripts are in /etc/rc.d/ -- if you use
ls -lF /etc/rc.d (that's a lower case L)
you will see directories rc.X.d/ (where X is 0->6) and the rc.local* executable file.
We need the /etc/rc.d/rc.local script to be modified.
I have modified the RC.LOCAL.TXT attachment for you
On windows, you can edit this file with notepad; locate and edit ONLY the following
## we use a suffix to allow multple mounts
mountpointA='/laptop';
sysnameA='yourSysName';
sharenameA='shareddocs';
winuserA='owner';
winpwdA='ownerpassword';
winmodeA='rw';
(1) mountpointA is where the Windows Share will be located on your Linux filesystem
(2) sysnameA is the name of the Windows System which as
(3) the sharenameA folder
(4) winuserA is the owner of that folder
(5) and windpwdA is the access password
(6) windmodeA is either rw or ro
Be sure there are no spaces and that you keep the QUOTEs as shown.
save this file as rc.local.txt into a directory on Windows which will be mounted on Linux
Here's the install process to get this active on Linux
- Boot Linux and login as root
- cd to the /etc/rc.d/
- manually mount the windows share
smbmount //sysname/sharename /mountpoint -o username=owner,password=pass,rw
- copy your modified rc.local.txt to the linux system like this
cp /laptop/rc.local.txt .
As Windows has \r\n as line terminators and Linux can only use \n,
- correct the script like this
cat rc.local.txt | sed -e 's/\r//' >rc.local.txt2
- save the original rc.local with cp rc.local rc.local_v1 and the install your new script
cp rc.local.txt2 rc.local
To reset the system and mount using this script
- ./rc.local stop
- telinit 1
- telinit 3
(a) will dismount the first manual smbmount used to get access to the rc.local.txt
(b) will put the system into Single User Mode
(c) will continue back into Multi User Mode just like would be done from a BOOT of Linux
and you will need to login again (root is not required)
From a Terminal Session, you can see the Windows Share with ls /laptop or whatever you used
as the mountpoint.
In the GUI system, use the Computer icon->Filesystem and you will find /laptop listed and accessible there.
Cleanup:
1) on the Windows Share where you saved rc.local.txt --- delete that file to secure the password
2) on Linux, cd /etc/rc.d/
and set the permissions using su -c 'chmod 750 rc.local*'
you'll need the root password