Tag Archives: Ubuntu

Changing ownership on a Linux CIFS share

This is one of those very simple things that just doesn’t seem to come up right away in Google search results.  Especially if you’re new to how Linux handles ownership and file permissions.

Working on the server I mentioned in my last post, I couldn’t get some of the applications I am using to properly access my NAS mount point.  Specifically, any time permissions were trying to be changed it would fail because the program was running as my user, and not root.  Normally I’d just run the scripts as root, but I felt it’d be more secure to instead change those mounts to my user account.  Especially since these would be running unattended.  Also, I wanted fstab to bring up the drives already associated with my account.

First and foremost: Using chown on a mounted share will not work.  The command will behave as though it succeeded, but the ownership will not change.  Ownership can only be assigned at mount time.  Be ready to umount the share you wish to change ownership on.

The trick is to add the gid and uid to the fstab line for the mount.  So this:

//192.168.1.100/share      /media/nasshare          cifs    guest,rw,nounix,iocharset=utf8,file_mode=0770,dir_mode=0770 0 0

Becomes this:

//192.168.1.100/share      /media/nasshare          cifs    guest,rw,nounix,iocharset=utf8,gid=1000,uid=1000,file_mode=0770,dir_mode=0770 0 0

The above examples give full access to a share with no credentials, so it’s only shown as an example. But the gid and uid parameters specify the user and group that the share will mount as.

The source I’ve been using to learn all of these mounting procedures is here:
http://ubuntuforums.org/showthread.php?t=288534

Any more information needed about mounting shares in Ubuntu can be found there.

A real home network and server

Over the last few months I’ve been making steady improvements to the network and sever situation in the house I live in.  I have two roommates, so finding time to implement changes is sometimes a challenge.  They aren’t big fans of the internet going down while I upgrade things.  And when I set up a server I want to present it only after I have it running and know they can expect it to be reliable.

A few months ago I upgraded the existing network.  There were some specials on Newegg that allowed me to change up several components.  The Linksys router was switched to the Buffalo WZR-HP-G300NH.  I wanted something with the customization capabilities of DD-WRT, but a with little more memory and speed than the (still great) Netgear WNR2000.  Unfortunately, the WZR-HP-G300NH has some problems, namely the current official firmware – which is a DD-WRT build – has a wireless dropout issue.  While I linked to the DD-WRT site there, I don’t approve of the fixes on the Wiki.  Monitoring for a dropped ping and restarting the wireless interface is not a fix, it’s a hack in the derogatory sense.

I was seeing daily drops of the Wifi connection, and ultimately had to add in the old Linksys back as an AP.  I’m still using the Buffalo for wireless N, and my N devices are laptops and phones that don’t need constant connections.  Fortunately the router is rock-solid for wired connections, so with a Gigabit Switch that was also on sale I was set with enough connections and speed to set up something cool.

For the servers I had two machines:  A 2.26Ghz Pentium 4 1GB, and a Core 2 Duo 3.0Ghz  8GB server that I picked up very cheap from a friend of mine.  The Pentium 4 was already working as a media server – it couldn’t do any transcoding though, so it was actually behaving more like a glorified file server.  It also has 400GB of hard drive space, so eventually it will become a dedicated NAS.  To that end I installed a gigabit NIC in it for faster transfers.

The Core 2 Duo server is where things get fun.  It supports virtualization, so it is now a XenServer box with a few different VMs on it:

XenCenter showing off my virtual machines!

Here is the VM breakdown:

  • FreeNAS – A NAS test install before I move to the actual hardware
  • Ubuntu Server – SSH tunnel entry point, as well as webapp test server
  • Windows Server 2008 – To be used later for a domain building project
  • Xen-Media-PC – The new media server to replace the Pentium 4 box

The Ubuntu server and Media PC are the most noteworthy.  The Media PC VM will be taking media streaming responsibilities as well as acting as my CrashPlan backup point.  Originally I planned to have it act as an FTP server as well, but with the NAS in place I don’t see a real need to bring that functionality in.  And with the jump in power for the Media streaming software, things like real-time transcoding and subtitle overlays are now a possibility.  Which is doubly impressive to me considering this is a virtualized environment!

The Ubuntu server isn’t as immediately impressive (it doesn’t exactly “do” anything yet) but I’m very happy with it because I’ve finally learned how to set up OpenSSH with shared key authentication.  It’s something I’ve used at work (after it was set up) but I’ve never done it for my own purposes.  I was amazed at how easy it is to set up and how much you get with that setup.  I was expecting a console session and that’s it.  Instead I was able to begin using things like SSH tunneling, proxies, and SCP immediately!

The SSH tunneling was of particular interest to me, I use LogMeIn Hamachi to remote into my home machine nearly anywhere I go, but Hamachi has its limits.  It doesn’t run on everything, and offers nearly no ability to remote through phones.  SSH works nearly anywhere, I even got my phone working with remote access, and I expect my iPad and TouchPad to work with it too.  And to be frank about it, I found RDP through SSH to be snappier than through Hamachi. That surprised me, I believe Hamachi is a direct connection after it negotiates with the LogMeIn servers; I expected there to be no real difference in speed switching to SSH.  Now that I have it set up though, I can see why this is considered the standard for remote access.  It’s secure, it’s open, and it’s fast.

What all of this means is that I now have a fully configured media server than my roommates and I can access and push files to without worry, as it has the power to transcode on the fly.  And the ability to access it anywhere I can use SSH.  But more importantly I’m familiar with XenServer and OpenSSH now, which I wasn’t before.  It’s been exciting setting all of this up, and I can’t wait to get more uses out of this hardware!

Configuring LDAP with TWiki

I’m currently trying to get a knowledge base set up at my place of work.  Initially, I had used 68kb to set it up.  It was fantastic to work with (especially after installing TinyMCE as a plug in) but it had no access control or authentication, so management asked I look into alternatives with those features.  I found TWiki and set it up with LDAP / AD (Active Directory) authentication.  Since the documentation wasn’t helping me, I wrote some of my own in case anyone else needs some help, or if I would need to do it again.

Read more »