I am trying to mount nas filesystem using python subprocess.popen command, i am running a script to mount the filesystem. some how the script is unable to mount the filesystem.
My script:
self.mountSrc = subprocess.Popen('mount'+' '+ self.src_m[l], shell=True)
print self.mountSrc
if self.mountSrc==0:
print "Mounted filesystem:"+ self.src_m[l]
Output from my script:
Mounting: Source Mount Point:/rsyncTesting/source/share1
Starting:[................................................... ] Done!
mount: can't find /rsyncTesting/source/share1 in /etc/fstab or /etc/mtab
1
I am updating the filesystem path in /etc/fstab before running the mount command. Also i am able to mount the filesystem manually as root user from command line.
slcnas888:/export/rsyncScriptProject_Source/rsyncShare1/.zfs/snapshot/SR_0000-0000000_Refresh_rsyncShares_RSYNC_PROJ_exp13April16 /rsyncTesting/source/share1
I just modified the mount
command to include the name of the mount point,
ie mount /absolute-nas-fs-path /mount-point
instead of only mount /absolute-nas-fs-path
.
I observed that in linux, when we add entries to the /etc/fstab
file, running mount <mount point path>
works fine from the shell, but in a python subprocess we need to pass both the filesystem absolute path as well as the mount point in the command parameter.
# self.src_fs[l] is an item from my list of filesystem paths.
# self.src_m[l] is an item from my list of mount points.
self.mountSrc = subprocess.Popen('mount ' + self.src_fs[l] + ' ' + self.src_m[l], shell = True)
print self.mountSrc
if self.mountSrc == 0:
print "Mounted filesystem:" + self.src_m[l]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.