Saturday, December 12, 2015

Installing 64-bit Ubuntu on 2007 Mac Mini (A1176) from bootable USB

Due to the lack of support for newer Mac OS’s on older Mac Minis, I opted to wipe my mac and install Ubuntu over it. This was a nightmare to finally find a method that works, as the standard documentation from the Ubuntu website did not apply to my machine. Finally I got it installed after picking up some tips from a few forums. Below are the steps I went through to get this working.

Brief overview

My Mac Mini has a busted Superdrive, so booting from a DVD wasn’t an option. Creating Bootable USB drives using standard methods on the Ubuntu website didn’t seem to work either. Finally I came across this blog post which refers to a super easy method for making bootable USB drives that comes from some German forums. I tried this with a 64-bit Ubuntu ISO, but no luck and I had this same issue which revealed that 2007 mac minis don’t support x86_64-efi (64-bit EFI booting). Following this, I used a 32-bit installation of Ubuntu along with the 32-bit EFI loader from the German package to boot from USB, and everything seemed to work fine. Once the Ubuntu Live USB booted up, I had one more minor issue where the boot loader failed to install, but I just selected don't install boot loader, completed the installation, then manually installed the boot loader using the boot-repair tool as seen in this thread. Following this, my 32-bit Ubunutu install booted with no issues. Finally, using Unetbootin within my new 32-bit Ubuntu installation, I made a Frugal Install of a 64-bit Ubuntu Live ISO which I could then boot from the hard drive, allowing me to install a 64-bit version of Ubuntu and then dual-boot into into either one.

To summarize this all up… I made a 32-bit bootable USB drive which installed a 32-bit version of Ubuntu along with the GRUB launcher. Using unetbootin inside the 32-bit Ubuntu, I then made a bootable partition on my hard disk from a 64-bit Ubuntu ISO which could then be booted from the GRUB. This allowed me to boot and install a 64-bit version of Ubuntu without a DVD drive. Major kudos to all the authors and contributors in the mentioned blogs and threads for paving the way for this to work. I spent days sifting through message boards and this was the only method that worked for me. Below are the detailed steps I took to get this working.

Make bootable USB (32-bit)

  1. Download the obscure German USB creator from here.

  2. Format a USB stick to FAT32 and manauly create the folder structure efi/boot/ inside of it.

  3. Copy a 32-bit Ubuntu install ISO (I used 14.04 desktop) and the file bootIA32.efi from the german package into the /efi/boot directory you just created.

  4. Rename your 32-bit Ubuntu install ISO you just copied to boot.iso

  5. Your USB drive should now look like this: (image taken from my chormebook, the drive is named UNTITLED) enter image description here

  6. Thats it! Now when you restart and hold down Alt, you can select the USB from the list of boot options, no Refit install required. The instructions are similar to this post, with the exception that we’re using the file bootIA32.efi instead of bootX64.efi, which I tried earlier with both 32 and 64 bit Unbuntu install disks, but it didn’t work.

Install the 32-bit version of Ubuntu

Now you can go through the Ubuntu install once the Live USB has booted. I chose to Erase disk and install Ubuntu and let Ubuntu automatically create the new partitions needed and I chose not to use LVM (the default option), as this causes confusion later on when trying to re-partition your drives. At some point, I got an error which is something like Could not create boot loader in specified partition, please choose location to install boot loader. None of the available locations worked for me, so I chose Continue without a boot loader.

This isn’t quite as scary as it sounds, as you can still boot into your live USB if you restart without the boot loader having to be installed. However, after the installation finished, and before restarting for the first time, I followed these suggestions and installed and ran the boot-repair utility. The steps are below:

  1. After Ubuntu install has finished (and you have selected to Continue without a boot loader), open the terminal and type the following:
