As I’m fairly new to Linux, it was a bit of a venture to get the following to work.
I have an OpenSUSE 12.2 with KDE4 installation as server, and I want to access a share through my Windows 7 client.
Setting up Samba with netbios name through YaST was fairly easy and when I enter \opensuse I can see the shares. (note, this is not the real computername, but makes it easier to understand). When I click on my shared folder a login prompt shows. Trying to login with root or my installation’s super user and password combination did not allow me to get access.
What you have to do at this point is actually add a user to Samba, given that you haven’t set it to use an LDAP server, but just the default tdbsam database.
To do this, open a terminal session and enter the following:
sudo smbpasswd -a [username]
After the user is added, you should be able to log into the share. If you set the username and password identical to your Windows 7 login client (yes you do need a password set for your windows 7 installation, but since you can enable auto-login on windows 7, there’s no reason why you couldn’t make this easy for you. A login prompt should not appear anymore. (I am not sure if with anonymous (guest access set) the login prompt will disappear too, but while testing, I have played with it and that login kept being seen.
Now that we see our shares, I wanted to secure some of my data in a better way.
During the installation, I have setup my 2 identical harddisks as follows:
Aside from the swap and root partition, I added a 100 GiB partition on both harddrives, and another with the remaining space, but did not mounted them. Then I created 2 RAID mount points: /home (set as RAID0, mirrored) for the 100 GiB partition and /fileserver for the remaining space (set as RAID 1, striped).
On my fileserver, I have a projects directory that has everything related to my projects:
/fileserver/projects
now comes the fun part. I have one project that is important to me that I want to be on both harddrives (so it must be on the mirrored partition)
I created a folder mirrored on my /home partition for this kind of stuff using: mkdir /home/mirrored
I then changed owner to my superuser using: sudo chown [username] /home/mirrored
I then moved the important project to my /home/mirrored folder
So my dir list is as follows:
/fileserver/project/project1
/fileserver/project/project2
/home/mirrored/important_project
Now obviously, I do want to see my important_project in the project folder. To do that, you have to create a symbolic link (in windows 7 its mklink /d)
to do that, do the following from terminal:
cd /fileserver/project
ln -s /home/mirrored/important_project important_project
Now, from linux its exactly as you want. The dirlist shows you this:
/fileserver/project/project1
/fileserver/project/project2
/fileserver/project/important_project -> /fileserver/project/project2/home/mirrored/important_project
/home/mirrored/important_project
If you have shared project through Samba, you will also see the 3 folders. YAY!
But now comes the catch. You can open project1 and project2, but as soon as you go into important_project, you get an “Windows cannot access this folder” error
Here is what you need to do.
First, if you have shared the project directory using the Dolphin filemanager, right click folder, properties, share, [x] Share this folder with samba; you have to undo this change. You have to share your folder through the samba interface, which can be done either through YaST->Samba, or by editing the smb.conf file directly. To make the symbolic link (symlink) to work, we will have to edit the smb.conf file anyway, so lets go with this approach directly.
Go to your terminal once more and type the following:
sudo edit /etc/samba/smb.conf
You now get a texteditor. Press the Insert key on your keyboard to start editing.
Navigate to your [global] section.
Add a new row by pressing enter at the end of one of the configuration lines, and type this:
unix extensions = No
Now, we need to add your share if you haven’t yet already done so through Samba itself.
Scroll down and create a new section that looks as follows:
[Projects]
comments = My Projects
inherit acls = Yes
path /fileserver/project
read only = No
wide links = Yes
follow symlinks = Yes
The wide links = Yes and follow symlinks = Yes are needed for your share if you want symlinks to work. Now, press the Escape key, to exit editing mode, then type : to get the editor’s console and type x to save and exit. Note, if you have not used sudo to edit this file, it will say you cannot save your changes and since you made any, you will not be able to get out of the editor without killing the terminal window. (at least I couldn’t). So if you have not used sudo to open the file, but you have not yet made changes, you can still :q to exit.
Now, we have to restart Samba.
In terminal, type the following:
sudo /etc/init.d/smb reload
This is it. One last note, and this is crucial! Windows will not directly pick up the changes. It doesn’t take long, but its not instant. I was trying to fix my issue which was that I kept using follow wide links = Yes, and as such it was not working. When I removed the follow and saved, and then restarted samba, windows still said it was not working. It took about a minute before windows catched on. I have a feeling this is only for when you make small changes to existing shares. So if its not working for you and you are positive it should, just wait or in worst case reboot your windows 7 machine.