Sunday, November 20, 2016

Install VirtualBox on Arch Linux

Using VirtualBox is something of a daily habit for me. Having the ability to quickly install a virtual machine to without any implications on my laptop is extremely helpful. I go through distros fairly quickly with Arch Linux being the newest trial. With that said, installing VirtualBox on Arch was somewhat of a necessity.

To install VirtualBox, grab the package from pacman with the following command:

sudo pacman -S virtaulbox

Then set the VirtualBox modules to load when Arch boots up by creating the file virtualbox.conf:

sudo nano /etc/modules-load.d/virtualbox.conf

The file did not exist on my install and the editor was blank add these lines:

vboxdrv
vboxnetadp
vboxnetflt
vboxpci
 
Add the your user to vbox group so it can create, manage, and delete virtual machines in the program:

sudo gpasswd -a USER_NAME vboxusers

Finally, reboot and then launch VirtualBox and run virtual machines on your Arch Linux installation.

Friday, August 5, 2016

Static IP on CentOS 7

After a minimal install of CentOS 7 you can change the ifcg-enp0s3 file using vi. To do so, type the following command in the prompt: vi /etc/sysconfig/network-scripts/ifcfg-enp0s3


Here is an example of the file using 192.168.1.10 as the static IP address.

TYPE="Ethernet"
BOOTPROTO="none"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_PEERDNS="yes"
IPV6_PEERROUTES="yes"
IPV6_FAILURE_FATAL="no"
NAME="enp0s3"
UUID=”Long string of characters”
DEVICE="enp0s3"
ONBOOT="yes"
HWADDR=”MAC ADDRESS”
IPADDR=192.168.1.10
PREFIX=24
GATEWAY=192.168.1.1
DNS=192.168.1.1

Save the file by pressing CTRL, and then type wq. This will save the file and quit the editor. Afterwards, you'll need to restart the networking service by typing the following command:

service network restart

Now your CentOS 7 machine has a static IP address and you can remote in via SSH with Putty or from the terminal of another Linux machine.

Monday, July 11, 2016

Install VirtualBox on CentOS

Recently, I switched to CentOS from Windows as my main operating system. Needless to say, not everything I do from day to day can be accomplished on Linux. I still need access to some features Windows has. Mainly their domain tools, because where I work is built on Windows AD. That's where VirtualBox comes in. On most other Linux distros it is as easy as a simple command line and it is installed. Sure it's not the most up-to date version but it does most of what is required from it. Or, on Debian based systems downloading the latest .deb file from Oracle will do the trick.
It's not so easy on CentOS, but it can be done using yum. To start, you need to open up terminal and switch to the root user. This is pretty straightforward with:

su - 
or
sudo -i

then enter the root password. The next step is to add the RHEL repos.

wget http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo

then

yum update

Once the update is complete, perform a reboot.

CentOS 5/6/7 need the EPEL repo in addition to the RHEL repos, the commands for that are here:

## CentOS 7 and RHEL 7 ##
rpm -Uvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-6.noarch.rpm

## CentOS 6 and RHEL 6 ##
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

## CentOS 5 and RHEL 5 ##
rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm

Perform another repo update with

yum update

Next, there are a few prereqrisites that need to be installed before downloading and installing VirtualBox.

yum install binutils gcc make patch libgomp glibc-headers glibc-devel kernel-headers kernel-devel dkms

Then install VirtualBox with:

yum install VirtualBox-5.0

This command automatically creates the vboxusers group and your username must be a part of that group in order for VirtualBox to work. Replace username with your regular username

usermod -a -G vboxusers username

Rebuild the kernel modules for VirtualBox to run:

## CentOS/RHEL 7 ##
/usr/lib/virtualbox/vboxdrv.sh setup
## CentOS/RHEL 6/5 ##
/etc/init.d/vboxdrv setup