sudo add-apt-repository ppa:yannubuntu/boot-repair && sudo apt-get update
sudo apt-get install -y boot-repair
boot-repair
  1. The final command will open the boot-repair tool for you. It’ll automatically scan your computer and suggest repairs. Press Recommended repair

  2. I selected No RAID when the option asked me if RAID was installed on my hard drive

  3. I then opted to uninstall any previous GRUB loader and reinstall a fresh one. You’ll have to do some copy and pasting into the terminal, but the instructions are very clear within the installer.

  4. Install the new GRUB into the disk where Ubuntu is.

  5. Done! After restarting without the bootable USB drive, it goes straight into the GRUB loader and you can launch Ubuntu! (If you messed up a step and GRUB isn’t working, you can always just reinsert your bootable USB, restart the computer, then rerun the boot-repair app)

Install a 64-bit version of Ubuntu

Now that you have a working 32-bit version of Ubuntu, you can use Unetbootin to create a bootable partition on your hard disk to launch the 64-bit Live CD from.

  1. First, you must make sure you have enough free space to install the 64-bit version of Ubuntu. I just booted from the 32-bit live USB again, then used gparted to resize my partitions. Because we’ll be loading the 64-bit live CD from the hard disk, we cannot resize this partition during the installation, as the disk will be in use. I resized my 32-bit installation to a 20GB partition. To run gparted from the Live USB, use the following command in the terminal:

    • sudo gparted
    • If you selected LVM (Logical Volume Management) when installing the 32-bit Ubuntu, you won’t be able to use gparted for this. You’ll have to do some fancy command line partitioning, as the LVM system works very differently, and there are not really any reliable GUI tools to do this.
  2. Now restart your computer and enter the 32-bit Ubuntu you just resized in the previous step. Here we’ll install UNetbootin, which will be used to create a bootable partition.

    • sudo apt-get install unetbootin
  3. Use UNetbootin to create a bootable partition from the 64-bit Live CD with the following settings:

    • Distribution: Ubuntu - 14.04_Live_x64
    • Type: Hard Disk
    • Drive: /
  4. After the partition is created, reboot the computer when prompted to do so and select UNetbootin from the GRUB options and this will take you into the 64-bit Live CD.

Launch the 64-bit Ubuntu Live ISO from the bootable partition and then install it along side your 32-bit install. All I had to do was select the free space in the partition step of the installation and create a new ext4 partition from it with the mount point set as /. The swap space from the previous 32-bit install will be reused for the 64-bit install, so u don’t need to create a new one. Again in the installer, select Continue without boot loader option if the error comes up and install and run the boot-repair utility after to get the GRUB working right. By the end, you should have both 32 and 64 bit versions of Ubuntu dual booting on your system.

Final comments

All these steps worked for me, and I was dual booting both versions of Ubuntu

If anything is unclear here, you can check the links to the blogs and threads I posted above (and again here down below). The method described here was a mix-and-match between these four sources:

  1. Making a Bootable USB drive for old Mac Mini: Really good instructions on how to make a bootable USB using the obscure German forums method.
  2. x86_64-efi not supported error when trying to boot from USB on mac: The explanation on why the x86_64-efi boot loader wont work on pre-2008 Mac Minis.
  3. How to manually create a boot loader with boot-repair in Ubuntu: This tells how you can complete the Unbuntu installation when the boot loader fails to install correctly.
  4. Make bootable partition: You can use the frugal install section of this guide to make a bootable partition that launches the 64-bit Ubuntu Live ISO.

Tuesday, November 24, 2015

Access 2010: Selecting unique records across multiple tables with combo boxes

This quick example will show you how to make a set of filtered hierarchical combo box selectors for records across multiple tables within a tabbed navigation form. In other words, if your data is divided up across multiple tables joined by relationships, you can use this method to quickly find your record without having to use a series of multiple embedded sub forms to reach that record. This requires a little bit of VBA, as Access doesn’t offer any GUI features to achieve this.

At the end of this tutorial, you’ll have an Access from which looks like the image below, where the combo boxes are selecting filtered values out of separate tables. The combo boxes Trial and Individual will only show values which are filtered by the combo box selections above them. This is pretty useful if you have huge data sets which are too big to scroll through in just a single combo box.

enter image description here

Example Database

For this example we’ll use a small database comprised of three tables:

Table: Project

ID Project
1 Project A
2 Project B

Table: Trial

