I want to mount 4 NTFS filesystems that are on a XP system on the same LAN. At the moment I’m manually mounting them but’s it’s a pain. Ideally, I’d like them to auto mount when I boot but am not sure of the best way to go about this. I know you put the entries into fstab but what happens if I’m not on the network and the mounts fail? Will it cause a problem with or won’t it matter as it gets taken care of automatically?
I have a XP box on which there are 4 drives formatted as NTFS that I need to mount on my openSUSE laptop. The XP box is on the same LAN and subnet as my openSUSE laptop. At the moment I have a script which I manually run to mount these remote filesystems. I’m looking for a way to automate this so they mount at boot.
I know I can just run the script at boot or login but I have a few concerns with how thngs are handles in the event of no network available.
What happens if the path to the filesystem is not avaialble, e.g. I’m not connected to the network at the time of booting or login? I’m assuming the mount just fails without any further problems.
What happens if I’ve mounted the remote filesystem and the network then fails? Will I get data corruption? What happens to the mounted filesystem? Do I need to unmount it? Is there an elegant way to automatically have the system handle such events?
I’m basically looking for the best practice for mounting remote NTFS filesystems reliably and safely.
The correct way is to use the smbfs service (/etc/init.d/smbfs). This reads /etc/samba/smbfstab which contains a list of filesystems to mount. It also is sequenced after the network is up so that it won’t before that happens. It’s probably configured from YaST. I’m guessing, but yast2-samba-client looks like the required package for the YaST menus.
However I don’t use it myself, this is what I deduce from reading the comments and knowing how init scripts work. Maybe swerdna can explain it in more detail.
> No opinions? I’ll try clarify my request.
>
> I have a XP box on which there are 4 drives formatted as NTFS that I
> need to mount on my openSUSE laptop. The XP box is on the same LAN and
> subnet as my openSUSE laptop. At the moment I have a script which I
> manually run to mount these remote filesystems. I’m looking for a way to
> automate this so they mount at boot.
> I know I can just run the script at boot or login but I have a few
> concerns with how thngs are handles in the event of no network
> available.
Well, that’s a matter of taste. I don’t mount samba shares, just access the
resources via konqueror and smb:// protocol.
But sometines it is usefull to create a static mount point by:
Editing /etc/fstab and add an entry for your ntfs static mount point
Going to yast / system / runlevel editor and enable “smbfs” which says is
for “import remote smb/cifs filesystems”.
And just try
> - What happens if the path to the filesystem is not avaialble, e.g.
> I’m not connected to the network at the time of booting or login? I’m
> assuming the mount just fails without any further problems.
smbfs script should handle a failure like this at boot time. If cannot
connect with the remote resource, whatever reason, it will just say “smsfs
service… failed or timeout” and the mount point will not be present once
you login. You can manually mount it later.
> - What happens if I’ve mounted the remote filesystem and the network
> then fails? Will I get data corruption? What happens to the mounted
> filesystem? Do I need to unmount it? Is there an elegant way to
> automatically have the system handle such events?
The behavior should be same you get when working with a device or resource
that is not available over the network. You just can’t access to that
device or if currently working or managing the files, they just become
unaccessible.
> I’m basically looking for the best practice for mounting remote NTFS
> filesystems reliably and safely.
“Test and error” is sometimes a good start point
BTW, I am a bit reluctant with the status of the “ntfs-3g” driver to handle
writing operations. People say is quite safe but I am not so sure about
that :-/
> BTW, I am a bit reluctant with the status of the “ntfs-3g” driver to
> handle writing operations. People say is quite safe but I am not so sure
> about that :-/
Oops, my fault O:-)
I was thinking on locally connected devices (i.e., usb hard disks) that
use “ntfs-3g” driver to handle ntfs filesystem, but this does not apply
when accessing or mounting a remote filesystem over the network.
This seems like the way to go, except I have a few problems. I’ve added the mount points to the smbfstab. When I go to YAST system services smbfs looks like it’s started but has a * next to it - like “Yes*”. When I click on expert mode suddenly the smbfs service is not running and any attempt to start it comes up with
p, li { white-space: pre-wrap; } /etc/init.d/smbfs start returned 6 (program is not configured):
How do I get the service started?
I have the samba-client installed but not samba. From everything I’ve read only the samba-client is required for accessing windows shares as I don’t intend to share anything on my Linux system. Do I still need to install samba for this to work? I can manually mount and rwx everything on the XP box as things are at the moment.
My smbfstab like like this:
It went through all the lines in smbfstab and didn’t find a valid one. Did you end that active line with an end of line? Add a blank line to the end just to make sure of that. Also are you editing the right smbfstab? It’s in /etc/samba/smbfstab, not /etc/smbfstab. I notice that it went through the loop 12 times. That is exactly how many lines there are in the unmodified version. So I bet you didn’t edit /etc/samba/smbfstab at all.
Ahah! Adding the blank line to the end of the smbfstab got a completely different output now. Yes, I am editing the correct smbfstab. I looked to make sure and don’t have a /etc/smbfstab.
Here is the output now. Still looping 12 times.
sh -x /etc/init.d/smbfs start
+ . /etc/rc.status
++ LC_ALL=POSIX
++ export LC_ALL
++ trap rc_lc SIGWINCH
++ rc_lc
++ test -n ''
+++ stty size
++ set -- 32 79
++ LINES=32
++ COLUMNS=79
++ test 32 -eq 0
++ test 79 -eq 0
++ export LINES COLUMNS
++ case ":$PATH:" in
++ test -t 1 -a xterm '!=' raw -a xterm '!=' dumb
++ stty size
+++ echo -en '\033'
++ esc=$'\E'
++ extd=''
++ warn=''
++ done=''
++ attn=''
+++ echo -en '\017'
++ norm=''
+++ echo -en '\015 '
++ stat=' '
++ rc_done=' done'
++ rc_running=' running'
++ rc_failed=' failed'
++ rc_missed=' missing'
++ rc_skipped=' skipped'
++ rc_dead=' dead'
++ rc_unused=' unused'
++ rc_unknown=' failed''
++ rc_reset=''p='
++ rc_save=''
++ rc_restor'='
++ _rc_service=/etc/init.d/smbfs
++ _rc_status=0
++ _rc_status_all=0
++ _rc_todo=start
++ test start = status
++ test -n start
++ cmdline=
+ rc_reset
+ _rc_status=0
+ _rc_status_all=0
+ rc_check
+ _rc_status_ret=0
+ test 0 -eq 0
+ test 0 -eq 0
+ return 0
+ return 0
+ LC_ALL=en_US
+ SMBFSTAB=/etc/samba/smbfstab
+ SMB_CONF=/etc/samba/smb.conf
+ SMBFS_STATE_FILE=/var/lock/subsys/smbfs
+ SLEEP=1
+ TIMEOUT=10
+ grep -q ' cifs ' /proc/mounts
+ test 1 -eq 0
+ smbfs_used=no
+ case "$1" in
+ grep -q '^:space:]]*^#].*:space:]]cifs:space:]]' /etc/fstab
+ rc=1
+ '' '!' -f /etc/samba/smbfstab -a 1 -ne 0 ']'
+ echo -n 'Mount CIFS File Systems '
Mount CIFS File Systems + service_used=no
+ '' 1 -eq 0 ']'
+ timer=-1
+ test -e /etc/samba/smbfstab
+ read service mountpoint vfstype options
+ case "${service}" in
+ continue
+ read service mountpoint vfstype options
+ case "${service}" in
+ continue
+ read service mountpoint vfstype options
+ case "${service}" in
+ continue
+ read service mountpoint vfstype options
+ case "${service}" in
+ continue
+ read service mountpoint vfstype options
+ case "${service}" in
+ continue
+ read service mountpoint vfstype options
+ case "${service}" in
+ continue
+ read service mountpoint vfstype options
+ case "${service}" in
+ continue
+ read service mountpoint vfstype options
+ case "${service}" in
+ continue
+ read service mountpoint vfstype options
+ case "${service}" in
+ continue
+ read service mountpoint vfstype options
+ case "${service}" in
+ continue
+ read service mountpoint vfstype options
+ case "${service}" in
+ '' cifs '!=' cifs -a -z 'username="user name",password=password' ']'
+ '' -z 'username="user name",password=password' ']'
+ '' -1 -eq -1 ']'
+ echo -en 'from /etc/samba/smbfstab
'
from /etc/samba/smbfstab
+ timer=0
++ echo /windows/Lacie
++ sed 's/\/*$//'
+ mountpoint=/windows/Lacie
+ grep -q ':space:]]/windows/Lacie:space:]]' /proc/mounts
+ service_used=yes
+ echo -n '//xxx.xxx.xxx.xxx/Lacie on /windows/Lacie type cifs '
//xxx.xxx.xxx.xxx/Lacie on /windows/Lacie type cifs + rc_reset
+ _rc_status=0
+ _rc_status_all=0
+ rc_check
+ _rc_status_ret=0
+ test 0 -eq 0
+ test 0 -eq 0
+ return 0
+ return 0
+ timer=10
+ JOBS=none
+ printdot=
+ '' none ']'
+ '' 10 -gt 0 ']'
+ '' -z '' ']'
+ mount -t cifs -o 'username="user' 'name",password=password' //xxx.xxx.xxx.xxx/Lacie /windows/Lacie
Usage: mount -V : print version
mount -h : print this help
mount : list mounted filesystems
mount -l : idem, including volume labels
So far the informational part. Next the mounting.
The command is `mount -t fstype] something somewhere'.
Details found in /etc/fstab may be omitted.
mount -a -t|-O] ... : mount all stuff from /etc/fstab
mount device : mount device at the known place
mount directory : mount known device here
mount -t type dev dir : ordinary mount command
Note that one does not really mount a device, one mounts
a filesystem (of the given type) found on the device.
One can also mount an already visible directory tree elsewhere:
mount --bind olddir newdir
or move a subtree:
mount --move olddir newdir
One can change the type of mount containing the directory dir:
mount --make-shared dir
mount --make-slave dir
mount --make-private dir
mount --make-unbindable dir
One can change the type of all the mounts in a mount subtree
containing the directory dir:
mount --make-rshared dir
mount --make-rslave dir
mount --make-rprivate dir
mount --make-runbindable dir
A device can be given by name, say /dev/hda1 or /dev/cdrom,
or by label, using -L label or by uuid, using -U uuid .
Other options: -nfFrsvw] -o options] -p passwdfd].
For many more details, say man 8 mount .
+ PID=16115
+ test -e /proc/16115
+ JOBS=
+ '' '' ']'
+ '' '' ']'
+ test ''
+ '' '' -a 10 -eq 0 ']'
+ rc_status -v
+ rc_check
+ _rc_status_ret=0
+ test 0 -eq 0
+ test 0 -eq 0
+ return 0
+ test 0 -gt 7
+ _rc_status_ret=0
+ case "$_rc_todo" in
+ local i
+ for i in '"$@"'
+ case "$i" in
+ local vrt=
+ local out=1
+ local opt=en
+ test -n ''
+ opt=e
+ case "$_rc_status" in
+ vrt=' done'
+ echo -e '' done
done
+ _rc_status=0
+ return 0
+ read service mountpoint vfstype options
+ test yes = no
+ touch /var/lock/subsys/smbfs
+ rc_exit
+ exit 0
Here is my smbfstab
# This file allows you to mount SMB/ CIFS shares during system boot while
# hiding passwords to other people than root. Use /etc/fstab for public
# available services. You have to specify at least a service name and a mount
# point. Current default vfstype is smbfs.
#
# Possible vfstypes are smbfs and cifs.
#
# The options are explained in the manual page of smbmount and mount.cifs.
#
# service moint-point vfstype options
//xxx.xxx.xxx.xxx/Lacie /windows/Lacie cifs username="user name",password=password
OK, here is an update for anyone interested. It appears that there is a mixture of the two ways that you need to escape the space depending on whether it’s a space in the path or username.
I found that for my smbfstab to work I had to do the following:
Path spaces are escaped as:- /path\ name/
Username spaces are escaped as:- user\040name
Below is my smbfstab
//xxx.xxx.xxx.xxx/Data\ I /windows/DataI cifs username=User\040Name,password=password,uid=1000,gid=100,umask=0022
//xxx.xxx.xxx.xxx/Data\ II /windows/DataII cifs username=User\040Name,password=password,uid=1000,gid=100,umask=0022
//xxx.xxx.xxx.xxx/LaCie /windows/Lacie cifs username=User\040Name,password=password,uid=1000,gid=100,umask=0022
//xxx.xxx.xxx.xxx/LaCie\ Media /windows/LacieMedia cifs username=User\040Name,password=password,uid=1000,gid=100,umask=0022
Hopefully it will get fixed by 11.2. Or you can patch your smbfs script as shown. Also, I suspect you may also be able to use \040 in the service name.