SGVLUG: Custom Computer Projects

Last night I had the opportunity to present my Luggable PC, FreeNAS Box, and Portable External Monitor projects to the San Gabriel Valley Linux User’s Group. Though the projects themselves have only minimal relation to Linux, the spirit of customization and project sharing fits well with the Linux open source ethos.


I hauled in all the latest versions of my projects. Plus all the earlier drafts and revisions that have yet to be disassembled and pitched. More visual aids is always better than less and they proved quite popular after the talk concluded and people came up to look over the projects up close.

Some of the audience found the topic engaging and stayed after the talk discussing aspects that didn’t make it into the talk and offered ideas for future exploration. Some of those ideas were already on my to-do list and some are novel ideas I should explore.

A few people left early, whether they had other obligations or they got bored I might never know.

I don’t have a lot of public speaking experience so this was a great opportunity for me to get some practice in a low-pressure environment in front of a like-minded crowd. At the moment I’m not planning to go work in a mega corporation again. I might not need good presentation skills in a small business, but if I want to get entrepreneurial and start my own business, I will definitely need presentation skills.

This was good practice, building up the public speaking skill one bit at a time.

Much like my design and fabrication skills.


Acrylic Lights: Infinity Mirror

I’ve played with putting lights in my 3D-printed creations for glowing illumination effects. There were limits to what I could do with 3D printing, though, because printing with a clear filament does not result in a clear object. In contrast, acrylic is clear and works as a light guide with a lot of possibilities.

I’ve noticed a few attention-getting light effects in my acrylic projects to date, most of them created by happy accident. The acrylic box with external fixture made good use of external light. The Portable External Monitor version 2.0 was built from stacks of acrylic sheets: its fluorescent back light reflected between the layers like an infinity mirror.


This effect was on my exploration to-do list for the future, but I moved it to the top of the list after seeing surprisingly good results on the FreeNAS Box v2 enclosure.

I had planned for it to have the standard PC status LEDs: one for power, and one for disk activity. The acrylic plate for motherboard mounting spacer also had two cutouts for 3mm LEDs along the center line. The red hard drive activity light is to be mounted high, and the blue power light mounted down low. The idea was for the blue light to illuminate the top edge of the plate. When there is hard drive activity, red LED will light up the center of that edge, and it should blend to purple with the power light. Both LEDs were blocked from direct view by the motherboard, so all we should see is a nice soft glow emitting from behind the motherboard.


That was the plan, the reality was different. The red activity light worked as expected: when there is disk activity, the center of the top edge had a little red glow.

The blue LED decided to ignore my “nice soft glow” plan and put on an extravagant light show. It didn’t just light the top edge, it lit every edge of that acrylic sheet and had plenty of extra light energy to throw on the surrounding shelving.


Here’s a close-up of the sideways illumination.


The many rays visible in the side illumination, as well as the lines making up the top illumination, indicate infinity mirror action going on inside that sheet. It wasn’t directly visible, and probably very difficult to photograph even if so. Without internal reflections, the blue light would have just gone straight up. But with the smooth surfaces and edges of the acrylic reflecting inside the sheet, the light of a single LED bounced around, found different angles, and was emitted in many more directions.

This LED illumination effect warrants further investigation. It is a happy accident that I fully intend to learn from, and put into future acrylic projects.

I want every acrylic project to look this awesome!


A Survey of Hosting Mechanisms in FreeNAS

After getting Plex plug-in up and running, I started researching the FreeNAS features for hosting other code. I plan to keep my FreeNAS box up and running at all times, as is typical NAS usage, to ensure files are available whenever I want them.  I wanted to know what else I can run on the box at the same time since it is going to be on and consuming electricity anyway.

From highest and most user-friendly level to the lowest, they are:

1) FreeNAS Plug-in: This is how I got started with Plex media server, as it is one of the few plug-ins on the default list. Some flaws with this system was visible immediately. The version of Plex on the default plug-in library is several versions out of date, and there is no user-friendly update mechanism. The user has to go into the FreeBSD jail and update manually. Similarly, in order to access the media files hosted on the same FreeNAS box, the user has to know about manually mapping storage into FreeBSD jails.