ID ProjectID Trial
1 1 Trial 1
2 1 Trial 2
3 2 Trial 3
4 2 Trial 4

Table: Individual

ID TrialID Individual
1 1 1
2 1 2
3 2 3
4 2 4
5 3 5
6 3 6
7 4 7
8 4 8

The relationships between these tables are illustrated here:

enter image description here

The layout for the forms looks like this:

enter image description here

Where the three combo boxes are named project, trial, and individual, and they are located within the form Example_Navigation_Subform, which is the target form for tab 1 within the Navigation Form.

Transform the combo boxes into hierarchical selectors

Combo box: Project

  • In Design mode, select the Project combo box, on the properties select: Data > Row Source > to open the query editor for this combo box. Now use the following image as your query:

enter image description here

  • Also, make sure to set your query to a Snapshot query instead of Dynaset. This will make your queries refresh much faster. The Dynaset query type is only necessary when you want the query to be able to pass edits down to its underlying table.

enter image description here

  • Now that the query is set, go into Data > Bound Column and set it to 1. This will make the value returned by the combo box the ID value of the selected item.

  • Next, go to Format > Column Count and set to 2. Two columns will now be displayed in the box, ID and Project

  • And then Format > Column Widths and set to 0;1. This will cause the box to only display the second column from your query, so when you select a project name it will return the associated ID for that name.

Combo box: Trial

Now select the Trial combo box, and get to the query design: Properties > Data > Row Source >

  • Now set your query up like this:

enter image description here

  • Again, set this query to a Snapshot .

  • The important part of this is the Criteria for the ProjectID column. Use the code [Forms]![Navigation Form]![NavigationSubform].[Form]![Project] to tell the query to get the criteria value from the selected ID value in the Project combo box.

    • When working with tabbed navigation forms, notice that the ![NavigationSubform].[Form] part of the statement points towards the form which is currently opened in your tab. In other words, if you have a function which uses this line and you open the navigation form to a tab which does not contain the target item then run your function, Access will not be able to find it.
  • Now set up your combo box properties for Trial similar to how the Project combo box was.

    • Data > Bound Column = 1.
    • Format > Column Count = 3.
    • Format > Column Widths = 0;1;0.
  • Now the Trial combo box will only show selections that are filtered by the Project Combobox. However, you need to add some VBA here to make sure that when you edit the value in the Project combo box, the row source query in the Trial Combo box will automatically refresh.

    • Select the Project combo box
    • Properties > Event > After Update > > Code Builder
    • Now enter the following VBA code so that it looks like image below: [Forms]![Navigation From]![NavigationSubform].[Form]![Trial].Requery

    enter image description here

  • Now when you select a new value in the Project combo box, the query which defines the row source values in the Trial combo box will automatically update with the new Project ID.

Combo box: Individual

Repeat the same steps above for the Individual combo box to add another level to your selector.

  • select the Trial combo box, and get to the query design: Properties > Data > Row Source >

  • Now set your query up like the image below, where Criteria = [Forms]![Navigation Form]![NavigationSubform].[Form]![Trial].

enter image description here

  • Again, set this query to a Snapshot .

  • Now set up your combo box properties for Trial.

    • Data > Bound Column = 1.
    • Format > Column Count = 3.
    • Format > Column Widths = 0;1;0.
  • Add some VBA to make it automatically refresh the query under the Individual combo box.

    • Select the Trial combo box
    • Properties > Event > After Update > > Code Builder
    • Now enter the following VBA code so that it looks like image below: [Forms]![Navigation From]![NavigationSubform].[Form]![Individual].Requery

enter image description here

Create a query which is automatically updated by the combo box selectors

Now that your combo boxes are complete, you can make a small query which will automatically update when you select a new Individual from the combo box selectors.

Create the query

  • Create a query called ResultsQuery with the following criteria for Individual ID: [Forms]![Navigation From]![NavigationSubform].[Form]![Individual].

enter image description here

  • Now add this query to your tabbed form, with the properties:
    • Source Object: Query.ResultsQuery

