Getting FreeBSD 11 working on my Asus Zenbook UX31A

Sigh… not sure why this was so painful. After years away, I thought it would be nice to re-visit FreeBSD on my dedicated malware analysis laptop. While I had used FreeBSD for over a decade on personal server systems, I’ve never really used it as a desktop system, but I’m tired of the Linux disto situation. Besides, I’ve always been more comfortable on BSD-based systems.

But let’s face it, some Linux distros are much better at working as desktop systems. Here’s my (on-going) work to get FreeBSD 11.0RC2 going on my spare ultrabook.

During install make sure to configure the internal drive as GPT partition table and be sure the EFI partition is listed first.

After the install, enter the firmware to create “a new boot option” and indicate the location of the proper UEFI boot file.

Add boot option: Internal SSD
Select Filesystem: [accept default]
Path for boot option: \efi\boot\bootx64.efi

Form here, I’m basically just going to follow the FreeBSD desktop install instructions from CoolTrainer: https://cooltrainer.org/a-freebsd-desktop-howto/

Next swap CapsLock and Ctrl keys, because that’s just better:

echo 'keymap="us.ctrl" >> /etc/rc.conf

Then go into the System->Preferences->Hardware->Keyboard->Layouts and select “swap ctrl and caps lock”.

 

Some additional things I had to do:

  • installed emacs (text editor)
  • installed redshift (like flux)
  • installed slim (login manager)
  • installed cairo-dock (like Mac OS X dock)
  • installed cairn-dock-plugins
  • installed launch (like Alfred/Quicksilver)
  • installed compton (compositing window manager)
  • installed Chromium

Things I still need to work out:

  • Removable Media
  • SD card
  • Touchpad
  • WiFi panel for Gnome
  • Gnome 2/Mate sound

Installing the Nix Package Manager

There isn’t really a reason to read my install directions for nix, I just used the default install command for Linux/Mac OS X.  To wit:

curl https://nixos.org/nix/install | sh

Except that I had to modify the .profile script to work in tcsh.  Namely, I created a version of the default nix.sh file works for csh/tcsh:

#!/bin/sh

if [ -n "$HOME" ]; then
  NIX_LINK="$HOME/.nix-profile"
  echo 'setenv NIX_LINK $HOME/.nix-profile;'

  # Set the default profile.
  if ! [ -L "$NIX_LINK" ]; then
    echo "creating $NIX_LINK" >&2
    _NIX_DEF_LINK=/nix/var/nix/profiles/default
    /nix/store/rznhi2hyzcgckk7yb2662lr57sb906ps-coreutils-8.24/bin/ln -s "$_NIX_DEF_LINK" "$NIX_LINK"
  fi

  echo "setenv PATH ${NIX_LINK}/bin:${NIX_LINK}/sbin:$PATH;"
	
  # Subscribe the user to the Nixpkgs channel by default.
  if [ ! -e $HOME/.nix-channels ]; then
    echo "https://nixos.org/channels/nixpkgs-unstable nixpkgs" > "$HOME/.nix-channels"
  fi

  # Append ~/.nix-defexpr/channels/nixpkgs to $NIX_PATH so that
  #  paths work when the user has fetched the Nixpkgs
  # channel.
  echo "setenv NIX_PATH ${NIX_PATH:+$NIX_PATH:}nixpkgs=$HOME/.nix-defexpr/channels/nixpkgs;"

  # Set $SSL_CERT_FILE so that Nixpkgs applications like curl work.
  if [ -e /etc/ssl/certs/ca-certificates.crt ]; then # NixOS, Ubuntu, Debian, Gentoo, Arch
    echo 'setenv SSL_CERT_FILE /etc/ssl/certs/ca-certificates.crt;'
  elif [ -e /etc/ssl/certs/ca-bundle.crt ]; then # Old NixOS
    echo 'setenv SSL_CERT_FILE /etc/ssl/certs/ca-bundle.crt;'
  elif [ -e /etc/pki/tls/certs/ca-bundle.crt ]; then # Fedora, CentOS
    echo 'setenv SSL_CERT_FILE /etc/pki/tls/certs/ca-bundle.crt;'
  elif [ -e "$NIX_LINK/etc/ssl/certs/ca-bundle.crt" ]; then # fall back to cacert in Nix profile
    echo 'setenv SSL_CERT_FILE "$NIX_LINK/etc/ssl/certs/ca-bundle.crt";'
  elif [ -e "$NIX_LINK/etc/ca-bundle.crt" ]; then # old cacert in Nix profile
    echo 'setenv SSL_CERT_FILE "$NIX_LINK/etc/ca-bundle.crt";'
  fi
