Walk through the process of sharing files between Windows and AIX by using CIFS to mount a Windows 7 network share onto an AIX system.
The Common Internet File System (CIFS) protocol allows file sharing between different operating systems. The most common use of CIFS is in mounting Microsoft Windows network shares onto UNIX/Linux systems, which in turn means you can mount Windows shares onto a AIX box. CIFS offers the same type of file-mode access as can be found in NFS. So why use CIFS instead of, say, FTP? FTP is a transfer protocol, which is appropriate for pulling or pushing files around, but it isn't a file-sharing protocol. In contrast to FTP, the primary task of CIFS is to allow sharing, thus cutting down on network traffic.
Typical uses for Windows shares on an AIX box include:
- sharing documents between a single AIX box or geographically distributed users
- storing backups (because disk is cheap for Intel boxes, they’re economical backup repositories)
Once you’ve defined and mounted your network share, you can set it up to be mounted automatically when the system comes up, just as you'd do for normal file systems. In this article, I’ll show you how to create and mount a Windows 7 share on an AIX box.
Before you can mount a share, you must first do some pre-checks and gather information. On the Windows side, you'll perform these tasks:
- Confirm that you can resolve/ping the AIX box.
- Identify the name of the network share (i.e., directory) to export.
- Identify the workgroup name the Windows box belongs to.
- Identify the username/password that will have access to the share.
- Export the network share.
On the AIX side, you’ll need to perform these tasks:
- Confirm you can resolve/ping the Windows box.
- Install the CIFS filesets.
- Confirm that the device nsmb0 has been created and is available.
- Decide on your mount point, then create the directory.
On the Windows side, I’ve found that identifying the workgroup name of the Windows machine isn’t always necessary, depending on how you want to be authenticated—locally or remotely. In our example, authentication will be done via CIFS, so the workgroup name isn’t needed. Assuming these tasks have been completed, let's now walk through the procedure for using CIFS to mount a network share on an AIX box.
Getting Ready to Mount the Share
On the Windows side, define the user that will be used to authenticate to the share. In this example:
- The Windows user is sedon.
- The directory to share is E:\codes\EN_codes.
- The share is named EN_codes.
To share a Windows 7 directory, simply right-click the directory and click Properties, then select Sharing, then select a local user (sedon in this example) who has access to this share, then click OK. For access, include everyone.
To confirm that the share has been exported, use the Windows net share command to confirm the export. The net share command:
generates the following output, confirming that a Windows share has been exported:
ADMIN$ C:\Windows Remote Admin
C$ C:\ Default share
IPC$ Remote IPC
The command completed successfully.
When you create the mount for a Windows share on AIX, you can do so either via the command line or via the AIX System Management Interface Tool (SMIT, aka the smit command)—the choice is yours. I’ll demonstrate both methods. When using smit (smit cifs_fs) or the mkcifsmnt command, you can place the credentials that are parsed into the credentials file: /etc/cifs_fs/cifscred. Doing so allows the network share to be mounted without your having to provide the user credentials once the mount is initially mounted. AIX will look for a match in this file, then use these credentials to complete the mount process.
I think this is a good idea, because you don’t want a hanging file system "waiting to give up" when the system is coming up (or even worse, you don't want a situation in which the password has been changed and no one told you about it, or you've forgotten the password). So I’ll go with stored credentials in this article).
We should now have gathered all the information needed for a successful mount:
- Windows host: rumble
- Windows share: EN_codes
- Windows user: sedon
- Windows password: sedon345
- AIX mount point: /mnt/win/
The network share of rumble:EN_codes will mount over /mnt/win on the AIX box.
Mounting the Share
We’re now all set to perform the mount. Before we begin, we’ll confirm that the filesets and the device nsmb0 are available, as well as the mount point directory, using the command
bos.cifs_fs.rte 188.8.131.52 C F Runtime for SMBFS
bos.cifs_fs.smit 184.108.40.206 C F SMIT Interface for SMBFS
# lsdev |grep nsmb0
nsmb0 Available N/A
The special device nsmb0 is used to create a connection to the remote server when using CIFS.
Create the mount point next:
The next step is to run smit (smit cifs_fs, add cifs) and input the following values, most of which we determined earlier; Table 1 lists the smit options we'll use here.
Press Enter to initiate the process of smit creating the CIFS mount and then mounting it.
In the smit input fields shown in Table 1, note that the file's ownership is set to a user ID (UID) of 203 and a group ID (GID) of 1. In this example, user dxtans is UID 203 and GID 1 is staff. In addition, the permissions have been set to read/write/execute by everyone. The network share will also be mounted on a system restart.
The next step is to confirm that the network share has been mounted by running this command:
rumble:EN_codes 923779064 747202224 20% 0 0% /mnt/win
The command's output shows that the share has been mounted. Now let's check the files, using the following command:
# ls -l
-rwxrwxrwx 1 dxtans staff 1024 Nov 13 18:48 agel.txt
-rwxrwxrwx 1 dxtans staff 8912 Nov 13 18:49 fig_lop.txt
-rwxrwxrwx 1 dxtans staff 9 Nov 13 18:49 psot_hit.txt
-rwxrwxrwx 1 dxtans staff 4096 Nov 13 18:49 trell_pot.txt
We can also confirm the existence of an entry in /etc/filesystems using the following command:
dev = ENcodes
vfs = cifs
nodename = rumble/sedon
mount = true
options = uid=203,gid=1,fmode=777
account = false
To list the current CIFS mounts, run the lscifsmnt command:
Name Nodename Mount Pt VFS Size Options Auto Accounting
EN_codes rumble/sedon /mnt/win cifs -- uid=203,gid=1,fmode=777 yes no
Earlier in this article, I stated that you can automatically insert the user credentials into the file cifscred. The format of the file is windows_hostname/windows_user/encrypted_windows_user_passwrd. In our example, the current contents of the cifscred file are as follows:
If you opted to not store the credentials when the CIFS mount was created, but you've since decided you want to store them, you can use the mkcifscred command to add the credentials. Please note that you can’t add the same host/user that is already present, even if it’s using a different share. To add another credential from host rumble with the user and password seltop/mopte11, you could run the following command:
To remove the credentials, you use the rmcifscred command. For example, to remove the credentials I just added, I could run this command:
Adding a CIFS Mount from the Command Line
Now we’ll add a CIFS mount to the /etc/filesystems file using the mkcifsmnt in the following format:
-f <mount point>
-d <netshare name>
-h < windows host>
-B < add entry to /etc/filesystems and auto mount at system restart>
-p <windows user password>
-u < UID of who should own the files>
-g <GID of group who should own the files>
-x <file_permissions octal>
When you add a network share using the mkcifsmnt command, AIX doesn’t like it if the local mount point is already present, so don't bother to create it as described earlier. The following example creates and mounts the same share as done via smit, except this time the permissions are set to 775 instead of 777.
-c sedon -p sedon345 -u 203 -g 1 -x 775
If you get an error similar to "error connecting to...," check whether you can ping the server and that the Windows credentials are correct. Also check that the following ports are open on the Windows side: 137,138,139, and 445.
Finally, to unmount a CIFS-based file system, run the rmcifsmnt command.
To mount a CIFS mount directly from the command line using the same credentials as the previous examples, I could use the following:
Note that in the above mount command I've specified the domain name, which in this example is maps.
And there you have it: You've learned how to mount an AIX network share using CIFS—a pretty straightforward process.