Topic: Mount Windows (CIFS) LAN Shares and Overcome Libreoffice/.doc Issues

Those of us trying to use Linux in a Windows network LAN environment at work can have a certain amount of difficulty accessing Windows (CIFS) shared folders when using the company's Windows LAN.  In addition, Libreoffice Write (and OpenOffice Write) can create problems trying to open/save .doc files because Libre/Open Office do not use the CIFS-style mandatory byte-range blocks.  I am using #! both at work and at home, and I thought it might help at least some folks if I shared some of the setup I use.  This setup allows auto mounting of Windows network shares and overcomes the problems opening/saving .doc files in Libre/OpenOffice.  Here goes -

PERMANENTLY MOUNTING WINDOWS (CIFS) SHARES AS A #!LINUX CLIENT:

1.  Open a terminal and create a directory in /mnt to receive the shared CIFS folders as follows:  sudo mkdir /mnt/<foldername> 

I use the existing name for the Windows share as it appears on the company server, but you can name this folder anything - it does not matter.  If you have subfolder within a primary shared folder, mounting the primary folder will also allow access to all of the subfolders and files it contains (no need to mount each subfolder individually).

2.  If not already installed, install the "smbfs" package via Synaptic or via apt-get install from the command line.  (You can determine whether you already have this installed by opening Synaptic and doing a search for "smbfs").  smbfs "provides support for cross-platform file sharing with Microsoft Windows, OS X, as well as other Unix systems."

3.  Open your /etc/fstab file in gedit from the terminal command line as root using the following command in a terminal:  sudo gedit /etc/fstab

4.  Add the following entry to the end of your /etc/fstab file and save the edited fstab:

#Mount Windows network shares
//1xx.xx.x.xxx/<share_name_or_IP_address> /mnt/<foldername> cifs auto,iocharset=utf8,nobr1,username=<windows user name>,password=<windows network password>,_netdev,uid=<username>,gid=<group_id> 0 0

If you have other shares to mount, make an entry like the one above for each additional share you want to mount at boot.

If there is a space in a share name in fstab, you can "escape" the space by replacing it with the escape code \040. For example, if a share's name is "bobs your uncle", then the share's name in fstab would be:

//1xx.xx.x.xxx/bobs\040your\040uncle

5.  After saving the file, check to see whether your Windows shares are mounted by entering the following command in a terminal:

sudo mount -a

You will get a return showing all mounted devices and shares.  Here is what mine looks like currently (edited slightly to remove some identifying information):

/dev/sda3 on / type ext4 (rw,errors=remount-ro)
tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
udev on /dev type tmpfs (rw,mode=0755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620)
/dev/sda6 on /home type ext4 (rw)
fusectl on /sys/fs/fuse/connections type fusectl (rw)
//1xx.xx.x.xxx/users/ on /mnt/users type cifs (rw,mand)
//1xx.xx.x.xxx/Teams/ on /mnt/Teams type cifs (rw,mand)

Note the last two lines showing two mounted Windows LAN shares ("users" and "Teams").

OVERCOMING THE LIBREOFFICE WRITE FAILURE TO OPEN/SAVE .doc FILES

The key to making Libre/OpenOffice Write work properly with MS .doc or .docx shared files is to insert the "nobrl" option in the CIFS mount instructions.  This forces Write to ignore the mandatory byte range blocks inserted by MS Word.