It feels like the FreeNAS plug-in ecosystem never matured as much as the creators had hoped. A sentiment confirmed by this page. It explained the reasoning behind the push in FreeNAS 10 (Corral) to move to a system based on Docker containers. Unfortunately, when FreeNAS 10 was abandoned, that push was also put on hold.

Summary: It looks like FreeNAS plug-ins are a dead-end for a deprecated architecture.

2) FreeBSD Jail: Since a FreeNAS plug-in user basically had to know about running a FreeBSD Jail anyway, they might as well learn to work at this more hands-on level rather than depending on the FreeNAS plug-in architecture to sugar-coat it. There are a lot more steps involved, but for popular things, somebody would have posted the list of steps. For example, here’s how to install Plex in a jail. (UPDATE: I’ve learned Plex media server is part of the standard package system and therefore even easier to install: Create a jail, open shell to the jail, type ‘pkg install plexmediaserver‘, done.)

Upside: FreeBSD jails’ isolation protects FreeNAS from some security exploits. The resources consumed by a jail is managed by the same system that manages the rest of FreeNAS and automatically gains all the benefits thereof. Storage in a jail can be mapped to a FreeNAS storage volume to allow (optionally read-only) access.

Downside: FreeBSD jails offers no protection against the nastier kernel-level security exploits.

Summary: FreeBSD Jail makes sense for running relatively trustworthy code that integrates with the volumes on FreeNAS. Plex media server is a good example.

3) Virtual Machine: New in FreeNAS 11 is a feature to create and run virtual machines alongside FreeNAS using the FreeBSD bhyve hypervisor. As of FreeNAS-11-0-U1, this new feature is quite immature. For example, trying to stop a VM in the FreeNAS UI seems to have no effect. I have to go into the administrative shell and use the “bhyvectl‘ command-line utility to stop the VM. As another example, the virtual UEFI boot sequence doesn’t act as some operating systems expect, which can result in the user getting dumped into the UEFI shell. (Something normal users should never see!)

UEFI Shell

Google pointed me to this page which will help with most Linux distributions that encounter this problem. Thanks to this tip, I got my Ubuntu test server up and running on a FreeNAS VM.

Upside: Full virtual machine isolation will protect against most security exploits.

Downside: Full virtual machine isolation consumes more system resources. Most significantly, the storage is not shared: Space dedicated to a VM is not available to the rest of FreeNAS. And there is no storage mapping so a VM could only access FreeNAS shares over the network interface as if it is physically a different machine.

Summary: Virtual machines make sense for things that do not interact with the rest of FreeNAS, and a good alternative to setting up another physical machine.

FreeNAS Plugin: Plex Media Server

plex-logo-e1446990678679Once I had a few simple network file shares set up in FreeNAS, it was enough to do most of what I want in a home network storage device. For a fraction of the cost of a commercial solution like Drobo. Now we can start looking at the less critical fun stuff.

Part of my home media collection stored on my NAS includes various video files that I’ve been carrying around. Most of them were standard-definition video files I recorded off of broadcast television programs. This was done at a time when most people would record to VHS tape. Only the super nerdy types record to computer video.

So I had the files, but I didn’t have a good way to play them straight off a file share. This is where something like Plex comes in. There’s a server-side component that runs on my FreeNAS box, talking to client-side components for various devices. The web client could cast to a Google Chromecast, and the Amazon Fire TV stick has a Plex client app.

For security isolation, FreeNAS runs plugins inside a “jail”. This is a FreeBSD feature that sounds a lot like a Docker container but isn’t a Docker container. This isolation is good default security, but it does mean the Plex Media Server plugin could not see the rest of the FreeNAS box until the user specifies a way for the code inside the jail to see specifically allowed files outside of a jail. I could even specify the storage visibility to be read-only so there would be no accidental manipulation of my video files.