enter image description here

  • Finally, add some VBA code to the Individual combo box to make the results query automatically refresh when a new individual is selected.
    • Select the combo box Individual in design mode.
    • go to: Properties > Event > After Update > > Code Builder
    • In the new function, enter: [Forms]![Navigation From]![NavigationSubform].[Form]![ResultsQuery].Requery

enter image description here


Now your done! Now you can use the combo boxes to select specific records which are spread across multiple tables, and the results of your selection will automatically be shown in the Results query. You can download the example accdb file here to get a better look at the code.

Friday, November 13, 2015

Installing crouton, MATLAB, and Office 2010 on a USB drive

I recently bought a Toshiba CB35-B3340 Chromebook with the intent of installing crouton and using it as my primary work machine. Below are the detailed steps I took to get everything working. To get around the issues related to having a tiny hard drive, I opted to install crouton on a USB stick, which was the platform I use to run MATLAB and a few windows programs ported through wine.

Below are the detailed steps I took to:

  1. Install Crouton on a USB stick
  2. Install Microsoft office 2010 through wine
  3. Install Matlab from an ISO image
  4. Get a windows virtual machine running through Virtualbox

Set your chromebook to developer mode

Before installing crouton, you’ll have to switch your Chromebook to developer mode. Be aware that this will wipe your internal storage, so backup any important files you have on the local disk beforehand. This is really easy to do and since its pretty well documented already, you can follow the instructions on this link.

Download compiled version of Crouton

After you’ve got your Chromebook booting in developer mode, you can download crouton from here. You can then run crouton by opening crosh (ctrl + alt + t), then entering the shell by typing the command shell. Assuming you have saved the crouton file in your Downloads folder, you can use the following commands to interface with the compiled crouton package:

  • Check target and release lists
    • sh ~/Downloads/crouton -t help
    • sh ~/Downloads/crouton -r list

You can use these lists to pick out the release you want to install.

Prep the USB stick

The first step is to prepare a USB stick for the installation. The only real requirement here is that the USB is formatted in ext4 which is the standard Ubuntu format. For picking out a USB stick, it’s probably a good idea to go for a USB 3.0 compatible one, and I’d recommend having a minimum of 32GB, as programs like MATLAB and wine eat up a lot of space.

  • Format USB stick to ext4.
  • Name the USB partition “Crouton”.

Install to USB

Now you can go back to your crosh shell and enter the commands for installing crouton from the pakcaged binary you downloaded.

  • The -p flag is the important part here, as it specifies the location of the install.
  • Use the -r flag to specify the release you want.
  • The -e flag will make your chroot encrypted with an additional password.
  • sudo sh ~/Downloads/crouton -e -r trusty -t unity -p /media/removable/Crouton

Run from USB

The installation is pretty straight forward and I’ve never ran into issues. However, launching crouton from a USB stick is a little different that if its on the hard disk. You’ll have to first enter the chroot, before you can use the startunity command.

  • sudo sh /media/removable/Crouton/bin/enter-chroot (to enter the chroot)
  • startunity (to start Ubuntu)

Useful Crouton actions

Clone your crouton installation to another USB drive

If you later upgrade to a larger USB drive for your crouton installation, you don’t have to worry about reinstalling everything. You can use the Ubuntu disk manager gparted to copy and paste your crouton partition to another USB drive.

  • Install gparted with this command: sudo apt-get install gparted
  • Open gparted and copy and paste your crouton partition to another ext4 formatted USB drive

Update your chroot

If your chroot no longer works after a chrome OS update, you can try using crouton to update it with the command below.

  • sudo sh ~/Downloads/crouton -u -n trusty -p /media/removable/Crouton
  • The -u flag specifies the update option.
  • The -n flag is the name of the chroot you want to update.

Installing software

The following instructions assume a basic knowledge of linux operating systems. This section will show you how to install a selection of programs within crouton.


Install Matlab

Mount MATLAB ISO

  • Download Furius ISO mount
  • sudo apt-get install furiusisomount
  • Open Furius ISO and mount the MATLAB ISO file

Create an install directory

