X
Tech

Vista Hands On #15: Access shared folders from a Linux machine, part 2

In the last installment of this series I showed how to quickly (and temporarily) mount a shared folder on a Windows Vista machine from a Linux PC in read-only mode. But what if you want the Vista shared folder to be permanently available to all users, in read-write mode? Here are the step-by-step instructions.
Written by Ed Bott, Senior Contributing Editor

In the last installment of this series I showed how to quickly mount a shared folder on a Windows Vista machine from a Linux machine (specifically, from one running Ubuntu 6.10). This solution works if you just want to read files on the Vista PC and you don’t mind re-entering the mount command the next time you reboot your Linux PC. But what if you want the Vista shared folder to be permanently available to all users, in read-write mode?

Here’s how. As in the previous post, these instructions assume that you’ve set up a password-protected shared folder on the Vista machine in a non-domain environment, that you have already installed Samba server v3.0.22 or later and smbfs on the Linux machine, and that you’ve created a Samba user account and password. (For details on how to perform these last two tasks, see Vista Hands On #13: Connect to a shared folder on a Linux machine.) All of the following steps are performed on the Linux machine.

1. Choose a name to use for the shared folder on your Linux machine, such as vista_public. Open a Terminal window and issue the command sudo mkdir /mnt/vista_public (if you chose a different name to identify the shared folder, substitute it for vista_public). This creates a directory that will be used as the mount point for your shared folder.

2. Using a text editor, create a plain text file containing two lines:

username=windows_username
password=windows_password

Substitute your actual Windows username and password for the italicized text. Save the file in your home folder as .smbpasswd (don't forget the dot at the beginning of the filename, which makes the file hidden). Finally, change the permissions on the file so only you can open and change it by issuing the following command in a Terminal window:

chmod 600 .smbpasswd

3. On the Linux machine, open /etc/fstab in a text editor. (On Ubuntu, I used the command sudo gedit /etc/fstab. You can use another editor if you prefer.)

4. At the end of the file, add a new line containing the following:

//vista_pc_name/share_name   mount_folder_name smbfs credentials=/home/linux_username/.smbpasswd,uid=linux_username,gid=users  0 0

Use the UNC path for the Windows share, and replace mount_folder_name with the full path of the folder you created in Step 1 (in this example, /mnt/vista_public). Substitute your Linux username for the values in red. These credentials will be passed to the Vista machine. (Note: there’s no space after the comma and before the uid and gid.) [Update: Thanks to Jeremy Allison in the comments of the previous post for pointing out that smbfs is deprecated and no longer maintained. You can safely substitute cifs for smbfs in the fstab entry.] 

5. Save the file and, in the Terminal window, issue the command sudo mount -a.

6. Create a link in your Home folder or on the desktop to the location you created in Step 1 (in this example, /mnt/vista_public) and give the link a descriptive name. Click OK to save it.

You now have a shortcut (link, in Linux-speak) that you can use to to access files in your shared Vista folder. If you find that subfolders in the shared folder are set as read-only, right-click the folder on the Linux box, choose Properties, and click the Permissions tab.

For more details, read this excellent tutorial at justlinux.com, which was one of my primary sources for getting up to speed on these features.

Editorial standards