Apple OS X as an NFS Server (with Linux Clients)

For a customer, I had to set up a Linux-based virtualised environment on a MacBook Pro using VirtualBox. This environment included making a couple of 8TB external hard drives available under NFS to the Linux hosts.

In all fairness, what better use can one put OS X to than to virtualise Linux?!?  Just kidding fanboys… well, sort of 😉

Let’s begin with a quick description of the environment:

  • A MacBook Pro (MBP) with OS X 10.8.2
  • VirtualBox with it’s own network (MBP: 192.168.56.1/24) for NFS as well as bridged adapters for general Internet access;
  • Multiple external HDDs – for simplicity, let’s just do one here which is mounted under /Volumes/DATA-1.

We want to export the DATA-1 volume to the Linux clients. That bit’s actually not too hard (see below), the main issue is we needed to match what on Linux is call no_root_squash – i.e. so the root user on the Linux clients would have root access to the NFS shares. That bit was harder.

I’ll assume root access / sudo use in the following commands.

To configure NFS, we edit / create /etc/exports (e.g. nano /etc/exports) such as:

/Volumes/DATA-1 -maproot=root:wheel -network 192.168.56.0 -mask 255.255.255.0

In other words:

  • export /Volumes/DATA-1
  • map the clients root user to local root user and the clients root group to local group wheel (gid = 0)
  • allow the export to be accessed by any host on the private VirtualBox network.

With that entry, NFS can be enabled at boot and started via:

nfsd enable
nfsd start

On a Linux client, this can then be mounted at boot with an /etc/fstab entry:

192.168.56.1:/Volumes/DATA-1 /mnt/data-1 nfs defaults 0 0

The problem was that no matter what variation of options I used, I could not get root access from the Linux clients.

The answer came by chance when I glanced an odd mount option on the external HDD:

/dev/disk2s2 on /Volumes/DATA-1 (hfs, NFS exported, local, nodev, nosuid, journaled, noowners)

noowners? What pray-tell is this? The internet provided some insight:

In Leopard, due to an unfortunate design decision by Apple, “admin” authentication is now required to make this change (no noowners) and non-admin users are no longer able to use “Get Info” to change this setting, even on devices they own and have mounted themselves.

An unfortunate design decision indeed. The temporary solutions is to execute:

mount -u -o owners /Volumes/DATA-1

Thereafter, I now have root access / effective UID from the Linux clients. This of course needs to be entered each time – if someone has a more permanent solution, I’m all ears (see below for a cron script I have implemented for this).

Just as an aside, we have a lot of NFS activity which required some tuning. First, additional NFS threads by adding nfs.server.nfsd_threads=16 to /etc/nfs.conf (execute nfsd restart after that). I’ve also added the following line to /etc/rc.local:

sysctl -w kern.aiomax=64 kern.aioprocmax=32 kern.aiothreads=4

Cron Script for Automatically Removing noowners

As mentioned above, removing this mount option every time you connect these HDDs is damn annoying at best and error prone at worst. I have a script for this now which I locate in /var/root/bin/mount-check.sh which is:

#! /bin/bash

NOOWNERS=`/sbin/mount | grep "/Volumes/DATA-1" | grep noowners | wc -l`

if [[ "X${NOOWNERS//[[:space:]]/}X" = "X1X" ]]; then
    /sbin/mount -u -o owners /Volumes/DATA-1;
fi

This is then executed via a new line in /etc/crontab:

* * * * *    root    /var/root/bin/mount-check.sh

 

Should We Expect Any Different?

As I reflect on the performance of the Government over the past few months, I feel awash with disappointment. A foreigner reading the newspapers with party and names blacked out would hardly know the Government has changed.

The latest failures of Ministers such as Phil Hogan (what of the seven children he wished to condemn to the halting site?) and James Reilly (pulling such an obvious stroke, blatantly lying about it and then incompetently covering it up) are depressing and maddening.

But what is even worse is the Government backbenchers. I’ve watched politician after politician from the Government parties asked about these failures of character and every one of them have uttered some mealy-mouthed claptrap nonsense to weasel around the question rather than just calling a spade a spade. All too interested in keeping their nose clean to enrich themselves with some committee or future ministerial position rather than being a good, decent honest politician loyal to the people who elected them in the first place.

Should we have expected anything different? Maybe not. But we changed the Government to promises of a better way. Maybe we shouldn’t expect it, but we sure as hell should demand it.


Extended Version

The country as a whole rejoiced at the last general election when Fiannia Fáil were returned to the wilderness of opposition. After fifteen years in Government, their TDs and Ministers had become all too used to the trappings of power. And in the last decade they presided over a boom and budget after budget that dropped the country into its worst ever depression. All the while lining their own pockets.

We looked at a new Fine Gael / Labour coalition with much hope and optimism. But we weren’t and aren’t idiots – we didn’t expect them to change the country overnight. We all know that we’re in for a long hard slog. We did however expect them to be  different from the cronies that went before them. We expected that in a time of great depression, we could look at a new Government that would forgo the trappings of power, leave Parish pump politics to the local councilors – we expected a group of people who would put the common good of the Country as a whole first.

