Wednesday, August 7, 2013

[Linux] file_mode, dir_mode or permission not working correctly in Samba Share or Mount folder

Users permission in Linux is really complicated, for samba share, you need to take care:

  1. the folder permission of the parents folder where your samba share is located (at server side)
  2. the folder permission of the parents folder where your fstab mounted folder is located
  3. the create mask and directory mask in /etc/samba/smb.conf on your server
  4. the file_mode, directory_mode, nopermrw and credentials in your /etc/fstab on client PC
General rules are parent folders permission will always overwrite the smb.conf & fstab

When do I need to check the parents folder permission?
  1. If you have set everything in both files and still cannot get the correct permission for new created file/directory in your samba shares. Check client PCs mount folder's parent's permission
  2. If client PCs has problem access the samba shares, even with the correct username & password entered. Check server samba share parent's folder permission
  3. When you need valid users = xxx, xxx to give access to client PCs. Check server samba share parent's folder permission
I have set the samba/fstab/parent folder permission, but I still don't have write permission?
  1. you need to add uid=***your current user name*** at the fstab mount option.
Known Issue
  1. When creating file/directory in the mount folder (using Ubuntu 12.10), it does not honor the create mask & directory mask set by the server's smb.conf. I'm still looking for a solution... appreciate if anyone can help.

Saturday, August 3, 2013

[Ubuntu] Can access samba network share by IP but not Netbios name from Windows

After whole long day of troubleshooting why we cannot resolve samba shared folders using the NetBIOS Name defined in smb.conf.. finally I have figured out the root of the problem:
Hostname CANNOT equal to NetBIOS name!!!
A bit of background...

  1. our server hostname is server1
  2. our NetBIOS name is server1 (defined in smb.conf)
  3. IP-address is 10.0.0.2

From Windows 7 / OSX we can access the samba shares using \\10.0.0.2\share, as well as \\server1.local\share (the .local is a result of running avahi-daemon). We can also ping 10.0.0.2 or server1 or server1.local, but we simply cannot access with \\server1\share

By changing the Hostname in /etc/hosts & /etc/hostname to any name other than "server1", or change the NetBIOS name in smb.conf to any other name, we can now get it work.

This is rather weird for a Windows user like me, where only hostname need to be set and we can access directly from other PC in the network without bothering what is NetBIOS. Linux is indeed too tricky!

Anyway, kind of fun when able to figure out what's wrong. It makes me love and hate Linux at the same moment!

[Ubuntu] Can ping internet IP address but cannot resolve web address

If you got error when trying to ping any web address e.g. www.google.com, but can ping its IP address, there could be something wrong with the resolv.conf.

Despite you could have set the dns-nameservers in /etc/network/interfaces, the resolv.conf may not be updated yet. And if you have some running process and could not do ifdown / ifup, you can do nano /etc/resolv.conf, comment the original nameserver 127.0.0.1 to nameserver 8.8.8.8 (or the DNS provided by your ISP).

Ubuntu should now resolve the web address correctly!

Wednesday, July 31, 2013

How to solve chmod doesn't work on mounted folder

When chmod does not have any effect on mounted folder, it could be wrong filesystem flag being used:
  • try umount the folder first
  • if you mount folder is a HDD, check its filesystem type by fdisk -l
  • if it is a NTFS, use the following in fstab :
    •  /dev/sda1    /mnt/folder    ntfs-3g    rwx,uid=xe4,iocharset=utf8,umask=000    0    0
  •  then mount -a
Then the chmod should work now.

Tuesday, July 30, 2013

Damn you, buggy Samba 3.6.3

I have been finding solution to address a samba sharing (Ubuntu 12.04.2 LTS) for few days, the errors that I faced:

  1. windows 7 cannot access share
  2. windows 7 keep asking password to access samba share
  3. windows 7 computer on other VLAN cannot browse the Ubuntu server with Windows Explorer
  4. troubleshoot using smbclient -L localhost -U% give errors such as:
    - tree connect failed, NT_STATUS_CONNECTION_INVALID
And very very luckily... I found a discussion & an article which discussed about the bug found in Samba 3.6.3, and suggest to upgrade to 3.6.7:

Thanks god their suggestion work.. and damn Ubuntu & Samba, how could they release such a buggy version for LTS and do not issue immediate upgrade in the official repository?!!

Alright, here's the solution copy from Marcel's blog:
  • sudo add-apt-repository ppa:nathan-renniewaldock/ppa
  • apt-get update
  • apt-get install samba
Voila! Now Samba works like a charm!

Saturday, July 27, 2013

[Ubuntu] The bad day!! How to recover from dmraid

Today is a real bad day, one of the Ubuntu server that I "managed" (it's not me who installed it) has gone down! There could be two reasons:
  1. Incompatible version of Zentyal (Zentyal 3.0 was accidentally installed on this 12.10, causing the samba not functioning)
  2. The electrical leak in the office due to DP box does not have proper earth line installed. Damn it, the whole rack is covered by electricity, and I got an electric shock! Luckily it was not at high current else all devices and I would have died =_=!
Well.. after hours of troubleshooting, I could not bring the server up and running again. It halted at different stage of loading, sometimes failed to load Samba, sometimes failed at Checking Quota...

I do suspect it is caused by the Zentyal... but time is running out. I rush back to home, taking my laptop SSD* installed with Ubuntu 12.10, together with as many as HDD I could found available for the backup**, and plugged into the server.

Voila! Now I'm inside my laptop Ubuntu, and by running dmraid -r, I could now see the RAID under name isw_xxxxx (isw is a prefix for Intel RST). By running dmraid -ay (activate with silent mode YES), I can now see the whole RAID in Nautilus.

I'm backing up those file now... hopefully the files and directories in the server are still in good condition. Losing a single files will be disaster. Cross finger!

=======================

* Why SSD? Because the Ubuntu server was installed using dmraid and Intel RST (Rapid Storage Technology), so SSD can work well as most of the time SSD is used under AHCI. SATA drive that previously installed without AHCI would fail to boot up.

** Please make sure you use a reliable HDD for the backup. You won't like to fail the second time where you could be only having once chance to perform the recovery.

*** Regarding the mdadm and dmraid, here are some good reads:

  • https://help.ubuntu.com/community/FakeRaidHowto
  • http://raid6.com.au/posts/mdadm_advantages/
  • http://www.sourceware.org/lvm2/wiki/DMRAID

Monday, July 15, 2013

[Centos] yum-complete-transaction error

These commands are useful when yum-complete-transaction gives error, in my case "error removing yum" & "duplicate packages" (yum-utils need to be installed to perform no. 2 & 3):

  1. yum-complete-transaction --cleanup-only
  2. package-cleanup --dupes
  3. package-cleanup --problems