Once I got past the FreeBSD jail mechanics, it was mostly smooth sailing. The only problem came from the large fraction of my files encoded in Windows Media Video format, an old video format that Plex does not support. If I end up deciding I like the Plex experience, I will have to look into doing a bulk re-encode of these old video files.

FreeNAS File Sharing: Trust the Wizard

FreeNAS LogoThe authors of FreeNAS tries to make things easy for the user by providing automation tools (“Wizards”) that take care of the fine administrative details without requiring the user to learn all the underlying nuts and bolts of FreeNAS, or FreeBSD, or Linux kernel, etc.

This is especially true for creating network file shares in FreeNAS. It supports many network file sharing protocols. Including the Apple-specific AFP (Apple File Protocol), the Microsoft Windows-based SMB (Server Message Block), the Unix-based NFS (Network File System), plus three others I don’t even understand.

Each of these have their own setup requirements that a casual user like myself is unlikely to get right on our own. So the manual encourages the use of Wizards. (Bold emphasis mine, but I think it should be in the manual!)

FreeNAS® provides a Wizard for creating shares. The Wizard automatically creates the correct type of dataset and permissions for the type of share, sets the default permissions for the share type, and starts the service needed by the share. It is recommended to use the Wizard to create shares.

Windows has a file sharing wizard as well: In Windows file explorer, I would create the folder I want to share, then right-click on that folder to select “Sharing…” This launches the wizard who will then take care of everything else.

Since I was used to the above workflow, I did the same thing in FreeNAS. Create a directory, then run the wizard to share that directory. Unfortunately this results in network shares that were not accessible. (“Access Denied”)

I eventually debugged the problem to my “create a directory” step. Since I had created as an administrator, the permissions on that directory were not set for use by other users. And the FreeNAS wizard did not (or could not) update the permissions properly.

What I needed to do was to launch the FreeNAS network sharing wizard, and tell it to create the directory as part of the network share creation process. This way the directory would be created by the wizard who will properly set the permissions for file sharing.

I did too much and that became unhelpful.

Trust the Wizard.

FreeNAS USB Flash Boot Drives: Recovering Boot Drives That Don’t Boot.

FreeNAS LogoWe’ve established that FreeNAS can mirror the USB flash drive boot device for redundancy. If one of them should fail, the system can be recovered with the other. I hadn’t set out to verify the recovery procedure, but I stumbled into a practice run anyway. In hindsight it’s good to get a feel of my recovery options now when I’m still playing with the system, rather than later when I’m in a panic to recover my data.

Over the past few days I’ve experimented with the boot volume, setting up the mirroring and using the built-in replacement mechanism to retire my USB sticks with checksum errors. After this was done, I unplugged the checksum-error drives (including the one I originally installed FreeNAS on) and rebooted the system.

It failed to boot and ended up at the GRUB recovery menu. Hmm, that’s not good.

I plugged all the old drives back in… and that didn’t improve the situation. Apparently, in the midst of all the mirroring and replacing, I managed to damage GRUB configuration so FreeNAS no longer boots.

Since I expected all the actual operating system files to be OK, I searched for a way to rebuild just the boot loader portion of the USB sticks. There are many ways to do this. The easiest – looking route I took is to perform an in-place upgrade.

I booted up the FreeNAS installation media, and selected the “Install/Upgrade” option. I pointed it to a USB drive that was free of checksum errors but would not boot. The installer detected an existing installation and offered to generate a new boot environment for the existing FreeNAS installation. Sounds perfect! I hit <OK>

Ten minutes later, the upgrade failed due to an error writing boot configuration files the installer wants to add. A quick Google search found a few suggestions on how to fix it using command-line tools I wasn’t familiar with. I decided to try easier things first.

I restarted the installation process and chose the other upgrade option: An upgrade with a disk reformat rather than just generating a new boot environment. The installer will preserve a copy of the FreeNAS configuration but wipe everything else from scratch.

This approached was more destructive and took more time but it worked. My FreeNAS box booted back up as if nothing happened. Success!

FreeNAS USB Flash Boot Drives: Wide Variations in Performance