If everything went well, you should now be able to launch VirtualBox from either the terminal by typing VirtualBox or by clicking on the icon in the application launcher. Be sure to check the BIOS for enabling Virtualization Support. This wasn't enabled on my desktop at first and VirtualBox wouldn't allow to start any VM's without it enabled.

Sunday, June 26, 2016

Revert TP-LINK MR3020 to Factory Firmware

If at any point you feel like going back to the factory firmware of the TP-LINK MR3020 from OpenWrt, then follow these steps.

  1. Download the stock firmware from here.
  2. Remove the first 0x20200 (131,584 bytes or 257*512) from the original firmware:
    dd if=mr3020-original.bin of=mr3020-modify.bin skip=257 bs=512
  3. Transfer the firmware image to /tmp on the device and revert back to the original firmware
    sysupgrade /tmp/mr3020-modify.bin

The OEM firmware from TP-LINK for the TL-MR3020 with the boot part removed is also available here if you don't have access to dd to modify the firmware yourself. Just search for TL-MR3020-V1 and download the file to your computer.

If you have decided to flash dd-wrt, then there is a archive download here that you can flash via the web GUI to revert back.

TP-LINK MR3020 and OpenWrt

The TP-LINK MR3020 is an inexpensive device that is highly versatile and powerful enough for daily use. Another great feature is that it consumes very little power to run. TP-LINK's stock firmware is not that bad either. However, if you want to really unleash this as an access point then flashing it with OpenWrt will do such that.

To start, download the OpenWrt firmware from here. At the time of writing this the current version is openwrt-ar71xx-generic-tl-mr3020-v1-squashfs-factory.bin then login to the router's web GUI (default address is 192.168.0.254, login/password is admin / admin) and flash the firmware image like a regular firmware update. Wait for the progress bar to finish twice, at which point the device will reset itself, and you can now proceed with the basic configuration as with any OpenWrt first install.

If you feel like you would like more of a GUI experience, then try dd-wrt. The install process is very similar, you need to download a webflash image for first installation.

Saturday, May 21, 2016

OS X Bootable USB

This post is mainly something to write down so there is a place that I can refer back to if I ever need to go back and refer to it later on down the road and not have to dig through a Google search. That may make me sound lazy, but hopefully it can help others as well.

There is a post where I created a multi-boot USB for OS X, but I also needed just a single USB for each version of OS X (Mavericks, Yosemite, and El Capitan). So I am going to break this post up into making a single bootable USB for each version. This assumes that the installer application is located in /Applications on your hard drive. I do like to move it outside of that location so if it is needed later on than it doesn't need to be re-downloaded.

Mavericks:

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

Yosemite:

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

El Capitan:

sudo /Applications/Install\ OS\ X\ El\ Capitan.app/Contents/Resources/createinstallmedia \
--volume /Volumes/Untitled \
--applicationpath /Applications/Install\ OS\ X\ El\ Capitan.app \
--nointeraction

Create OS X NetInstall Images from Command Line

Creating NetInstall images on OS X is quite easy, there are a number of different ways to do so. There are tools such as AutoNBI, or Casper NetInstall Creator. But third party tools are not required to make the NBI for Mavericks, Yosemite, or El Capitan. The System Image Utility is a great tool with a GUI to make the images. The only caveat to this that I have found is that you can only create an image from the installer of that version you are on. So let's say you have a MacBook Pro running Yosemite and you have the Install application for Mavericks in your applications folder. When opening the System Image Utility, it would not recognize the installer.

One way to go around this is to use the imagetool through the command line. This is a Unix Executable File located in the Contents folder of the System Image Utility.

'/System/Library/CoreServices/Applications/System Image Utility.app/Contents/MacOS/imagetool'

From Terminal, this can be run to create a NetInstall Image with the install application that was downloaded from the App Store and no other tools are required. To create a Mavericks NetInstall, I have copied the Install OS X Mavericks.app outside of the Applications folder for safe keeping, but in order to run the tool the installer must be in the Applications folder. Open up terminal and run this command (note, you must be sudo to run):