I hope this is helpful.  (I want to thank the OpenSUSE team for their wonderful instruction set available here:  http://opensuse.swerdna.org/susesambacifs.html Much of the above was adapted from this document).

Last edited by busprof (2011-05-16 02:07:50)

Re: Mount Windows (CIFS) LAN Shares and Overcome Libreoffice/.doc Issues

Thanks for the great instructions!
I am a total noob but I could follow them all except I was trying to do this with my NAS. I am not what all the bit about:
",_netdev,uid=<username>,gid=<group_id> 0 0"
was meaning so I just went with:
#Mount Windows network shares
//192.168.1.8/Movies /mnt/media cifs  auto,iocharset=utf8,nobr1,username=admin/admin,password=*****

And that worked sweet.

This was one of the most difficult things to deal with when I moved from OS X to #! so I do really appreciate the sweet set of instructions. I think a few people like me, noobs smile, might be looking for this info in regards to auto mounting their NAS drives. Mine was a Lacie.
I hope that this helps other people.
Cheers,
Rubinski

Re: Mount Windows (CIFS) LAN Shares and Overcome Libreoffice/.doc Issues

@Rubinski - I'm glad the (long) instruction set worked out for you.  If you followed it without trouble AND edited it to meet your specific needs I doubt that you can call yourself a total noob. 

BTW, the "uid" is the user identification and the "gid" is the group identification needed for access to the file servers in a MS Exchange-based LAN environment (some UNIX-type file server systems also).  NAS storage setups like yours are a bit simpler (and more flexible in many ways) and (obviously in your case) may not require the same type of identification for access.  Good catch on your part to recognize the difference and modify accordingly.

Re: Mount Windows (CIFS) LAN Shares and Overcome Libreoffice/.doc Issues

@busprof Cheers Bro. I am really starting to enjoy this whole #! stuff. It is like doing math at the start then after a while it becomes ultra satisfying. I can see having this level of control will be addictive. Plus it looks soooo good. smile

Re: Mount Windows (CIFS) LAN Shares and Overcome Libreoffice/.doc Issues

My CIFS fstab entries look like this:

//192.168.0.120/archivos /mnt/tooga cifs defaults,rw,noexec,nosuid,iocharset=utf8,nobrl,username=zap,password=password,file_mode=0777,dir_mode=0777,uid=1000,gid=1000 0 0

The rw, uid, gid, file_mode, and dir_mode options allow me to edit and delete files and folders on my NAS devices.

Last edited by ZAP (2011-05-15 23:04:27)

Re: Mount Windows (CIFS) LAN Shares and Overcome Libreoffice/.doc Issues

@ZAP Shot! I was wondering about how to turn on editing. I noticed I couldn't make changes and hadn't even tried to change it but that should help.
Thanks

Re: Mount Windows (CIFS) LAN Shares and Overcome Libreoffice/.doc Issues

Rubinski wrote:

@ZAP Shot! I was wondering about how to turn on editing. I noticed I couldn't make changes and hadn't even tried to change it but that should help.
Thanks

Hope it helps. You may not need all of these options, but I find that I don't have problems if I include them all. If I don't include the uid and gid, on one of my NAS devices I can create folders and files, but then I can't edit or delete them later.

Re: Mount Windows (CIFS) LAN Shares and Overcome Libreoffice/.doc Issues

@ZAP Sweet. Well pleasingly I can now edit and do everything I would expect to from my OSX machine. Thanks for the tips. I found a big set of unix/linux commands off of reddit.com/r/linux so I am off to wreak some experimental havoc on my #! box smile

Re: Mount Windows (CIFS) LAN Shares and Overcome Libreoffice/.doc Issues

After all this time, I just noticed an error in my log files. Turns out that the option that fixes the Office file problem is "nobrl", not "nobr1". That's an L as in lollipop at the end, not the number one...

Re: Mount Windows (CIFS) LAN Shares and Overcome Libreoffice/.doc Issues

@ZAP -

Aw...Shucks!  Man, your mistake was my fault - I had a "one" at the end of the flag instead of an "l"

I've edited the original post to reflect the correction.  Thanks for the catch - sorry for the mistake.

11

Re: Mount Windows (CIFS) LAN Shares and Overcome Libreoffice/.doc Issues

busprof wrote:

@ZAP -

Aw...Shucks!  Man, your mistake was my fault - I had a "one" at the end of the flag instead of an "l"

I've edited the original post to reflect the correction.  Thanks for the catch - sorry for the mistake.

Stuff happens - I blame serif fonts!

12

Re: Mount Windows (CIFS) LAN Shares and Overcome Libreoffice/.doc Issues

Alrighty so I'm still having one annoying issue with my network mounts: Restarting and shutting down take forever because Network Manager is stopped before the drives are unmounted (I'm connecting via wireless).

I've tried changing the order of shutdown kill tasks, but I can't seem to get it right. I even added a separate shell script (the one called by the K01umountnfs link below) which should go through each of my mounted drives and unmount them, but it's not doing the trick either. Here are the contents of my /etc/rc6.d directory:

zap@vitxo:/etc/rc6.d$ ls
K01alsa-utils  K01avahi-daemon  K01hddtemp     K01mountcifs  K01umountnfs            K02gdm              K04rsyslog     K07ifupdown    K10cryptdisks-early  K12live-boot
K01anacron     K01bluetooth     K01kexec-load  K01openvpn    K01unattended-upgrades  K02network-manager  K05hwclock.sh  K08umountfs    K11umountroot        K13reboot
K01aumix       K01fuse          K01lpd         K01plymouth   K01urandom              K03sendsigs         K06networking  K09cryptdisks  K12kexec             README
zap@vitxo:/etc/rc6.d$ 

Anyone see what I'm doing wrong and know how to fix it?

13

Re: Mount Windows (CIFS) LAN Shares and Overcome Libreoffice/.doc Issues

*BUMP!*

Anyone?

Re: Mount Windows (CIFS) LAN Shares and Overcome Libreoffice/.doc Issues

How do you guys protect your fstab from being read and your password being stolen?

I'm so meta, even this acronym

15

Re: Mount Windows (CIFS) LAN Shares and Overcome Libreoffice/.doc Issues

Awebb wrote:

How do you guys protect your fstab from being read and your password being stolen?

I encrypt the partition.

Re: Mount Windows (CIFS) LAN Shares and Overcome Libreoffice/.doc Issues

@Awebb ^^What ZAP said.

@ZAP - just a suggestion, but would a new post in the "help" section maybe get more views from knowledgeable people and (maybe) a suggestion?  I must admit I'm at a loss on the unmounting issue you raised.

Re: Mount Windows (CIFS) LAN Shares and Overcome Libreoffice/.doc Issues

So you don't have any other users on that system? Single user desktop? Has anyone figured out how to protect it from other users without breaking half the system? Just chmodding it might break some userland.

I'm so meta, even this acronym

18

Re: Mount Windows (CIFS) LAN Shares and Overcome Libreoffice/.doc Issues

Awebb wrote:

So you don't have any other users on that system? Single user desktop? Has anyone figured out how to protect it from other users without breaking half the system? Just chmodding it might break some userland.

GVFS or a separate mount script run at boot in encrypted home directories is best for multi-user systems where mounts are not shared.