fi

I installed this file as: /nix/var/nix/profiles/default/etc/profile.d/nix.csh. Then I just called in my .tcshrc using:

eval `/nix/var/nix/profiles/default/etc/profile.d/nix.csh`

BasicTeX 2015

Ok, this is part of the regular series of these posts, and mostly serve as a simple record for my own use.  If there’s anyone out there reading this, please disregard yet another TeX upgrade  posting.

I know I’m going to have to do this again in a week or so when BasicTeX 2016 hits, but here it is anyway.  I should have done the normal tlmgr uninstall in step 1, but I noticed that I had a backlog of old TeX install directories out there, so I nuked them instead.  Partly this is because El Capitan broke the TeX link (/usr/texbin) and some GUI utils weren’t working (mainly the PrefPane).

  1. create a list of installed packages: tlmgr info --only-installed | cut -d: -f1 | cut -c3- > tex-packages
  2. rm -rf /usr/local/texlive
  3. download and install the current BasicTeX package from tug.org
  4. tlmgr update --self
  5. tlmgr update --all
  6. create a list of the packages installed by default: tlmgr info --only-installed | cut -d: -f1 | cut -c3- > tex-default
  7. Diff the two lists: diff tex-default tex-packages
  8. Install the packages using tlmgr
  9. tlmgr install algorithms collection-fontsrecommended enumitem endnotes exam footmisc lastpage multirow paralist parnotes subfigure tex4ht titles todonotes
    

QNAP 451+: Hardware Accelerated Transcoding

I’m having problems with Plex using too much CPU to transcode files. Actually, I’m not sure why it’s transcoding to an AppleTV 4, it should be able to Direct Stream .mkv files. I’m trying to go ahead and use the QNAP hardware accelerated transcoding engine.

First problem, all transcode requests are returning, “Failed: File read/ write error“. No logs for the failure, so off to ssh I go. The transcode command lives in: /mnt/ext/opt/medialibrary/bin. There are three commands we care about:

  • mfytranscodesvr
  • mytranscodecmd
  • myvatranscode

Running the first seems to indicate it already running, and the second seems to kick-off another failing transcode. The third command is interesting because it appears to the be accelerated version. It’s actually a symbolic link to: /mnt/ext/opt/QDMS/bin/myvatranscode.

A quick check shows that the entire /mnt/ext/opt/QDMS directory is missing. This is apparently because I turned off DLNA streaming. By re-activating the “Media Streaming Add-on”, the accelerated streaming appears to be working now.

We’ll have to see if Plex is smart enough to pick-up the transcoded version when available.

QNAP 451+: SABnzbd/Sickbeard setup

  1. Install the Python 2.7 from the QNAP app center.
  2. Install the following qpkg from the QNAP community app repository:
  3. Configure SABnzbd with Usenet servers, and SickBeard with shows to search.
  4. Make sure that SABnzbd is configured to post-process by using the nzbtosickbeard.py script.This will also require configuring the values in: /share/Download/nzbToMedia/autoProcessMedia.cfg.
    Specifically

    • SickBeard integration had to be activated
    • The port had to be set to 7071 (based the SickBeard.qpkg config).
  5. If necessary, patch the first line of: /share/Download/nzbToMediaCharTranslator.py to use:
    #!/usr/bin/python2.7 -OO
  6. If necessary, patch: /share/CACHEDEV1_DATA/.qpkg/SABnzbdplus/SABnzbd.py to fix a bug causing SSL timeouts while  fetching nzb files from indexers using HTTPS (as per this forum post):
    opt_out_of_certificate_verification = True
    if opt_out_of_certificate_verification:
        try:
            import ssl
            ssl._create_default_https_context = ssl._create_unverified_context
        except:
            pass
    
  7. If necessary, patch: /share/CACHEDEV1_DATA/.qpkg/SickBeard/SickBeard/sickbeard/helpers.py errors related to searching for nab files (from this forum post):On line 227, remove the str() from around the e.code so it reads like:
    logger.log(u"HTTP error " + e.code + " while loading URL " + url, logger.WARNING)
    

    Then, do similar down on line 234 so it reads like:

    logger.log(u"URL error " + e.reason + " while loading URL " + url, logger.WARNING)
    

