Sunday, February 28, 2016

Multi-Boot OS X USB

Having a bootable OS X installer on USB is essential for any technician or administrator to have with them. Sometimes the installer doesn't cover every model of MacBook, or iMac. Instead of carrying around three or four different USB sticks, and since a 32GB or even 64GB USB is so cheap; why not create one USB with the different installers you need?

Following the Building an OS X Triage Drive at The Instructional, I decided to create a bootable USB with Mavericks (10.9), Yosemite (10.10), and El Capitan (10.11). This covers most of the Mac's supported by my organization because for the most part we don't deal with imaging, we just re-install the os when we have any problems. In the beginning, I ran into a couple of problems of creating the bootable USB. When I ran this command to create the Mavericks partition

sudo /Applications/Install\ OS\ X\ Mavericks.app/Contents/Resources/createinstallmedia --volume /Volumes/Mavericks-I --applicationpath /Applications/Install\ OS\ X\ Mavericks.app --nointeraction

and booted the Mac into the installer; it said that the installer could not complete because it may have been corrupted during download. Verifying the checksum, everything looked normal. So I tried it with the Install OS X Yosemite.app as well. Same thing, it would not install and gave the same prompt.

I'm getting a little ahead of myself. Let's start with partitioning the USB. I picked up a 64GB PNY USB 3.0 at Best Buy for less than $20. All of this was done in terminal. First we need to discover the disk we will partition, to find this out plug in the USB and use the command:

diskutil list

In my case, it was /dev/disk1 you may need to replace for the rest of the tutorial, just be cautious as to not delete other partition on any other drives you may have connected. I am not responsible for the loss of any data.

We need to create three journaled HFS+ (JHFS+) partitions. To do this the command is:

diskutil partitionDisk /dev/disk2 GPT JHFS+ Mavericks 7g JHFS+ Yosemite 7g JHFS+ ElCapitan 7g JHFS+ SpareVolume 0b

Note that this is all one line; formatting of the blog separates  it into multiple lines. Also, the SpareVolume partition is not created as an empty partition, that particular combination uses all the extra space. Once that completes it's time to copy the installers.

Copying Mavericks Installer

You can copy and paste these commands into terminal and press return after. You'll want the local administrator password, or an account that has local admin privileges.

sudo hdiutil attach /Applications/Install\ OS\ X\ Mavericks.app/Contents/SharedSupport/InstallESD.dmg

sudo asr restore -source /Volumes/OS\ X\ Install\ ESD/BaseSystem.dmg -target /Volumes/Mavericks -erase -format HFS+

This step will prompt you to confirm that you want to erase the partition Mavericks. Press y and then return.

sudo rm /Volumes/OS\ X\ Base\ System/System/Installation/Packages

sudo cp -a /Volumes/OS\ X\ Install\ ESD/Packages /Volumes/OS\ X\ Base\ System/System/Installation/Packages

sudo cp -a /Volumes/OS\ X\ Install\ ESD/BaseSystem.chunklist /Volumes/OS\ X\ Base\ System

sudo cp -a /Volumes/OS\ X\ Install\ ESD/BaseSystem.dmg /Volumes/OS\ X\ Base\ System 

hdiutil detach /Volumes/OS\ X\ Install\ ESD

Once you're done, the volume is now named Mac OS X Install ESD to make it easier to know which one is the installer we want, rename it with the following commands:

diskutil rename "Mac OS X Install ESD" "Mavericks"

and change the boot label for the volume by using: 

sudo bless --folder "/Volumes/Mavericks" -label "Mavericks Install"

Copying Yosemite Installer

You can copy and paste these commands into terminal and press return after. You'll want the local administrator password, or an account that has local admin privileges.

sudo hdiutil attach /Applications/Install\ OS\ X\ Yosemite.app/Contents/SharedSupport/InstallESD.dmg

sudo asr restore -source /Volumes/OS\ X\ Install\ ESD/BaseSystem.dmg -target /Volumes/Yosemite -erase -format HFS+

This step will prompt you to confirm that you want to erase the partition Yosemite. Press y and then return.