Since I went into this FreeNAS project with the expectation to experiment and learn, I followed the recommendation to use commodity USB flash drives as the operating system boot drive despite my skepticism. The previous blog post discussed checksum errors found on some of the USB flash drives I had on hand, and how FreeNAS is able to mitigate the errors by mirroring the operating system across multiple USB sticks. This greatly increased my confidence entrusting the FreeNAS operating system to these USB thumb drives.

Usually these devices are used for ferrying files from one computer to another. They expect to see some files copied onto the drive, then copied off the drive in order. (sequential read/write operations.) Putting them in service as the operating system drive is an entirely different work pattern, with small pieces of data written at unpredictable places and other data retrieved from equally unpredictable places. (random read/write operations.)

I was aware of this difference and it was part of my skepticism using USB sticks as operating system drive. Now that I’m using it, I can see how it works in reality. Thanks to FreeNAS boot device mirroring, I have the confidence to go into this experiment without risking my data.

Outside of errors or outright failures, the other thing I had expected was degraded performance. If the flash memory controller chip is optimized for sequential operations, it might be bad at random operations. Unfortunately there was no way to tell up front. The software running on the flash drive controller isn’t something manufacturers put on the packaging. And every company has their own algorithm.

Since they are so cheap, the easiest thing to do is to just go and try it. The result is clear: some USB flash memory drive controllers are far far better at this workload than others.

Some of this difference is felt immediately, in the time taken for the mirroring duplication process. During this “resilvering” process roughly 2GB of data is copied to the new flash drive. Out of the two drives that had no checksum errors, one of them was able to complete the process in a little over two hours. The other took 26 hours, more than ten times longer!

Their difference is also visible in the FreeNAS system performance reporting page. Since FreeNAS keeps the two drives in sync, it’s easy to see how they respond to identical workloads. The flash drive identified as (da1) breezes through work, never more than 50% busy. Its mirrored sibling (da2) struggles to complete the same work, frequently spiking up to 100% busy.


One of these is much less happy at their new job than the other.

Between the checksum errors and the disk busy graph, I am now much better enlightened on the varying quality of USB flash drives. I had thought of them as all basically equivalent, so I just bought whichever is the cheapest. My attitude has now changed. From here on out, whenever I need to buy USB flash drives, I’ll look for those made by SanDisk.

FreeNAS USB Flash Boot Drives: Mirroring For Fault Tolerance.

FreeNAS LogoFreeNAS encourages the use of USB flash drives as the operating system boot drive. This allows FreeNAS to dedicate all of the motherboard SATA connectors for data storage drives. I didn’t think commodity USB flash drives are trustworthy enough to hold the operating system, but I was willing to experiment and be proven wrong.

The very first night, I got worrying news from the nightly system check:

  pool: freenas-boot
 state: ONLINE
status: One or more devices has experienced an unrecoverable error.  An
        attempt was made to correct the error.  Applications are unaffected.
action: Determine if the device needs to be replaced, and clear the errors
        using 'zpool clear' or replace the device with 'zpool replace'.
  scan: scrub repaired 3K in 0h10m with 0 errors

        NAME        STATE     READ WRITE CKSUM
        freenas-boot  ONLINE       0     0     0
          da0p2     ONLINE       0     0    11

errors: No known data errors

Looking on the bright side, “No known data errors” is comforting, as is the “repaired […] with 0 errors”. It’s nice FreeNAS was able to repair whatever was wrong with my USB stick. I suspect inexpensive commodity USB flash drives frequently encounter errors that are silently corrected by the operating system. Still, an error is an error and it’ll only be a matter of time before I run into a serious problem.

Fortunately, FreeNAS authors had the foresight to make sure a bad boot device does not become a single point of failure. A second one can be added to the system act as a mirror to the boot device. If either of them fails, the other can take over.

Much to my dismay, the second USB stick I tried also encountered a data checksum error. I didn’t have much luck figuring out how to interpret the checksum error code, but I did learn that it is supposed to be zero. The first stick returned 21, the second 26.

