Growing ZFS pool

recently one of the drives in my storage pool died. Considering that I already was running out of free space:

#zfs list storage
storage 3.21T 820G 236K /storage

I decided to not only replace the failed 1.5TB drive but get two 4TB drives and upgrade whole vdev. Imagine my surprise that despite my memory telling me that it should grow on it’s own. It didn’t.

Some searching later I found out that replacing drives is only part of the solution.
First you have to make sure that autoexpand is on

#zpool get autoexpand storage
storage autoexpand off default

#zpool set autoexpand=on storage
storage autoexpand on local

That still didn’t do the trick, but I’ve noticed that now it was showing:

#zpool get expandsize storage
storage expandsize 2.27T -

To make it use that space you need do zpool online -e for all replaced devices:

#zpool online -e storage wwn-0x5000c500654c1adc
#zpool online -e storage wwn-0x5000c500652efbc2

and now:

#zfs list storage
storage 3.21T 3.04T 236K /storage

Os X Preferences stopped working? There is a fix for that!

Recently I’ve noticed that my Preferences started behaving strangely. Only main panes would open, but no secondary windows would work. For example I could open network preferences and delete all interfaces, but clicking plus button to add new did not work. Which quickly left me with no network on my machine :-)

Some googling later and it seems to be an issue carried over from times when my machine had Leopard installed and some preferences were saved on the disk and carried over. Here is the fix:

defaults delete NSGlobalDomain NSUseLeopardWindowValues
defaults delete NSUseLeopardWindowValues
defaults delete -g AppleUseCoreUI
killall SystemUIServer

Gone… electric!

By no possible means I could be described as a tree hugger.

Yet I’ve just bought an all electric car (Nissan Leaf). Since every person I spoke about that asks the very same question I’ve decided to answer it publicly.


Let’s start from describing our situation. We (me and my wife, no kids) live in not-so-small-yet-not-that-big metro area in the midwest. The whole thing has about 20 miles radius and then nothing but farm fields and very small towns for at least 60 miles. So most of our driving happens within those 20 miles from home.
Then there are those occasional long trips that rack up our mileage to about 15k miles a year.

Up to about three months ago our car park comprised of Mazda CX-5 doing easy 28mpg and an old Range Rover getting about 14mpg. Due to our driving habits described above the Sharky (nickname of the CX-5 – it’s shark fin antenna on the roof sticks out nicely in the sea of cars on any parking lot) was doing about 13k miles a year while the Rover was used only as a backup car for the rare situations when both of us needed to go to different place at the same time driving about 2k miles a year.

About three months ago Rover blew it engine and the repair wasn’t economically feasible so we’ve decided to replace it with something newer. At the same time I wanted to keep our ‘Car budget’ in line (did I mention that my wife thinks I’m a relative of Scrooge McDuck?). So the thought was to replace Rover with something that is much more economical that CX-5 and start using it as main daily driver offsetting it’s purchase cost by savings in fuel.

Easier said than done.

Being comfort creatures we did not want to settle for a shopping cart, and as a result the cars we were looking at were only getting about 40mpg giving as mere $30 saving a month in fuel. That wasn’t helping our situation at all.

At that moment I’ve started to look into alternatives.

First there are hybrids. I was always vocal what I think about them and that didn’t change. You pay a lot and get very little in return. Coming from Europe with their high efficiency _not_so_small_ diesels easily getting 60mpg I was never impressed by expensive toys barely getting 50mpg that hybrids are. Hybrids – out.

Second – plug in hybrids. At first this seems to be looking as a nice thing. You get a car that drives certain amount of miles purely on electric power and then in case you have to go further (or forget to plug it in overnight) the gas engine kicks in. But when you look at it closer I can’t help but see it as the worst of both words. First you have that all additional weight of second power source that doesn’t help efficiency. Second – if you keep driving electric – the gasoline engine can sit weeks or months without a start. And we all know that the fastest way to wear a gasoline engine down is to not use it and let it rust. Plug in hybrids – out.