sudo rm /Volumes/OS\ X\ Base\ System/System/Installation/Packages

sudo cp -a /Volumes/OS\ X\ Install\ ESD/Packages /Volumes/OS\ X\ Base\ System/System/Installation/Packages

sudo cp -a /Volumes/OS\ X\ Install\ ESD/BaseSystem.chunklist /Volumes/OS\ X\ Base\ System

sudo cp -a /Volumes/OS\ X\ Install\ ESD/BaseSystem.dmg /Volumes/OS\ X\ Base\ System 

hdiutil detach /Volumes/OS\ X\ Install\ ESD

Once you're done, the volume is now named Mac OS X Install ESD to make it easier to know which one is the installer we want, rename it with the following commands:

diskutil rename "Mac OS X Install ESD" "Yosemite"

and change the boot label for the volume by using :

sudo bless --folder "/Volumes/Yosemite" -label "Yosemite Install"

Copying El Capitan Installer

You can copy and paste these commands into terminal and press return after. You'll want the local administrator password, or an account that has local admin privileges.

sudo hdiutil attach /Applications/Install\ OS\ X\ El\ Capitan.app/Contents/SharedSupport/InstallESD.dmg

sudo asr restore -source /Volumes/OS\ X\ Install\ ESD/BaseSystem.dmg -target /Volumes/ElCapitan -erase -format HFS+

This step will prompt you to confirm that you want to erase the partition ElCapitan. Press y and then return.

sudo rm /Volumes/OS\ X\ Base\ System/System/Installation/Packages

sudo cp -a /Volumes/OS\ X\ Install\ ESD/Packages /Volumes/OS\ X\ Base\ System/System/Installation/Packages

sudo cp -a /Volumes/OS\ X\ Install\ ESD/BaseSystem.chunklist /Volumes/OS\ X\ Base\ System

sudo cp -a /Volumes/OS\ X\ Install\ ESD/BaseSystem.dmg /Volumes/OS\ X\ Base\ System 

hdiutil detach /Volumes/OS\ X\ Install\ ESD

Once you're done, the volume is now named Mac OS X Install ESD to make it easier to know which one is the installer we want, rename it with the following commands:

diskutil rename "Mac OS X Install ESD" "ElCapitan"

and change the boot label for the volume by using :

sudo bless --folder "/Volumes/ElCapitan" -label "El Capitan Install"

You should now have a bootable OS X USB with three installers that you can select at boot by holding down the option key and be able to select which installer you would like to use.

Saturday, February 27, 2016

SonicWALL NetExtender on Ubuntu

Dell's SonicWALL firewall is a pretty nifty appliance with many variations of the NetExtender client for Windows, OS X, and even Linux variants. (Although, I should note that now the OS X client can be downloaded from the app store and has been rebranded as SonicWALL mobile connect). If you'd like to test the NetExtender's functionality on Linux it's quite easy to install, even if you don't have access to a SonicWALL. (There's a demo site here)

Please note that you must have Oracle JDK installed, the Open JDK is not supported.

Follow these steps to install the NetExtender clieet on Ubuntu:

  1. Go to https://sslvpn.demo.sonicwall.com/cgi-bin/welcome
  2. Login with demo/password
  3. Click on the NetExtender Icon... This will download the .tar.gz
  4. Unpack the client archive
    • tar -xzvf NetExtender.Linux.8.1.789
  5. Type chmod +x ./install (This makes the installer executable)
  6. Run the install sudo ./install
  7. Enter the sudo password and follow the prompts
The main thing to note when installing the NetExtender client is that it asks if you'd like to make it available to non-Root users. You can do so, however it may pose a security risk. If the install is successful, the output should look like this:

administrator@ubuntu:~/Downloads/netExtenderClient$ sudo ./install 
[sudo] password for administrator: 
— Dell SonicWALL NetExtender 7.5.768 Installer —
Checking library dependencies…
Checking pppd…
  Do you want non-root users to be able to run NetExtender?
  If so, I can set pppd to run as root, but this could be 
  considered a security risk.
  Set pppd to run as root [y/N]? N
  You have chosen NOT to allow non-root users to run NetExtender.
