@Manoj Agrawal Welcome to Microsoft Q&A Forum, Thank you for posting you query here!
You cannot mount a sub-folder. You need to mount the entire share.
If I cannot mount a sub folder (Azure File share in Linux) then, is it possible to mount the file share and then change directory in Linux machine to traverse to sub folder to place file? So, the answer to this question is. Yes, once you mount the file share, you can change directory to traverse to sub-folder and place file
Mount fileshare root [has one folder (dir1) and one file (file1)
azureuser@subm-ubuntu20:~$ sudo mount -t nfs submsapremium.file.core.windows.net:/submsapremium/nfs-share1 /mount/submsapremium/nfs-share1 -o vers=4,minorversio
n=1,sec=sys,nconnect=4
azureuser@subm-ubuntu20:~$ cd /mount/submsapremium/nfs-share1/
azureuser@subm-ubuntu20:/mount/submsapremium/nfs-share1$ ls
dir1 file1
I can create a folder, subfolder and file in the mountpoint
azureuser@subm-ubuntu20:/mount/submsapremium/nfs-share1$ cd dir1/
azureuser@subm-ubuntu20:/mount/submsapremium/nfs-share1/dir1$ ls
dir2 file file2 file3
azureuser@subm-ubuntu20:/mount/submsapremium/nfs-share1/dir1$ cd dir2/
azureuser@subm-ubuntu20:/mount/submsapremium/nfs-share1/dir1/dir2$ ls
file3
azureuser@subm-ubuntu20:/mount/submsapremium/nfs-share1/dir1/dir2$ mkdir dir3
azureuser@subm-ubuntu20:/mount/submsapremium/nfs-share1/dir1/dir2$ cd dir3
azureuser@subm-ubuntu20:/mount/submsapremium/nfs-share1/dir1/dir2/dir3$ touch file4
azureuser@subm-ubuntu20:/mount/submsapremium/nfs-share1/dir1/dir2/dir3$ ls
file4
I can also mount sub-folder if required and then create files and directories under the mountpoint
Below, I am just mounting the dir2 which is inside the dir1 -> inside root of the share. When I mount the subfolder, I can only see that folder and any child folders/files under the subfolder that is mounted.
azureuser@subm-ubuntu20:/mount/submsapremium/nfs-share1/dir1/dir2/dir3$ cd
azureuser@subm-ubuntu20:~$ sudo umount /mount/submsapremium/nfs-share1
azureuser@subm-ubuntu20:~$ ls
azureuser@subm-ubuntu20:~$ sudo mount -t nfs submsapremium.file.core.windows.net:/submsapremium/nfs-share1/dir1/dir2 /mount/submsapremium/nfs-share1 -o vers=4,minorversion=1,sec=sys,nconnect=4
azureuser@subm-ubuntu20:~$ ls
azureuser@subm-ubuntu20:~$ cd /mount/submsapremium/nfs-share1/
azureuser@subm-ubuntu20:/mount/submsapremium/nfs-share1$ ls
dir3 file3
azureuser@subm-ubuntu20:/mount/submsapremium/nfs-share1$ touch file5
azureuser@subm-ubuntu20:/mount/submsapremium/nfs-share1$ ls
dir3 file3 file5
azureuser@subm-ubuntu20:/mount/submsapremium/nfs-share1$ cd dir3/
azureuser@subm-ubuntu20:/mount/submsapremium/nfs-share1/dir3$ touch file6
azureuser@subm-ubuntu20:/mount/submsapremium/nfs-share1/dir3$ ls
file4 file6
azureuser@subm-ubuntu20:/mount/submsapremium/nfs-share1/dir3$ pwd
/mount/submsapremium/nfs-share1/dir3
azureuser@subm-ubuntu20:/mount/submsapremium/nfs-share1/dir3$ cd ..
azureuser@subm-ubuntu20:/mount/submsapremium/nfs-share1$ ls
dir3 file3 file5
For SMB share, you cannot mount the sub-folder, but once you have mounted the root of the file share , you should be able to create subfolders and files under that subfolder
Here, I am mounting the root of the smb share and also creating folders, sub-folders and files under the mountpoint
azureuser@subm-ubuntu20:~$ sudo mount -t cifs //submsapremium.file.core.windows.net/smbshare1 /mnt/smbshare1 -o credentials=/etc/smbcredentials/submsapremium.cred,d
ir_mode=0777,file_mode=0777,serverino,nosharesock,actimeo=30
azureuser@subm-ubuntu20:~$ cd /mnt/smbshare1/
azureuser@subm-ubuntu20:/mnt/smbshare1$ ls
subm-vng.zip
azureuser@subm-ubuntu20:/mnt/smbshare1$ mkdir dir1
azureuser@subm-ubuntu20:/mnt/smbshare1$ cd dir1
azureuser@subm-ubuntu20:/mnt/smbshare1/dir1$ touch file1
azureuser@subm-ubuntu20:/mnt/smbshare1/dir1$ mkdir dir2
azureuser@subm-ubuntu20:/mnt/smbshare1/dir1$ touch file2
azureuser@subm-ubuntu20:/mnt/smbshare1/dir1$ ls
dir2 file1 file2
azureuser@subm-ubuntu20:/mnt/smbshare1/dir1$ cd ..
azureuser@subm-ubuntu20:/mnt/smbshare1$ ls
dir1 subm-vng.zip
azureuser@subm-ubuntu20:/mnt/smbshare1$ mkdir dir3
azureuser@subm-ubuntu20:/mnt/smbshare1$ cd dir3
azureuser@subm-ubuntu20:/mnt/smbshare1/dir3$ touch file4
azureuser@subm-ubuntu20:/mnt/smbshare1/dir3$ ls
file4
azureuser@subm-ubuntu20:/mnt/smbshare1/dir3$ pwd
/mnt/smbshare1/dir3
azureuser@subm-ubuntu20:/mnt/smbshare1/dir3$ cd
azureuser@subm-ubuntu20:~$ sudo umount /mnt/smbshare1
If I directly try to mount a sub-folder, I get the error saying that path does not exist
azureuser@subm-ubuntu20:~$ sudo mount -t cifs //submsapremium.file.core.windows.net/smbshare1/dir2 /mnt/smbshare1 -o credentials=/etc/smbcredentials/submsapremium.cred,dir_mode=0777,file_mode=0777,serverino,nosharesock,actimeo=30
mount error(2): No such file or directory
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs) and kernel log messages (dmesg)
azureuser@subm-ubuntu20:~$ sudo mount -t cifs //submsapremium.file.core.windows.net/smbshare1 /mnt/smbshare1 -o credentials=/etc/smbcredentials/submsapremium.cred,dir_mode=0777,file_mode=0777,serverino,nosharesock,actimeo=30
azureuser@subm-ubuntu20:~$ cd /mnt/smbshare1/
azureuser@subm-ubuntu20:/mnt/smbshare1$ ls
dir1 dir3 subm-vng.zip
azureuser@subm-ubuntu20:/mnt/smbshare1$ cd dir3
azureuser@subm-ubuntu20:/mnt/smbshare1/dir3$ ls
file4
azureuser@subm-ubuntu20:/mnt/smbshare1/dir3$ mkdir dir4
azureuser@subm-ubuntu20:/mnt/smbshare1/dir3$ cd dir4
azureuser@subm-ubuntu20:/mnt/smbshare1/dir3/dir4$ touch file6
azureuser@subm-ubuntu20:/mnt/smbshare1/dir3/dir4$
Please let us know if you have any further queries. I’m happy to assist you further.
Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.