Last modified on January 18th, 2022 at 02:44 pm
Tutorial To Mount Windows Share On Ubuntu 22.04 LTS Operating System.
We will use CIFS or Common Internet File System in Ubuntu to access a particular mount point on a windows share. This tutorial will go through all steps of installing and mounting the Windows Share on Ubuntu Linux.
How To Mount Windows Share On Ubuntu 22.04 LTS
Install CIFS on Ubuntu operating system
Run the following commands in Ubuntu to install a common internet file system:
Install the cifs-utils package on Ubuntu Linux by using the following command line
sudo apt-get update sudo apt-get install cifs-utils
Now, let’s go through the process for manually and automatically mounting windows share on Linux.
Creating a directory on your Ubuntu by the name winshare under /mnt
sudo mkdir /mnt/winshare
Note: /mnt/winshare is the mount point of the remote windows share.
Windows share can be mounted on your Ubuntu with the CIFS option of the mount command.
sudo mount -t cifs -o username=$windows_username,password=$windows_username_password //WIN_SHARE_IPAddressofthewindows/$shared_name /mnt/winshare
If the $windows_username is in a windows domain, you need to specify the domain, run the following command to do that.
sudo mount -t cifs -o username=$windows_username,password=$windows_username_password,domain=$windows_domain_name //WIN_SHARE_IPaddressofthewindows/$shared_name /mnt/winshare
Once the windows share is successfully mounted, you can use command df -h to verify the mounting windows share in Linux.
df -h Filesystem Size Used Avail Use% Mounted on udev 3,9G 0 3,9G 0% /dev tmpfs 787M 2,2M 785M 1% /run /dev/sda2 450G 23G 405G 6% / tmpfs 3,9G 705M 3,2G 18% /dev/shm tmpfs 5,0M 4,0K 5,0M 1% /run/lock tmpfs 3,9G 0 3,9G 0% /sys/fs/cgroup //192.168.1.10/sharedfolder 300G 5,7G 295G 2% /mnt/winshare
Create a CIFS credentials file: /etc/cifs-credentials now with the following commands:
username = $windows_username password = $windows_username_password domain = $windows_domain_name
You also need to grant permission to read and write to the credentials file:
sudo chmod +rw /etc/cifs-credentials
Now, we can mount the share using credentials with commands as follows:
sudo mount -t cifs -o credentials=/etc/cifs-credentials //WIN_SHARE_IP/$shared_name /mnt/winshare
The drawback of the manual mount is that when you reboot your Linux machine, the shares will be lost. You need to configure the file /etc/fstab that contains the necessary configuration that allows automatically mount cifs permanently in Linux.
sudo vim /etc/fstab
Now add the following line to the file.
//WIN_SHARE_IPaddress/$shared_name /mnt/winshare cifs credentials=/etc/cifs-credentials,file_mode=0755,dir_node=0755 0 0
Run the command to mount all the entries listed in /etc/fstab
sudo mount -a
If you want to unmount a share, use the umount command:
sudo umount /mnt/winshare