sudo /System/Library/CoreServices/Applications/System\ Image\ Utility.app/Contents/MacOS/imagetool --netinstall --index 1001 --source '/Applications/Install OS X Mavericks.app' --destination '/Mavericks/NetInstall of Mavericks OS X' --name 'Mavericks NetInstall'

The same can be done with Yosemite on the same MacBook Pro mentioned earlier.

sudo /System/Library/CoreServices/Applications/System\ Image\ Utility.app/Contents/MacOS/imagetool --netinstall --index 1002 --source '/Applications/Install OS X Yosemite.app' --destination '/Yosemite/NetInstall of Yosemite OS X' --name 'Yosemite NetInstall'

In order to create the NetInstall image for El Capitan, the machine MUST be running El Capitan. Otherwise, image tool will throw an error and will not complete. However, on an El Capitan machine the command is the same and you can create all three versions from there.

sudo /System/Library/CoreServices/Applications/System\ Image\ Utility.app/Contents/MacOS/imagetool --netinstall --index 1003 --source '/Applications/Install OS X El Capitan.app' --destination '/El Capitan/NetInstall of El Capitan OS X' --name 'El Capitan NetInstall'

The only version of OS X where the imagetool command is different is in Mavericks, where the executable is located: 

'/System/Library/CoreServices/System Image Utility.app/Contents/MacOS/imagetool'

Sunday, May 15, 2016

Enable epel repo CentOS

The following command for me would not work on my CentOS minimal installation.

sudo yum install epel-release

If this command fails, there is another way to install the epel repo on CentOS. Just make sure that wget is installed. If you are unsure, you can find out if it is installed by typing:

which wget

This should return /bin/wget. If it does not then install wget with

yum install -y wget

Once that is installed, pick which version of CentOS you have and type the commands to install the epel repo

CentOS 5:

wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-5.noarch.rpm
sudo rpm -Uvh epel-release-latest-5*.rpm

CentOS 6:

wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
sudo rpm -Uvh epel-release-latest-6*.rpm

CentOS 7:

wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo rpm -Uvh epel-release-latest-7*.rpm

After that completes, then activate the repo with the following command

yum repolist

With the extra epel repo enabled, you should now be able to install extra software needed to finish setup of the CentOS distro.

Tuesday, May 10, 2016

Ubuntu 14.04 Server Static IP

By default, Ubuntu 14.04 server sets the network interface using DHCP. In most cases this is eth0, but could vary. To set that interface using a static IP address, the interfaces file needs to be edited. At the console type the command in bold to open the nano editor. (Replace nano with your editor of choice). For this exercise we are going to give the server a static IP of 10.0.1.5 in a 24-bit network.

user@server:/# nano  /etc/network/interfaces

Find this line:
iface eth0 inet dhcp

and change dhcp to static, then append the following lines after:
address 10.0.1.5
netmask 255.255.255.0
network 10.0.1.0
broadcast 10.0.1.255
gateway 10.0.1.1
dns-nameservers 10.0.1.2

The last line can be replaced with a public DNS server such as Google, or OpenDNS.  In this, I chose my private DNS server running a simple Bind9 instance in my network. The interfaces file can be saved and exited. Next the nameservers need to be added to the resolv.conf file located at /etc/resolv.conf

user@server:/# nano  /etc/resolv.conf

Add the nameservers of your choice, public or private, or a combination of both, as well as a search domain if you have one, or you can make up one.

nameserver 10.0.1.2
nameserver 10.0.1.3
search network.domain

Save the file and exit. The last step is to add the server name to the hosts file.

user@server:/# nano  /etc/hosts

10.0.1.5    ubuntu-srv.network.domain    ubuntu-srv

Save and exit. The final step is to restart the network service for the server to get the new IP address.

user@server:/# sudo ifdown eth0 && sudo ifup eth0