Finally the third choice – all electric. They have come a long way recently with Tesla leading the range ranks. Now you can get all electric car that can drive 80 miles on a charge with decent acceleration and handling and all the comfort features you may want. The availability isn’t there yet. Unless you live in Peoples Republic of California you are basically limited to the Tesla Model S or the Nissan Leaf, but I happen to like them both so no problem there.

Would the electric car fit our mission? As you see above where I describe our situation it perfectly suits our need for daily commuter – 80 miles range is more than enough. And if we go further it’s going to be at least 150 miles round trip and in 99.99% cases we’re going to drive together – we’ll be driving the Sharky then.

Can we afford it? Being a statistics nazi I threw some numbers in and here it is – currently we are spending about $250 on average on gas a month. Looking at mileage breakdown I expect it to go down to one tank a month on average for CX-5 and about $20-30 in additional electricity bill. That is going to free about $200 a month in our budget. Then there is the $7500 EV subsidy/tax credit that lowers the purchase price greatly. As a result we can drive all electric car for mere $150 a month car budget increase.

So lets sum it up:

  • Comfort features – check
  • Decent driving characteristics – check
  • Roomy interior for occasional 4 people or a bunch of junk we carry around – check
  • (relatively) Cheap – check!

Ladies and Gentelmen, let me introduce to you:

The Melex!



Zend Studio running out of memory? There’s a fix for that!

Recently while working in Zend Studio I had couple of crashes that I finally traced down to it running out of memory. After searching around I found that you can bump up it’s default settings by editing it’s .ini file.

The file is located in /Applications/Zend

# cat ZendStudio.ini
Zend Studio

The settings that you need to bump are Xms and Xmx (in case above they are already bumped up.

My Zend Studie has not crashed since. Happy coding!

Using built in Postgres 9.1.5 on Os X Mountain Lion (10.8)

I’ve been using Postgres db server for years in my day job. And for all those years I had a third party server installed on my Mac. But since Apple started bundling Postgres in Os X system I was thinking of ways to start using that one. Unfortunately it seems that Apple decided to make using it as hard as it’s possible so getting it to work needed some hacking.

The application I’m working with accesses db via network connection on localhost. So I needed to turn on listening on network interfaces. Postgres keeps it’s config file in /Library/Server/PostgreSQL/Data folder. You can find postgres.conf there. You need to edit this file and change two lines to show this:

port = 5432 # (change requires restart)
listen_addresses = '*' # what IP address(es) to listen on;

quick server restart:

# sudo serveradmin stop postgres
postgres:state = "STOPPED"
# sudo serveradmin start postgres
postgres:state = "RUNNING"

and… no luck. Still no connections are accepted on network interface. Checking settings:

# sudo serveradmin settings postgres
postgres:log_connections = "on"
postgres:unix_socket_directory = "/var/pgsql_socket"
postgres:listen_addresses = ""
postgres:unix_socket_group = "_postgres"
postgres:log_statement = "ddl"
postgres:log_line_prefix = "%t "
postgres:unix_socket_permissions = "0770"
postgres:log_lock_waits = "on"
postgres:logging_collector = "on"
postgres:log_filename = "PostgreSQL.log"
postgres:dataDir = "/Library/Server/PostgreSQL/Data"
postgres:log_directory = "/Library/Logs/PostgreSQL"

Shows that the listen_address parameter got somehow overwritten. It turns out that the server stores some parameters in plist files and those get priority over anything you set in postgres.conf file.

# sudo serveradmin set postgres:listen_addresses="*"
postgres:listen_addresses = "*"

changes that and now my application can access built in Postgres server on localhost.

But how about command line tools? Apple sets things up in a way that Postgres accepts socket connection only from users that belong to _postgres group. Now I needed to add myself to that group using dseditgroup command:

# sudo dseditgroup -o edit -a usertoaddtogroup -t user _postgres

and voila! I’ve gut running instance of Postgres (9.1.5) accepting connection from my application and letting me use all command line tools.