As I reflect on the performance of the Government over the past few months, I feel awash with disappointment. A foreigner reading the newspapers with party and names blacked out would hardly know the Government has changed. Two recent key examples stand out more than others:

  • Phil Hogan: Put aside the complete blunder that he made of the household charge and continues to make with the septic tank registrations; just this week we learned that he assured objectors that a Traveller family would not receive a house they were in line to be allocated and intervened with the local council to try and fulfill this promise. Never mind that his Ministerial office includes responsibility for housing and community – what of the seven children that would have been condemned to the halting site had he been successful? What of the children, Big Phil? So much for Frances Fitzgerald’s promises of “children first” with this Government.
  • James Reilly: I had high hopes and was willing to give Reilly a lot of latitude to try and sort out the mess of the HSE and the health system. But then he pulls one of the most obvious political Parish pump strokes yet and jumps a town in his constituency about 100 places up a list to get a primary care centre. 100 places! He denies it’s a stroke, takes a week to come up with some feeble excuse which is then discredited by a three month old FOI by the Irish Times. Pulling strokes, blatantly lying about it and then incompetently covering it up. His tenure is of course littered with disasters, this just being the latest of many.

Neither of these men deserve a place in cabinet – if even Dáil Eireann. But Enda Kenny owes them both dearly for the part they played in the pathetic coup attempt by other incompetents two years ago. More old fashioned clique politics – who cares if someone is completely ill-suited to Ministerial position; just as long as they have played ball and have served their time.

While the above angers me deeply, what is even worse is the Government backbenchers. I’ve watched politician after politician from the Government parties asked about James Reilly’s stroke-pulling and every one of them have uttered some mealy-mouthed claptrap nonsense to weasel around the question rather than just calling a spade a spade. All too interested in keeping their nose clean to enrich themselves with some committee or future ministerial position rather than being a good, decent honest politician loyal to the people who elected them in the first place.

Should we have expected anything different? Maybe not. But we changed the Government to promises of a better way. Maybe we shouldn’t expect it, but we sure as hell should demand it.

Tracking and Stalking on the WWW

I followed a link to a TED talk by Gary Kovacs, CEO of the Mozilla Corporation, earlier today in which he talks about the use of cookies and embedded objects to track us through the Internet. I always knew this happened and didn’t particular mind until recently:

I reviewed Zend Studio on Zend’s product page. But for weeks after, as I visited completely unrelated sites (non-PHP, non-programming), the embedded ads were often for Zend Studio. The obviousness of the tracking here brought it much more front and centre in my mind. Then Mozilla released Collusion which I installed and was quite shocked are the amount and degree of the tracking.

Watch the following short talk by Gary for more information. Then check out some plugins like AdBlock+, Collusion itself and ShareMeNot.

Pregnant Teenager / Single Mother Refused School Entry

For anyone wondering just how far Ireland has come since we banished pregnant women to the Magdalene Laundries should take a good read of the recent statement from the Childrens’ Ombudsman regarding the actions of school A.

tl;dr? Here are some exerts showing the school’s correspondence to the Ombudsman and the mother and child in question:

’Do not try to blame this school for having a moral code. You have no business coming down here to single us out – we are a Catholic school and shall remain so’.

‘Your letter surprises me. A neighbour called at your request and stated that your daughter was pregnant. I was shocked and told her that I did not take in such girls. She conveyed the message to you’.

’This is the first correspondence I have seen from you. We do not take single young girls who are mothers. This is not a suitable school for such’.

‘Neither am I obliged to have any other frills that you mention. This school is NOT a haven for young pregnant people or for young mothers who, in particular, have been in two other post primary schools. The school has an uncompromising ethos and will not become a dumping ground for those rejected elsewhere”.

‘it was always our policy not to entertain pregnant girls and that of some other local schools’

Wow. Queue outrage from various Ministers which, as always, will be soon forgotten and this issue (and the bigger issue of school enrollment) will be side lined and buried.

How did the girl in question feel? In her own words with additions from the Ombudsman:

‘felt put into a low category, .that I was not good enough to be in his school, I felt ashamed and embarrassed that someone could make me feel this was for being a single young mother. I wouldn’t wish this feeling on anyone else, I was very emotional
and stressed by it. I felt hurt and discriminated against as my child wouldn’t stop me having an education’.

She said it also made her upset for her baby. She explained that this initially made her not want to go back to school at all. She felt that the school did not see that she wanted to complete her education for her and her baby and worries that no one thinks she wants to make a difference for her child. She spoke about worrying about what people will think of her, that they may be judging her and thinking that she will get nowhere.

Her mother stated her view that the actions of the school impacted on her daughter’s self-belief, that she has no self-belief and does not believe in her abilities. She reports that as a result of the school’s actions, ‘the damage to her self esteem is immeasurable’.

As a side note, this investigation further highlights the good work of Emily Logan and the benefit and absolute need for having a strong and independent Ombudsman for Children.

HTC Back in my Good Books!

Last week, I posted HTC – quietly brilliant? Maybe not….

Then on Saturday I got my over the air upgrade to Android 4 (Ice Cream Sandwich).

So yes, HTC are definitely back in my good books 😉

PS: I had to send my HTC for repair earlier in the year. I came back in a cool package: https://twitter.com/#!/barryo79/status/167522921143746560