I ran into permissions problems when I let the MATLAB try to create its own installation directory. To work around this, I just made a new directory in my home folder and chose that as the install directory. In the past, I’ve had problems with file permissions when I installed MATLAB under sudo, so I’m going to refrain from using sudo here.

  • Make an installation directory for MATLAB: mkdir ~/MATLAB

Install MATLAB from ISO

  • cd to the MATLAB ISO mount: cd /home/username/Maltab801_MacUnix.iso
  • Run the install command: sh ./install_linux

If you get the error, Failed to create folder error during the installation, choose the new installation directory you created in the step Create an install directory: /home/username/MATLAB.


Install Virtualbox

These steps are essentially just a summary of this youtube video. The scripts used in these steps can be found here, or you can download them from the command line in the steps below.

Modifying the kernel headers

To get virtualbox running, you’ll have to use the scripts to do some modifications of the kernel headers. I’m not really sure what happens during this process… but I just know it works, and installing Virtualbox without these scripts is a nightmare.

First download the relevant scripts. Use (ctrl + alt + t) to enter the crosh, then type shell to enter the shell, and use these commands to download the scripts (or you can use the link above to grab them with your browser)

  • cd ~/Downloads
  • wget https://raw.githubusercontent.com/divx118/crouton-packages/master/change-kernel-flags
  • wget https://raw.githubusercontent.com/divx118/crouton-packages/master/setup-headers.sh

Now you can execute the change-kernel-flags script form the shell.

  • sudo sh ~/Downloads/change-kernel-flags
  • Restart your computer to activate the changes after the script has finished
  • Whenever you update your chrome OS, you’ll have to rerun the change-kernel-flages script , so it’s worth keeping around your downloads folder after you’ve finished the installation

Now you can log in to your chroot to run the setup-headers.sh script.

  • Enter crosh (ctrl + alt + t)
  • Enter the shell: shell
  • Enter your chroot: sudo sh /media/removable/Crouton/bin/enter-chroot

You don’t have to use the startunity command here. You can just install the script from the command line from within the crosh terminal after you’ve logged into the chroot. Use the following line to run the script:

  • sudo sh ~/Downloads/setup-headers.sh
  • Use logout and then sudo sh /media/removable/Crouton/bin/enter-chroot to log out and log back in again to your chroot to activate the changes the script has made.

Now the kernel headers are modified, you can go ahead and install Virtualbox as you normally would on any Ubuntu installation.

Install Virtualbox

Enter the chroot in the crosh terminal.

  • Enter crosh (ctrl + alt + t)
  • Enter the shell: shell
  • Enter your chroot: sudo sh /media/removable/Crouton/bin/enter-chroot
  • From the chroot, use sudo apt-get install virtualbox to install Virtualbox
  • Now you can run Virtualbox from within Ubuntu!

After the Virtualbox installation, I managed to setup a 32-bit version of Windows 7 on a .vdi disk with no issues. Also, check the github page for the kernel scripts and take a read through, as you may need to rerun some of the scripts when your Chrome OS updates to keep Virtualbox working.

Enable USB devices in Virtualbox

