Basic ZFS setup

Here is a quick guide to getting a plain ZFS partition working.  I was playing around on a CentOS 7 virtual machine trying to set it up as a replication target for my home FreeNAS box as a backup.

  • Install ZFS as per ZFS on Linux instructions.
  • Check ZFS by running zpool status.
    • If you encounter the following error when you run zpool status:
      [root@zenith ~]# zpool status
      Failed to load ZFS module stack.
      Load the module manually by running 'insmod /zfs.ko' as root.
    • Find the kernel version of your system using: uname -r
      Mine was 3.10.0-123.20.1.el7.x86_64, so replace that with yours below.
    • dkms install spl/0.6.3 -k 3.10.0-123.20.1.el7.x86_64
    • dkms install zfs/0.6.3 -k 3.10.0-123.20.1.el7.x86_64
  • Create a pool
    • zpool create <pool name> <devices to use>
    • e.g., zpool create tank /dev/xvda3
  • Create a data set
    • zfs create -o mountpoint=<where to auto mount the data set> <pool name>/<data set name>
    • e.g., zfs create -o mountpoint=/mnt/testdata tank/testdata
  • Or if you adding a disk that already has ZFS on it:
    • Run zpool import to see if any pools can be imported
    • Then run zpool import <pool name>

References

VMware ESXi Scratch Space

If you installed VMware ESXi on a USB stick like I did, the “scratch space” (used for storing logs and debug information) is stored on a RAM disk.  This takes up 512MB of memory that could otherwise be provisioned to virtual machines.  In addition, it does not persist across reboots, which explains why I was never able to find any logs after a crash. Also I was seeing random “No space left on device” errors when I was trying to run the munin monitoring script for ESXi.

The solution to this is to simply create a folder on a disk, and configure ESXi to use it.

  1. Login to the console or SSH to the host.
  2. Go into one of your datastores in /vmfs/volumes/
  3. Create a directory for the scratch space.
  4. Login to the vSphere Client.
  5. In the Host device, go to the Configuration tab, then find the Software category on the left menu and click Advanced Settings
  6. In the Configuration parameters window, find ScratchConfig on the left.
  7. For the “ScratchConfig.ConfiguredScratchLocation” box, enter the path to the folder you created in step 3.
    ESXi Advanced Settings Window
  8. Reboot the host.

It’s as simple as that!

References:

Seven years after Youth Leadership Millennium

Last Saturday I had the opportunity to attend the graduation ceremony of this year’s S.U.C.C.E.S.S. Youth Leadership Millennium (YLM) program.  I participated in the same program seven years ago and since then have been volunteering there.

Although I have attended many of the graduations as a volunteer over the past years, this was the first time I was invited to speak in front of the audience from my perspective as an alumnus.  Writing the speech gave me a chance to reflect over the past seven years and how different aspects of YLM have been part of my life.

Much of what I wanted to share with the graduates included learning and applying what was learned to life.  The first point was to get the graduates to reflect on what they had learned in the program.   I learned a lot during the seven-month program, hard skills like running meetings, and soft skills like working with others.  I was also exposed to different things that I wouldn’t have tried on my own.

The second point was to keep learning throughout their lives.  The motto of my elementary school was “Be a Learner for Life”.  The program can’t teach you everything there is to know about leadership within seven months.  It’s up to each individual to put in the effort to better themselves.

The final point was to apply what they learned in their lives.  I think much of the benefit of YLM wasn’t really within the program but what came afterward.  The opportunities of applying what I learned in YLM Council and further developing the things that I learned in the program was what I found most beneficial.

I’m including the text of the speech I drafted below.  For the actual speech, I did cut some parts out to save time because the other speakers also covered about some of the things I had planned, however I stuck with the three main points.

This was my first time speaking at an event like this as an alumnus of the program.  Again I learned a lot from this particular experience both when reflecting to write the speech, and giving it on the day.

Continue reading Seven years after Youth Leadership Millennium

How did advertisements get on my site?

I should probably pay more attention to my own site.

While I was working on my blog last week, I noticed that there were advertisements showing up in the Related Content links at the bottom of all my posts.  I was quite shocked as I never added them intentionally.  I feared that my blog was hacked.

Digging just a little deeper, I quickly found the culprit: the Shareaholic plugin.  I used it for related content and the social sharing buttons for the posts.  It turns out a few months ago they sneakily added in monetization options in their plugin update without having blog owners explicitly opt-in.  That means once you updated the plugin (if you’re using the WordPress panel to do this, there’s pretty much no changelog or notice), ad links would spontaneously spawn on your site.  I guess if you’re a better blog owner you would have caught it sooner than I did.  I understand developers need to make money too, and I’d understand forcing advertisements on the admin panel, but having advertisements enabled by default on the public site is a very sneaky process.

Needless to say, Shareaholic has since been removed from my site.  If you’re still using Shareaholic, you should really review its settings to make sure it’s doing what you want it to do.  For me, I’ve found other plugins to replace the functionality including Floating Social Bar and Contextual Related Posts.

Checking for a Null value in SQL

Yesterday I fell into a very simple but dangerous SQL trap.  Can you identify it?

SELECT first_column, another_column
FROM my_table
WHERE first_column = 1
    AND (another_column >= 100 OR 
         another_column = null)

Found it?  It’s the comparison to null.  My intention was to get rows where another_column was null, however the query did not do so.  It didn’t give me any results where another_column was null, but didn’t give me any error either.  Why?

Null in SQL is not a real value.  Null means “lack of a value” or “unknown”. Anything compared to null leads to an “unknown” result. Therefore, in SQL there are actually three values conditions can evaluate to: true, false, and unknown/null. This is called three-valued logic. SQL WHERE clauses only return rows that evaluate to true, not rows that evaluate to false or “unknown”.

The proper way of checking for null is by using the IS NULL or IS NOT NULL predicates. The correct SQL query would have been as follows:

SELECT first_column, another_column
FROM my_table
WHERE first_column = 1
    AND (another_column >= 100 OR 
         another_column IS null)

So if you’re used to languages where you check for null with equal signs, remember that in SQL, you must use the special IS NULL or IS NOT NULL predicates instead of the equals sign or other comparison operators. Don’t get tripped up like I did.

If you want to read more about, Wikipedia has a detailed article on null in SQL.

Software developer (mobile/web). Public transportation enthusiast. Catholic.