Creating new zfs pool mixing previously used drives

I am building a new homelab for myself using Intel NUCs. I need a NAS so I can test live migration and I was set to buy 2 bay synology. But when a 140$ HP Gen8 Microserver was on offer I couldn’t say no. FreeNAS might not be as polished as Synology but I would be getting 4 bays, two gigabit ports and iLO at a third of the price. Also it would offer the possibility of learning FreeNAS (my other, longtime NAS is slackware + zfs on linux).
Since this server is not going to hold any important data (I’ll be sure to backup anything important on my production NAS – i.e. the one I don’t mess with) I wanted to reuse three old 2TB drives left from upgrading my main NAS to 3TB reds.
When creating the volume in FreeNAS I would be getting the following error:
Creating GPT partition scheme on ada2gpart: geom ‘ada2’: File exists
I imediately realized that this is because some of the disks used to be in a zfs pool in the past. The suggestion was to clear the begging of the disk but that didn’t help. The only fixe from the ones proposed here was:
# destroy ALL DATA on disk /dev/ada2
sysctl kern.geom.debugflags=0x10
dd if=/dev/zero of=/dev/ada2 bs=1m
# now reboot!
I don’t remember if I zeroed the entire 2TB disk or just left it fot ~10 mins to ensure most of the zfs metadata is gone.
After running the above in the command line I was able to create the volume just fine.

Adding a form with autocalculated fields in squarespace

I had to build a form on a squarespace hosted site that has to auto-calculate a couple of fields and also do field validation and offer the option to email the whole calculation to a visitor chosen address. I won’t publish the complete script here, but it shold help get you going.

First of all you will have to build this in the HTML/CSS block, you won’t be able to use the squarespace offered form builder.

First you will need a few javascript functions

function getField1() {
var theForm = document.forms[“myform”];
var field1Value = theForm.elements[“field1”];
return parseInt(field1Value.value);

What this function does is return the value of a field named “field1” in your “myform” form. parseFloat might be required if you are going to use floating point values.

function calculateTotal() {
var outputfield1Value = getField1()*5;

var elem = document.getElementById(“outputfield1Id”);
elem.value = Math.round(outputfield1Value);


This function is called each time one of your form fields is modified. What it does is change the value of the read-only form field to field1*5. This is of course just an example. You can multiply this to as many form input and output fields you need. Please note that you cannot use “disabled” fields as those cannot be POSTed.

function validateForm() {
x = document.forms[“myform”][“field1”].value;
if (x == null || x == “”) {
alert(“Please fill in the first field”);
return false;
var x = document.forms[“myform”][“emailaddress”].value;
var re = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
if (x == null || x== “” || !re.test(x)) {
alert(“Please enter a valid email address”);
return false;

A simple function to do field validation. This one simply checks that the fields were actually filled and that the email field is valid (check RFCs, this is not really the best version but it works for me). Please note that this validation will not stop an attacker or bot to fill bogous data in your fields (as they can POST anything without going trough this javascript)


Autocalculated Squarespace Form

Email a copy to yourself:


The first four div’s are there to make the form look like other Squarespace built forms. Your form will call the validation function and onchange the first field will trigger the update of the second. When working with the new “number” input field pay close attention to the step value. The default is 1 which means Chrome (Firefox ignores it I think) will not allow floating point values unless you set the step to be any (or say 0.1, if you require specific values).

I will leave the emailself.php script as an exercise to the reader. It’s really easy to screw it up though, so be sure to secure it – both the form, maybe with google a captcha and your php script that takes POSTed data and emails it as it’s really easy to miss something and open your self to becoming a SPAM sender.

Speed-up WAN-LAN speed on the Cisco E3200 using Tomato

There’s a really long discussion on bcm_nat and fastnat on the various forums like linksysinfo. The short version of this is:

  1. fastnat and bcm_nat are disabled by default because they break QOS and access restrictions. If you use any of those you’re done, you have to choose features or speed or another router.
  2. If you, like me, don’t use those you can do the following:
    ssh into your router and try: [cci_bash]modprobe bcm_nat[/cci_bash] than speedtest your connection a few times you should see some improvement. Than run [cci_bash]echo “1”> /proc/sys/net/ipv4/netfilter/ip_conntrack_fastnat[/cci_bash] you shold see an even better improvement. If any of those give you issues simply reboot your router, nothing is permanent at this time.
  3. Add the commands to Administration->Scripts->Init.

The instructions are deliberately scarce, if you don’t understand them it’s better not to mess with your router. Check the tomato forums and the linux documentation about those commands until you’re sure you know what they are doing.

Subdomains pointing to private IPs are not resolved on Tomato

Some time ago I used to remember IPs on my home and work network but these days I rely much more on dns and dhcp reservation for this tasks. This has the advantage that I can easy move a service, say to a new server.

At home I switched (at least for a while) from a dedicated Debian router/gateway box to a router running Tomato. Suddenly subdomains pointing to private IP addresses were no longer resolved. Turns out the DNS rebinding protection is at fault. Now you could easily just disable it but this is not the secure way to fix a problem. You can actually white list domains to allow private IPs on subdomains.

Go to Advanced => DHCP / DNS Server (LAN)

Don’t uncheck “Prevent DNS-rebind attacks” as this will leave you vulnerable to this attack. Instead add the following to the Dnsmasq
Custom configuration


Where,, etc. are the domains for which you want to allow subdomains that resolve to private IPs.

Missing 5Ghz WiFi settings on Cisco E3200 with Tomato Shibby

I followed the instructions and installed Tomat on my Cisco E3200 router without issue. I chose Tomato by Shibby specifically because it supports the 5GHz radio in this particular router model. But woe and behold after I installed the settings were not there, I could only see them for the 2.4GHz WiFi.

Well it turns out instructions are made to be followed, I got curious after install and logged right in, but it turns out you really have to do the last 30-30-30 reset.

Sure enough after the final 30-30-30 hard reset the settings for the 5GHz of my Cisco 3200 appeared and were functional.

Quickly disable email for one virtual host

If you discover that one site that you host is sending tons of emails there is an easy and quick way to disable email only for one particular virtual host. Add the following line in it’s virtual host or .httacess file

[cci_bash]php_admin_value sendmail_path “/dev/null”[/cci_bash]

If you add it to the virtual host be sure to reload apache.