That's all, from another computer on the local network you should be able to ping the server's static IP address if all went well and there were no errors.

Sunday, April 24, 2016

Linux NetBoot Server with BSDPy and Docker

About a month ago I followed a guide here written by Graham Gilbert on setting up a NetBoot server on Ubuntu Linux using Docker and BSDPy. The guide is a setup using Ubuntu Linux, which is a great write up and very detailed in setting up. However, I needed to rebuild the server and I wanted to use CentOS 7 instead. The differences between the two versions of linux are just enough to have a few minor tweaks to the setup, but for the most part it is very similar. This guide will walk you through setting up Docker and BSDPy on CentOS 7 to get a working NetBoot server in your environment to deploy install or restore images for Mac's. (In my case, because of limited storage this is only going to server install images).

To start, grab a copy of CentOS 7 from the download site. I choose the minimal ISO because there isn't much needed for this. But you can choose the any ISO you want, but it doesn't really matter which on because there is not much needed for this guide unless you need to install the OS without an internet connection. Please note, this setup will be done in VirtualBox, so some things may differ if you are setting it up on a physical machine or in VMware. Once CentOS is installed, we need to make sure we have a network connection. In VirtualBox you will need to change the network adapter to be attached to Bridged Adapter this will give the VM an IP in the same subnet as the rest of your network.

We need to install Docker first, this can be done either from a script or from the Docker repository. I chose to go with the method from the repository. Log into your machine with a super user account that has sudo or root privileges and update the existing packages. Once that has completed add the Docker repo

$ sudo tee /etc/yum.repos.d/docker.repo <<-'EOF'
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/$releasever/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
EOF

Install the Docker package:

sudo yum install docker-engine

then start the Docker daemon:

sudo service docker start

Now that we have Docker installed, it's time to setup a script to download and run the containers needed for the NetBoot server and a directory for the NetBoot (nbi) Images. Graham describes his method of working with containers as placing the necessary files and scripts in the directory /usr/local/docker. It is his way of working and he does not suggest that it is the best, but it is nice to keep things consistent if later on down the road you setup another Docker server on your network. For this guide we are going to follow suite with creating the /usr/local/docker directory and placing the script and data there.

mkdir -p /usr/local/docker/nbi

Now it's time to start working with the startup script. In the text editor of choice, start with the first part of the script that will download the Docker containers for tftpd, netboot-httpd, and bsdpy

#!/bin/bash

docker pull macadmins/tftpd
docker pull macadmins/netboot-httpd
docker pull bruienne/bsdpy:1.0

and make it executable

chmod 755 /user/local/docker/startup.sh

then run it with the command

