Linux - Samba - How to mount/map a Windows Share on Linux

> Operating System - Kernel (Windows, Unix, Linux) > Linux / Unix

1 - About

Often you use a central Windows repository to save your installation file. In order to make them available to Linux, you can mount a Windows Share instead of to copy them.

If you want to “map a drive” from a Linux computer to a shared folder on a Windows computer or a shared folder on a Linux computer, you use samba.

Advertising

3 - Steps

3.1 - Verify that you see the shares

 
[[email protected] mnt]# smbclient -L rixni02 -U gerardnico
Password:
Domain=[RIXNI02] OS=[Windows 7 Home Premium 7601 Service Pack 1] Server=[Windows 7 Home Premium 6.1]

        Sharename       Type      Comment
        ---------       ----      -------
        ADMIN$          Disk      Remote Admin
        C$              Disk      Default share
        E$              Disk      Default share
        F$              Disk      Default share
        IPC$            IPC       Remote IPC
        kiosque         Disk
        Users           Disk
        video           Disk
Domain=[RIXNI02] OS=[Windows 7 Home Premium 7601 Service Pack 1] Server=[Windows 7 Home Premium 6.1]

3.2 - Mounting the Windows Shared Folder

Run the following command to mount the shared folder to a local path:

mount –t cifs –o username=myUsername,password=MyPassword //WindowsHost/WindowsSharedFolder /myMountFolder/MyMountPoint

Example:

mkdir /mnt/kiosque
mount -t cifs -o username=gerardnico,password=MyPassword //rixni02/kiosque /mnt/kiosque

Optional: Create a symbolic link to the mounted drive:

ln -s /myMountFolder/MyMountPoint /PathOfSymlink

3.4 - Mounting Automatically

  • Create a credential file /root/smbpass.txt
username=MyUsername
password=MyPassword
chmod 600 /root/smbpass.txt
# mounting cifs
//HostName/MyShare  /mnt/MyMountPoint  cifs    credentials=/root/smbpass.txt 0   0
  • Test it (You must get no error)
mount //HostName/MyShare
  • Show it:
[[email protected] ~]$ df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                      80370408  16157412  60064568  22% /
/dev/sda1               101086     12583     83284  14% /boot
tmpfs                  2172152   1030132   1142020  48% /dev/shm
//rixni02/kiosque    976759804 172971968 803787836  18% /mnt/kiosque
Advertising

4 - Support

4.1 - mount: unknown filesystem type 'smbfs'

use cifs instead

4.2 - tar: Cannot open: Cannot allocate memory

You may get this error when your untar a file through cifs.

tar: ./i9Pi/jre/README: Cannot open: Cannot allocate memory
tar: ./i9Pi/i9Pi.bin: Cannot open: Cannot allocate memory

Solution, on the Windows plateform:

  • Set the following registry key to ’1′:
HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\LargeSystemCache
  • Set the following registry key to ’3′:
HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters\Size
  • Restart the “Server” Service

Credits: Windows 7 Nonpaged Pool Srv Error 2017

os/linux/samba_mount_windows_share.txt · Last modified: 2018/09/16 12:42 by gerardnico