By default, USB devices won’t work in Virtualbox on crouton, the reasons for this are detailed in this wiki. The mentioned wiki in combination with this one gives instructions on how to get your USB devices recognized. Before reading these wikis, I had no idea what udev was and I found the instructions really intimidating for a relative newcomer to Linux. Because of this, I’m going to rehash the steps you need to do from these wiki’s with particular emphasis on the procedure rather than the explanation. For explanations on why this works, please read the wikis.

  • Open the chromeOS shell and log into your chroot, but don’t run the startunity command to launch the unity GUI. From here, we can edit the crouton system files we need to with a terminal text editor called nano. We’ll start by installing nano with the following command:
    • sudo apt-get install nano

  • With nano installed, we can now open the system file /etc/rc.local. Use the following command to open it:
    • sudo nano /etc/rc.local

  • We’ll need to add the following 3 lines to the file to apply the fix (you can use ctrl + shift + v to paste text when working in the terminal).
    • mkdir -p /run/udev/rules.d
      cp /etc/udev/rules.d/*.rules /run/udev/rules.d
      udevadm control --reload
    • After adding the lines, your nano file should look like the image below:

  • Finally, press ctrl + o to save your updates, then ctrl + x to close nano

  • Now we’ll prepare the udev rules for virtualbox. While still logged into your chroot, run this command:

    • cp /usr/share/virtualbox/VBoxCreateUSBNode.sh ~/Downloads

  • Now log out of your chroot with the exit command, and while in the chromeOS shell, run the following lines:
    • sudo mv ~/Downloads/VBoxCreateUSBNode.sh /usr/local/
    • sudo chmod 755 /usr/local/VBoxCreateUSBNode.sh
    • sudo chown root:root /usr/local/VBoxCreateUSBNode.sh

  • Now log back into your chroot, and use the following command to get the group ID of vboxusers
    • cat /etc/group | grep vboxusers
    • In the output, you’ll need to make a note of the 3-digit group ID. Mine was 121, and we’ll need to use this number again in the final step.

  • Now we’ll need to download the udev rules for virtualbox using the following command (while still in your chroot):
    • wget -P ~/Downloads 'https://gist.githubusercontent.com/Timvrakas/d43fe840d9fc336cae7b/raw/virtualbox.rules'

  • Now we’ll copy the rules into the appropriate directory, then delete the previous rules which were already in the folder. Run the following commands:
    • sudo cp ~/Downloads/virtualbox.rules /etc/udev/rules.d/
    • sudo rm /etc/udev/rules.d/*-vboxdrv.rules

  • Finally, use nano to open the rules file you just copied into the rules.d directory, and change the 3-digit group IDs in the first 2 lines of the file to the group ID you found earlier.

    • sudo nano /etc/udev/rules.d/virtualbox.rules

  • Finally, use ctrl + o to save your changes and then ctrl + x to exit nano.

After these steps are done, Virtualbox should now have the capacity to recognize your USB devices. I used these exact steps to get a Wacom tablet working on my windows virtual machine within crouton.

Minor issues

  • If you have kernel errors following the Virtualbox installation, try repeating the process with a .deb package form the Virtualbox website instead of installing from the repositories. After one of my Virtualbox updates, I started getting Kernel errors, but uninstalling Virtualbox and reinstalling the most recent .deb package from the website resolved it. Not sure why this is, but it seems like the .deb packages are more stable than the repository versions. I then used the synaptic-package-manager to lock the version of my Virtualbox install to avoid running into this again in the future.

  • After using virtualbox for a few weeks, my internet connection seemingly randomly stopped working. The workaround was simple and I only had to change the network settings on my virtual machine to enable cable connected.
    enter image description here


Install wine

To get the MSXML6.dll working (which is necessary for Office 2010), you’ll have to use a 32-bit winearch. This is detailed in the following steps.

  • Install wine via the terminal
    • sudo apt-get install wine
  • Delete old default wine prefix (only necessary if you already created a default 64-bit one)
    • sudo rm -r ~/.wine
  • Create default 32-bit prefix for wine
    • WINEARCH=win32 winecfg
    • Running the winecfg script will automatically create a new default wine prefix if one doesn’t already exist

Install Office 2010

Installing office in wine is pretty straight forward, and the only preparation you have to do is to install the MSXML6 package with winetricks. Aside from that, I’ve run into no other issues with running microsoft Word or Excel.

  • Install MSXML6 with winetricks

    • winetricks should have been automatically installed along with wine. You can find it by searching your apps with the super button.
    • Alternatively, you can do it from the terminal within Ubuntu using the following command: winetricks MSXML6.
  • Copy the Office2010 installation files from the ISO to your downloads folder.

  • Alternatively, you could try mounting the ISO with furius iso mount, but I haven’t tried this with the Office installation.
  • Now just double click the Office installation exe (or right click and select open with wine). The installer should initialize.

I’ve gotten both Word and Excel working with this method. It seems that the only necessary dependency issue was with MSXML6, and no additional dll’s were required.


All the above steps worked for me on my Toshiba Chromebook 2. Feel free to leave comments if any of the steps are unclear or something isn’t working!