Copying files…
———————— INSTALLATION SUCCESSFUL ———————–
To launch NetExtender, do one of the following:
  1. Click the NetExtender icon under the Applications menu
     (look under the ‘Internet’ or ‘Network’ category)
     or
  2. Type ‘netExtenderGui’

You can launch the client from either the terminal using netExtenderGui, or look for the icon in the applications menu.

Updating Oracle JDK on Ubuntu 14.04

After we've installed the Oracle JDK, we may need to update it for either security or development reasons. To do so, simply download an updated version from Oracle's website and extract it to the /opt/jdk directory that was made when installing, then set it up as the default JVM with a higher priority number (for this example 110)

update-alternatives --install /usr/bin/java java /opt/jdk/jdk.new.version/bin/java 110
update-alternatives --install /usr/bin/javac javac /opt/jdk/jdk.new.version/bin/javac 110

The old version can be kept on your machine. Or it can be deleted:

update-alternatives --remove java /opt/jdk/jdk.old.version/bin/java
update-alternatives --remove javac /opt/jdk/jdk.old.version/bin/javac

rm -rf /opt/jdk/jdk.old.version

That's all you need to do to update the Oracle JDK on Ubuntu or any variant of the Debian OS.

Install Oracle JDK on Ubuntu 14.04

This is a guide on how to manually install Oracle's Java on Ubuntu 14.04, or any of it's variants. Since Oracle Java is proprietary that is free to download or use commercially, but not to distribute; it is not included in any officially maintained repository. There are plenty of guides that have you add an unofficial repository from the webupd8team's ppa. In my case, I wanted to keep my system limited to the number of unofficial repositories needed.

The first thing you will need to do is determine the architecture of your system, 32 bit or 64 bit. Inside of the terminal run the command:

uname -m
  • x86_64 = 64 bit kernel
  • i686 = 32 bit kernel

Next we need to download Oracle's Java JDK. In a web browser go to the Java SE - Downloads page and select the JDK Download link. We will install the JDK Java SE Development Kit 8 x64. Accept the License Agreement and copy the download link for the tar.gz. Make sure you select the right one for your OS and use wget to download the archive, and since Oracle does not allow downloads without accepting the license modify the header of the request. I like to be in the /tmp directory while downloading and software or packages. That way it makes for easy clean up after the install.

wget --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u73-b02/jdk-8u73-linux-x64.tar.gz

Be sure to get the latest version from Oracle's site; since it is updated frequently after writing this there may be a new version. Or if you require a specific version, replace it with the one you need.

Now it's time for the install. To do this you will need sudo privileges. You can achieve this by either typing:

sudo su

or.. typing sudo before each of the following commands.

The /opt directory is reserved for packages that are not part of the default installation. Create a directory for JDK:

mkdir /opt/jdk

Extract the java packaged into the /opt/jdk directory we just made:

tar -zxf jdk-8u73-linux-x64.tar.gz -c /opt/jdk

To finish the install we need to set the Oracle JDK as the default. The java executable is located under /opt/jdk./jdk1.8.0_73/bin/java to set it as the default run the following commands:

update-alternatives --install /usr/bin/java java /opt/jdk/jdk1.8.0_73/bin/java 100

and

update-alternatives --install /usr/bin/javac javac /opt/jdk/jdk1.8.0_73/bin/javac 100

And that's it. Oracle's Java is now installed. But to just verify that nothing went wrong and it has successfully been configured, run:

update-alternatives --display java

and

update-alternatives --display javac

If the output looks like this:

java - auto mode
link currently points to /opt/jdk/jdk1.8.0_05/bin/java
/opt/jdk/jdk1.8.0_05/bin/java - priority 100
Current 'best' version is '/opt/jdk/jdk1.8.0_05/bin/java'.

javac - auto mode
link currently points to /opt/jdk/jdk1.8.0_05/bin/javac
/opt/jdk/jdk1.8.0_05/bin/javac - priority 100
Current 'best' version is '/opt/jdk/jdk1.8.0_05/bin/javac'.

You're all set and you're ready to be using the Java JDK from Oracle.