/usr/local/docker/startup.sh (or if you are working in the /usr/local/docker directory, you can run it with ./startup.sh

At this point, Docker should start downloading the images if everything was installed properly. Then, add a few commands after the last docker pull to stop and remove any running or installed containers. This is not necessary, but it is nice to clean up any prior installs. Also note that it doesn't take much more time to pull and start a new container than it is to start a container that was previously pulled. The benefit of this method is that you know you are running the most current version. Docker will only pull a new container if it has been changed on the Docker hub.

#stop all docker containers
docker stop $(docker ps -a -q)
#remove all docker containers
docker rm $(docker ps -a -q)

Now, to finalize the startup script with getting the server IP and running the containers previously pulled.

#change permissions on /usr/local/docker/nbi
chmod -R 777 /usr/local/docker/nbi

#set IP address as variable
IP=$(ifconfig enp0s3 | awk '/inet / {print$2}')
echo $IP

#run docker containers 
docker run -d \
  -v /usr/local/docker/nbi:/nbi \
  --name web \
  --restart=always \
  -p 0.0.0.0:80:80 \
  macadmins/netboot-httpd

docker run -d \
  -v /usr/local/docker/nbi:/nbi \
  --name tftpd \
  --restart=always \
  -p 0.0.0.0:69:69/udp \
  macadmins/tftpd

docker run -d \
  -v /usr/local/docker/nbi:/nbi \
  --name bsdpy \
  --restart=always \
  -p 0.0.0.0:67:67/udp \
  -e BSDPY_IFACE=eth0 \
  -e BSDPY_NBI_URL=http://$IP \
  -e BSDPY_IP=$IP \
  bruienne/bsdpy:1.0

We can run the script again and at this point, if it was already run before you will notice that Docker is checking for any updates to the containers. You can verify that the containers are running with:

docker ps -a

The only thing left to do is to upload a nbi to the directory /usr/local/docker/nbi from your admin machine or a network share where your images are saved

scp -r /netboot/path/netboot.nbi root@netboothost:/usr/local/docker/nbi

Once the image has been uploaded we can restart the containers on the host with the startup script. Then check the docker logs with:

docker logs bsdpy

If everything went well you should see it found your NBI. If you want to keep the logs open while testing a deployment add -f to the command:

docker logs -f bsdpy

That's all. The NetBoot service has now been moved off the Mac Mini and onto a Linux server. Or in my case, I now have a NetBoot server to install OS X in my organization and don't have to rely on installing from USB.

Saturday, April 16, 2016

CentOS 6.7 Network Card and VMware ESXi Template

Having a CentOS template in a VMware ESXi environment is not like having a Windows Server template when it comes to networking. There are a few gotchas to getting the network card to function after deploying from a template. This KB  from VMware was helpful in detailing what was needed to get the recently deployed template connected to the network.

Because a templates MAC address changes and the CentOS does not update it automatically we need to get the new address. To do this, right click on the virtual machine and go to "Edit Settings" in the "Network Adapter 1" you will find the new MAC address, make note of the last two octets and open the console of the virtual machine. Now you'll need to edit the ifcfg-eth0 configuration file with either vi or nano. My machine only has vi installed. This is located here:

vi /etc/sysconfig/network-scripts/ifcfg-eth0

edit the HWADDR to reflect the new MAC address, save the file and exit.

The next step is to edit the 70-persistent-rules file. This is another configuration file for the network interfaces in CentOS. To edit the file:

vi /etc/udev/rules.d/70-persistent-net.rules

On my virtual machine there were three lines with an eth0 configuration. I removed all but the one that was current with the new MAC address, which is usually the one at the end of the file. After editing, the file was saved and the virtual machine was rebooted. When logging in, the new network card was up and connected to the network.

Wednesday, April 13, 2016

Remotely Enable Windows Remote Desktop

In my organization, Windows Remote Desktop (RDP) is enabled by either Group Policy or Microsoft System Center Configuration Manager (SCCM). Recently there was a case where I moved some machines around in Active Directory, and SCCM did not update all the machines in their device collection query. In part, it disabled RDP on a number of machines. This was nothing critical, but just kept a few users from accessing their desktop while working remotely from home or on the road.

This post is going to guide you on enabling RDP from another computer. There are a few caveats to this, you need to be in a domain environment and be in the administrator group of the machine. This can be done with having the local administrator account on the machine enabled as well but that requires a few extra steps. You will also need to be on the same network as the computer you are trying to access, and you also need to download a copy of PsExec from the Windows SysInternals Suite.

Once you have downloaded PsExec find where it is and move it to either the root of the C:\ or a subfolder. (I like to keep all theses under C:\Tools). Run this command to open a remote command prompt on the remote computer

c:\tools\psexec.exe \\remote_computer cmd

If the firewall is not disabled via group policy than to disable it run:

netsh advfirewall set currentprofile state off

If you don't want to disable the firewall completely, you can set a rule for remote desktop that allows it through the firewall with:

netsh advfirewall firewall set rule group="remote desktop" new enable=Yes

But if you are in a domain setting, it is better to have Windows Firewall turned off for management of the machine and have a separate firewall that is at your gateway. After you have done this, you can start the Remote Registry Service via the MMC (Control Panel > Administrative Tools > Services), right click on "Services (Local), choose "Connect to another computer" and enter the name of the remote computer. Find the "Remote Registry" Service and start it. But leave the startup type to Manual, you don't really want this to be running all the time for security reasons. Leave this window open because we'll need it in a moment.

Now, open regedit and connect to the Remote Registry and enable RDP. Goto File > Connect Network Registry and enter the name of the remote computer and connect to it. Expand HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Terminal Server and change the value of "fDenyTSConnections" from "1" to "0"

Go back to the Services window of the remote computer and find the service called "Remote Desktop Services" and start it, or if it is already running right click and restart the service. Now, you should be able to connect to a remote desktop session of the computer. If you have any problems, then you may want to check your firewall settings because local administrators should have permissions to connect on a fresh install of windows.

**Check the rest of the Windows Sysinternals Suite for more nifty tools.

Sunday, March 13, 2016

Create OS X El Capitan Bootable ISO Image

Creating a bootable ISO of OS X El Capitan is quite easy, if you have access to an OS X machine. You will need a copy of the "Install OS X El Capitan.app" which can be downloaded from the App Store. Once you have it, the application will be in your applications list.

Inside of /Applications/Install OS X El Capitan.app, there is an installation image (InstallESD.dmg). By itself, it is not bootable and cannot be used to install the system on a virtual machine or on an iMac or MacBook without some work. Were going to focus on getting the ISO for installing OS X on a virtual machine. Start off by mounting the InstallESD.dmg image using the tool hdiutil

$ hdiutil attach "/Applications/Install OS X El Capitan.app/Contents/SharedSupport/InstallESD.dmg" -noverify -nobrowse -mountpoint /Volumes/esd

The switches -noverify and -nobrowse make mounting faster and keep the finder application from automatically popping up with a new window. The -mountpoint switch is where we will get the files to copy over. Now it's time to create a placeholder image file for the ISO.

$ hdiutil create -o ElCapitan.cdr -size 7316m -layout SPUD -fs HFS+J

This operation can take a while. When it is complete, you should now have the file ElCapitan.cdr.dmg and it will  need to be mounted to copy the files from the installation image we mounted.

$ hdiutil attach ElCapitan.cdr.dmg -noverify -nobrowse -mountpoint /Volumes/iso

Apple has a tool called asr (Apple Software Restore) which will be used to copy the contents from /Volumes/esd to /Volumes/iso

$ asr restore -source /Volumes/esd/BaseSystem.dmg -target /Volumes/iso -noprompt -noverify -erase

The asr tool will create a newly mounted drive called /Volumes/OS X Base System. This will be used to copy over some files and delete a symbolic link to the packages folder. To remove the invalid link that is not needed run this command:

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

Instead of the invalid link, we need the actual directory which is elsewhere on the image. To copy over the entire directory:

$ cp -rp /Volumes/esd/Packages /Volumes/OS\ X\ Base\ System/System/Installation

Once that is complete, there are some additional dependencies needed for the installer.

$ cp -rp /Volumes/esd/BaseSystem.chunklist /Volumes/OS\ X\ Base\ System/
$ cp -rp /Volumes/esd/BaseSystem.dmg /Volumes/OS\ X\ Base\ System/

The other images can be unmounted, if everything worked properly the ElCapitan.cdr.dmg has everything we need.

$ hdiutil detach /Volumes/esd
$ hdiutil detach /Volumes/OS\ X\ Base\ System

For the last step, we need to convert the IS file into the UDTO format.

$ hdiutil convert ElCapitan.cdr.dmg -format UDTO -o ElCapitan.iso

This will output the ElCapitan.iso.cdr file, which can be renamed to ElCapitan.iso and be used in virtualization software like VMware ESXi or Oracle's VirtualBox. The method described above can also work with OS X Yosemite or Mavericks.

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.

Monday, January 18, 2016

Create Time lapse with FFMPEG and Windows

A recent project I worked on was to create a time lapse of the building of my brother in-law's house. The camera itself was basically a Raspberry Pi that was set up to take a picture every half hour from 6 am to 9 pm. This was accomplished with a simple cron script that ran based on the time of the system clock. There was some drift because it was not connected to the internet and could not get any information from NTP. So it was all based on the time that was set after booting, and since it was powered by a solar panel and battery it could be set up for 3 months without interruption. The only downside was that the 16GB USB stick could not store all the photos for the entire time the camera was taking pictures. It also acted as an access point with a WiFi card so you could SSH into it and monitor the photos folder or download some images without having to take the camera down.

When it was finished, there were a total of 6145 photos, spanning just a little under six months. I found the easiest way to create a time lapse from that many images was to use FFmpeg. It works a little different on windows as it does on Linux, because it doesn't actually install anywhere and it is just an archive file that gets extracted. After downloading, it placed it in a folder called tools on the C:\ drive and opened the command prompt in C:\tools\ffmpeg\bin. (Note the bin folder... That is where the executable for FFMpeg is.)

The command to compile the video was:

C:\ffmpeg\bin>ffmpeg.exe -f image2 -framerate 15 -pattern_type sequence -start_number 0001 -i C:\Images\IMG_%04d.jpg C:\Output\video.avi

-f image2 is the input format
-framerate 15 is setting the video at 15 frames per second
-pattern_type is for using filenames matching the glob pattern set in -i
-start_number is telling FFmpeg to start at image number 0001
-i is the input files, with %04d setting the number with four digits

At the end of it all, I had a pretty nice 5 minute time lapse at about 300 MB in size.


Sunday, January 17, 2016

CentOS 6 Network Configuration

After installing CentOS 6.7 eth0 would not be listed in the output of the ifconfig command. This is because in /etc/sysconfig/network-scripts/ifcfg-eth0 the ONBOOT variable is set to no. If this is changed to yes, and the network service is restarted eth0 becomes active.

Example:

#vi /etc/network-scripts/ifcfg-eth0

DEVICE=eth0
HWADDR=[mac:address]
TYPE=Ethernet
UUID=[some long number]
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=dhcp

Once these changes are saved, then restart the network service with:

#service network restart

If using DHCP, then CentOS can now be updated and other tools can be installed.

Thursday, January 14, 2016

SonicWall Console Cable





Launch a terminal emulation application that communicates with the serial port connected to the appliance. Use these settings:
• 115,200 baud
• 8 data bits
• no parity
• 1 stop bit
• no flow control
Press Enter/Return. Initial information is displayed followed by a DEVICE NAME> prompt.

Exctract Acrobat MSI

Steps to extract the Adobe Reader MSI installation files from the compressed executable:
1. Obtain Adobe Reader from adobe.com: http://get.adobe.com/reader/ and save the file to your desktop.
2. Choose Start > Run.
3. In the Open text box, type: "%UserProfile%\Desktop\AdbeRdr80_en_US.exe"
4. Click OK.
5. When the Adobe Reader Setup screen clears, choose Start >  Run.
6. In the Open text box, type: %temp%
7. Drag the Adobe Reader folder to your desktop.
This folder contains AcroRead.msi and Data1.cab files needed for installation.
Update (thanks to the comment from V23 below)
For Adobe Reader X, the setup files will be extracted to a folder in:
  • %ProgramData%\Adobe\Setup (Windows Vista and above)
  • %ALLUSERSPROFILE%\Application Data\Adobe\Setup (Windows XP / Windows Server 2003)
If you wish to define where the files will be extracted, use the -nos_o switch as follows:
AdbeRdr1010_en_US.exe.exe -nos_o"C:\Folder" -nos_ne
Replace C:\Folder with the path to a local valid folder.  Please ensure the folder is empty as otherwise the existing files and folders may be overwritten/deleted.