I tried a third USB stick and was relieved to finally see a zero checksum. The output below was generated when I ran ‘zpool status’ while the third stick is in the middle of replacing the second stick.

  pool: freenas-boot
 state: ONLINE
status: One or more devices is currently being resilvered.  The pool will
        continue to function, possibly in a degraded state.
action: Wait for the resilver to complete.
  scan: resilver in progress

        NAME             STATE     READ WRITE CKSUM
        freenas-boot     ONLINE       0     0     0
          mirror-0       ONLINE       0     0    21
            da0p2        ONLINE       0     0    21
            replacing-1  ONLINE       0     0     0
              da1p2      ONLINE       0     0    26
              da2p2      ONLINE       0     0     0  (resilvering)

errors: No known data errors

I also found a fourth USB stick that was checksum error-free, so I had it take the place of the first one.

  pool: freenas-boot
 state: ONLINE
  scan: scrub repaired 0 in 0h29m with 0 errors

        NAME        STATE     READ WRITE CKSUM
        freenas-boot  ONLINE       0     0     0
          mirror-0  ONLINE       0     0    21
            da1p2   ONLINE       0     0     0
            da2p2   ONLINE       0     0     0

errors: No known data errors        

Now both boot drives in the mirror set have zero checksum error, but the mirror volume overall still has checksum error 21 from the first USB stick. I’m still learning if that means anything (bad) and what it would take to reset that to zero.

FreeNAS Box v2: Component Access

One aspect that was completely neglected in v1 was any kind of an access door. The panels were designed only enough for them to mesh, so the only way to hold things together is to glue everything shut. Completely impractical! The only way to perform any maintenance would be to shatter some acrylic to break the case open.

Now we have two access panels, one in the front and one on the bottom. I tried to see if I could somehow integrate things so there would only need to be one access panel, but never came up with a design that would work well while simultaneously satisfying all the other design goals I’m trying to accomplish.

Each access panel is held in by 4 x #6-32 screws, the standard desktop PC case screw. They fasten into threads I had tapped into the underlying layer of plastic. I should use heat-set inserts for better durability. Unfortunately I didn’t have #6-32 inserts on hand at the time and I thought I would probably build a V3 follow-up anyway.

FreeNAS v2 Front Panel Open

The front panel opens to allow access to the front chamber where the motherboard and CPU lives. If I wanted to upgrade the memory or switch out the SATA cables, I could do so through the front panel opening.

The bottom panel opens to allow access to the rear chamber. The two hard drives and the power supply are all installed through the bottom opening. The drives can be individually replaced without fighting through too many pieces of cable. The power supply can also be replaced through the opening exposed by the bottom panel.

FreeNASv2 Both Panel Open

FreeNAS Box v1 to v2 Size Comparison

Now that FreeNAS Box v2 is up and running, let’s do a size comparison to see how things have changed. The width dimension was a regression: v2 is wider by 3 centimeters. The real space requirement increased even more than that, because the v2 air intakes are on the sides.  So it needs additional room to the left and right of it in order to avoid blocking those intakes. In contrast, v1 with its bottom intake would be OK sitting flush against objects to its left and right.

Looking at the final results in reality, I think I can rearrange a few things to reduce the width by 1 cm. Something to consider for a potential FreeNAS Box v3.

FreeNAS v1v2 SideBySide

The greatest improvement is in the height which has been reduced by 7 cm thanks to the elimination of the lower air intake cavity. The advantage is somewhat reduced when in use, because the power cable now sticks straight up and adds a bit to the required height. If this becomes a serious problem, though, I could always switch to an power cable with a right-angle plug. This will allow the box to fit in a shelf only 28 cm high, leaving barely enough for proper heat exhaust. Looking over the results, I think I can safely reduce the bottom of the case by 1 cm and everything will still fit, another change for the potential v3.

FreeNAS v1v2 SideBySide

And finally, the depth is reduced by 3.5 cm. Real world improvement is even more, because now the back of the box can sit flush against the wall in a way that v1 could not.

The reduced height and depth has more than compensated for the increase in width, v2 is overall a more compact space-efficient package than the v1 design.