Seeking System 0.97

Lately, I have been dabbling with retro-computing (actually as part of co-adivsing a student group).  One of the old machines in my collection is an original Macintosh from 1984. For the sake of authenticity, I have been looking for the version of system software that shipped on release day – Jan 24, 1984.

That early in the Macintosh era, there were no official version numbers on the system disks, but the System and Finder files each had their own version number.  Various accounts indicate that I’m looking for System 0.97/Finder 1.0.  After a lot of searching I’ve turned up several candidate disk images, but each seems to have been modified over time.  Here’s one very common version:

sys097There are several problems with this version.  Most obviously, the version of the System font (Chicago-12) used here is quite different from the version seen in other system versions.  This includes the versions seen in pre-release publicity photos.  All of those other versions  used a more familiar looking variant.  Furthermore, the version of Chicago-10 included does match the more traditional version.  Other, more obvious problems exist. The SysVersion program is actually from 1986, and contemporary accounts indicate that Font Mover was included on the second disk, not the main system disk.  I believe this disk was created at a later date and does not represent what shipped with the first Macs.

The obvious thing to do it to go to the source.  Unfortunately, Apple no longer makes those early versions of the System software available on their website.  But various developer CDs have included System Software over the years.  One of the earliest was, Phil and Dave’s Excellent CD.

P&D filesJackpot! This developer disk lists versions of the System Software all the way back to v0.1.  Sadly, booting up the 0.1 System Tools image reveals that it’s really System 1.1/Finder 1.1g.

Screen Shot 2014-06-05 at 11.33.15 AMIn fact, looking at each version in turn, we get:

File Actual Version
0.1 System Tools System 1.1/Finder 1.1g
0.3 System Tools System 2.0/Finder 4.1
0.5 System Disk System 2.0/Finder 4.1
0.7 System Tools System 3.0/Finder 5.1 (800k image)
1.0 System Tools 512 & 128 System 3.2/Finder 5.3

I didn’t bother checking the rest of the disk images, since they were clearly >400K disks.  For the record, I’ve also checked the Apple Legacy Software CD and the September 1994 Service Software Restoration CD with similar results.

The hunt for a valid copy of System 0.97 continues…

New Laptop: Asus Zenbook Prime

I hadn’t really thought about the long-term ramifications of teaching a Malware course, but it appears that I will be teaching it annually for the foreseeable future.  Since I don’t think it’s the wisest idea to mess with live malware on my day-to-day system, I bought a “new” laptop last week.  It’s actually a used laptop from eBay, an Asus Zenbook Prime.  While similar laptops are occasionally available from woot.com as refurbs, careful auction hunting  netted it for less.

Here’s the exact specs:

Asus Zenbook UX31A-DH51

Asus Zenbook Prime

  • 13.3″ 1920×1080 IPS LCD screen
  • Intel Core i5-3317U 1.7GHz
  • 4 GB DDR3 RAM
  • 128 GB Solid-State Disk
  • Intel HD Graphics 4000

 

Since I wanted a computer that could be setup as an example for the students, I didn’t buy another Apple Macintosh.  The Asus is pretty comparable to a mid-level Macbook Air, and this used one cost me about 33% as much.  The new laptop has a ding or two, and didn’t come with all the accessories, but it works and fits my needs.  The speed at which Windows-compatibles lose their market-value is surprising to a long-time Mac owner (and a topic for another post).

I immediately blew away Windows 8, and replaced it with Elementary OS (Luna).  All things considered, installation went pretty smoothly.