Tag Archives: linux

Arch Linux Running OSX High Sierra In QEMU

I’m not a fan of Mac or OSX by any means however, there comes a time where I need to test either using their native Safari browser or some other native Mac environment. To solve this issue, I set out to install OSX into QEMU. It wasn’t very straight forward but I figured it out so hopefully you won’t have to go through the same issues I had to.  Please make sure to follow along exactly with the steps provided, any missed or skipped step could easily lead to a failed install.

Prerequisites

Make sure you already have QEMU installed on your system.

Also ensure you have cfdisk installed on your system, or something comparible that you’re comfortable using.  We’ll be using this later to create a GPT partition.

You’ll also need to get a hold of an OSX High Sierra ISO.  At the time of this publication I was able to located a download of OSX High Sierra 10.13.1 at High Sierra 10.13.1. If for some reason the provided link is unavailable simply do a search or use an actual OSX install disc.

I found the best luck using the enoch_rev2902_boot BIOS.  At the time of this publication I was able to located a download at enoch_rev2902_boot.  If this specific version is no longer available a later version may work as well.

Create The OSX QEMU Image

First we need to create the OSX QEMU image.  Issue the following command:

qemu-img create -f raw osx 32g

Replace the 32g with the actual hard disk size you want to use (ie. 64g, 128g, 256g, etc.).

Next, let’s create a GPT partition on the “osx” image.  Issue the following command:

cfdisk osx

cfdisk gpt

You should be presented with the above image.  When you are hit enter to select “gpt” as the label type.

cfdsik new partition

Next, select “New” and hit enter.  At this point you can select the size of the partition or partitions you would like to create.  I created a single partition.  Hit enter when you’ve chosen your size or just hit enter for the default max size.

cfdisk write

After the partition has been created, we’ll need to write it back to disk and quit.  Select the “Write” option and hit enter, then when prompted enter “yes” to confirm the writing of the partition to disk and hit enter.  Next, select “Quit” and hit enter.

At this point we’ve created the osx disk image which we’ll be using with QEMU, next we’ll need to configure a boot script for QEMU to load the installer ISO.

Install Mac OSX High Sierra

To make life easy on ourselves, let’s create a start-mac.sh script so that we don’t have to type out a ton of information each and every time we want to launch the qemu image.  Create a start-mac.sh script and add the following to it:

#!/bin/sh

qemu-system-x86_64 \
	-enable-kvm \
	-boot c \
	-m 8192 \
	-machine pc-q35-2.4 \
	-usb \
	-device usb-kbd \
	-device usb-tablet \
	-device isa-applesmc,osk="ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc" \
	-kernel ./enoch_rev2902_boot \
	-smbios type=2 \
	-device ich9-intel-hda \
	-device hda-duplex \
	-device ide-drive,bus=ide.2,drive=MacHDD \
	-drive format=raw,id=MacHDD,if=none,file=./osx \
	-cpu Penryn,vendor=GenuineIntel \
	-smp 4,cores=2 \
	-netdev user,id=eno1 -device e1000-82545em,netdev=eno1,id=vnet0 \
	-device ide-drive,bus=ide.0,drive=MacDVD \
	-drive id=MacDVD,if=none,snapshot=on,file=./macOS_High_Sierra_10_13_1_Official.iso \
        -monitor stdio \

Take note of a few things here.  If you’re network device differs from mine which is “eno1” then rename anything in the -netdev from “eno1” to whatever your network interface is called.  Next, if you named your QEMU disk image anything other than “osx”, make sure you change the -drive line to reflect that.  Lastly, before we move on and spin up the image, make sure you have your High Sierra install ISO and the “enoch_rev2902_boot” BIOS all in the same directory or at least referenced correctly in the start-up script.

Now, let’s set the execute bit on the script and spin it up:

chmod +x start-mac.sh

./start-mac.sh

As the image starts up you should see something like the following:

QEMU BIOS

Hit enter to start the OSX installer.

NOTE: from this point forward if your mouse gets stuck in the QEMU window, use the key combination “CTRL + ALT + G” to release the mouse.

Next you’ll see the following if everything went well:

Apple Start

This will take a while and you may see no progress for quite some time.  Don’t shut the image down, just wait.  Seriously, it could take up to 30 minutes on just that screen along.  Eventually however, you will be presented with the black loading screen:

Apple Black Start

This screen will take a little bit at first too, once again, just be patient it will eventually load.  Eventually you will be presented with the language selection screen.  Go ahead and select your choice of language and hit the next arrow.

DO NOT SELECT “Install macOS” YET, OR IT WILL FAIL!

First we’ll need to drop down into a terminal and format the disk image “osx” we created to be of the proper Apple type.  All the work we did up until this point was just getting it so the Apple installer would recognize it.  Also, don’t try and using the graphical Disk Utility either, it will fail and complain about the the disk saying:

Operation failed...

Running operation 1 of 1: Erase "MacOS"...
Unmounting disk
MediaKit reports nout enough space on device for requested operation.
Operation failed...

Re-partition The OSX Disk

Once you reach the macOS Utilities screen, click on the Utilities drop down at the top of the screen and select the “Terminal”.

macOS Utilies Terminal

Once the “Terminal” app has launched we’ll need to re-partition the disk and format it using a Mac readable format.

Mac Terminal

By default, the disk we’re looking to format should be labelled as “disk2”.  If for some reason you’ve deviated from the above steps your label may be different.  To ensure you’re partitioning the correct drive issue the following command:

diskutil list

Once you’ve identified the correct drive, we’ll need to partition it.  Issue the following command to re-partition the drive:

diskutil partitionDisk /dev/disk2 GPT JHFS+ New 0b

Once complete you should see the following:

diskutil complete

Finally, close the open terminal application and select Terminal -> Quit Terminal from the top drop down.

Now, we can actually install macOS to our drive.  Select the “Install macOS” option and click continue.

macOS Install

Follow the next few screens and agreements until you get to the disk selection screen.

macOS Install

macOS Install Disk Selection

Now you can actually select the installation drive we labelled as “New”.  You may have chosen a different label and if so select that drive and continue the installation.

Shortly after the installer finishes, you may be presented with a black screen and an error which reads:

ParseTagDate unimplemented

ParseTagDate Unimplemented Error

Don’t panic! Hit F12 and the boot BIOS screen will be presented.  Select the “New” drive “hd(1,2) () New”, hit enter and complete the macOS installation.

macOS Install BIOS

At this point you’ll be presented with the gray Apple loading screen.  Once again, this may take quite a while.  Don’t terminate the instance, let it complete fully.

Apple Start

Eventually you’ll be presented with the black Apple loading screen again.

Apple Black Start

Finally, you’ll see the actual install progressing.

macOS Installing

Hooray! After the install completes you’ll see the BIOS boot screen once more.  This time it will contain your Installer, your installed macOS image disk and a recovery disk.  Select your macOS image disk “hd(1,2) (10.13) New”, finish up the welcome installer and enjoy your new OSX QEMU instance.

macOS Install Complete BIOS

Post Install Tweaks

The follow are some final tweaks to make the overall experience a little better.

Screen Resolution

If you see your OSX resolution stuck at something you don’t like say 1024×768, there’s a simple fix that can be applied to change this.  Do the following:

First, apply any Apple updates to the OS currently outstanding or available.

Next, open your “Finder” application, select “Applications” and go to the root of your drive by using Apple/Metakey + Option/Alt + Up arrow.

macOS Drive Root

Create a directory called Extra

macOS Extra Folder

Next, copy the file /Library/Preferences/SystemConfiguration/com.apple.Boot.plist into the /Extra directory you just created.

Now, edit the file and change the following from:

<key>Kernal Flags</key>
<string></string>

org.chameleon.Boot.plist from

To:

<key>Kernal Flags</key>
<string></string>

<key>Graphics Mode</key>
<string>1920x1080x32</string>

org.chameleon.Boot.plist after

Or change it to whatever graphics resolution you would like.  The format of which is:

Next, shutdown the OS completely by selecting “(Apple Icon) -> Shutdown”.  Once the instance has completely shutdown, relaunch manually by issuing:

./start-mac.sh

You should see an error in the QEMU window:

Booting with plist

Press any key and you should see the window resized to the width and height you specified above.  Next, to get rid of the boot error, rename the com.apple.Boot.plist file to org.chameleon.Boot.plist in the /Extra directory.

org.chameleon.Boot.plist

Finally, shutdown fully using the “(Apple Icon) -> Shutdown” and start the instance again using:

./start-mac.sh

Now your resolution should be set and you’re good to go.

Remove the ISO image from the start script

Edit the start-mac.sh script and comment out the last 2 -device and -drive lines:

#!/bin/sh

qemu-system-x86_64 \
	-enable-kvm \
	-boot c \
	-m 8192 \
	-machine pc-q35-2.4 \
	-usb \
	-device usb-kbd \
	-device usb-tablet \
	-device isa-applesmc,osk="ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc" \
	-kernel ./enoch_rev2902_boot \
	-smbios type=2 \
	-device ich9-intel-hda \
	-device hda-duplex \
	-device ide-drive,bus=ide.2,drive=MacHDD \
	-drive format=raw,id=MacHDD,if=none,file=./osx \
	-cpu Penryn,vendor=GenuineIntel \
	-smp 4,cores=2 \
	-netdev user,id=eno1 -device e1000-82545em,netdev=eno1,id=vnet0 \
	#-device ide-drive,bus=ide.0,drive=MacDVD \
	#-drive id=MacDVD,if=none,snapshot=on,file=./macOS_High_Sierra_10_13_1_Official.iso \
        -monitor stdio \

This will remove the macOS Installer selection from the boot BIOS defaulting the selected item to the “New” drive.  Next time you boot, just hit enter and you’re good to go.

How To: Run Arch Linux on Windows 10

Windows 10 has the ability to run a Linux subsystem.  However, you can now run Arch Linux instead of the default Debian thanks to some great work by “turbo” at github.com.  Here’s the skinny on getting this setup.

First, download the alwsl.bat file from: https://github.com/alwsl/alwsl

Next, open a command Windows command prompt and execute the following:

alwsl install

Follow the steps provided by the batch file and voila! Arch Linux on Windows.

Lastly, just open ArchLinux from the Windows menu and enjoy.

I’ve noticed using Arch Linux instead of Debian on Windows appears to have some performance gains, especially around the usage of Vim and other console editors.

Running Graboid on Linux

Want to run Graboid on Linux, cool, here’s how you do it.  First you’ll need to install either wine  to run graboid.

user@computer:$ sudo pacman -S wine

Great, next we’ll need to install Graboid.  The good news is I’ve made it very easy for you, simply download my premade version containing everything you’ll need.

Download: Graboid for Linux

Next unpack the tgz file.

user@computer:$ tar xpf graboid.tgz

Under the Graboid directory you’ll notice two files, the first is the graboid.png file which you can copy to your shared icons directory (on Arch Linux this is /usr/share/pixmaps).  The second is a simple bash script which you can use to launch Graboid from the command line.  Feel free to modify this file until your heart’s content.  Also, if for some reason you can’t execute the graboid file, be sure to change the permissions of the file.

user@computer:$ chmod +x graboid

Lastely, run Graboid.

user@computer:$ ./graboid

I hope this helps you get up and running with Graboid on Linux.  Enjoy!

Web Developer Essential Tools

Foreword

The following highlights what I believe to be the best tools for web development and best of all, they’re all free.  This is a living reference which will be updated as new and better tools are found.  Feedback and suggestions are always welcome.

The List

Google Chrome

Google Chrome

Google Chrome

Light, extremely fast, jam packed with features and a debugger that makes short work of CSS and JavaScript.  The ability to right click inspect an element, change CSS values live in the DOM using up, down arrows or by entering values directly make this an essential tool for web development.

Get Google Chrome

ColorPic

ColorPic

ColorPic

Fantastic color picking tool which allows for obtaining the color values for anything on the screen.  Creation and loading of palettes, values can be slider modified for easy lighting or darkening of tones.  Shortcuts make color selection a cinch.  A must have tool.

Get ColorPic

Tape: Google Chrome Extension

Tape: Google Chrome Extension

Tape: Google Chrome Extension

You know that problem you have in CSS where you’re trying to line up elements either horizontally or vertically and you end up using paper to see if the alignment is correct, well you can forget about doing that ever again.  The Tape plugin allows you to easily place lines on the screen, then you can adjust your CSS to match.

Get Tape Extension

XML Tree: Google Chrome Extension

XML Tree: Google Chrome Extension

XML Tree: Google Chrome Extension

Display XML, RSS any form of node tree in a collapsible human readable format.

Get XML Tree Extension

Awesome Screenshot: Google Chrome Extension

Awesome Screenshot: Google Chrome Extension

Awesome Screenshot: Google Chrome Extension

Quickly screen grab what’s being displayed in the browser, draw, blur, annotate, write, etc. all from within the browser. Save when you’re done either locally or in the cloud.

Get Awesome Extension

LightTable

LightTable

LightTable

LightTable is one of the most robust and unique editors I have ever used.  Extremely powerful, easily customized with more features than I can list here.

Get LightTable

GIMP

GIMP

GIMP

If you’re used to Photoshop, it will take a little bit of a learning curve to get used to GIMP’s shortcuts and approach to image manipulation. However, once you get used to the shortcuts and image editing as a whole, you won’t want to go back. Select an area, resize the selection area by mouse or by shrink or grow amounts, copy then shortcut paste into a new image frame, fast. No more, click save, select extension type from a drop down, confirm, confirm, confirm. Instead, shortcut for save, enter filename with the extension (.png, .jpg, .gif, etc.), hit enter, enter, done. Made for rapid manipulation of images, tons of plugins, filters, great tool.

Get GIMP

Creating Virtual Network Adapters In CentOS

Forward

So here’s the scenario, let’s say for the sake of argument that you have a CentOS linux box running with a single NIC, but you want to have 2 IP addresses assigned to this box (for whatever reason). The following is a step by step guide that will walk you through the process of setting that up.

Getting Started

First, you’ll need to determine the interface name of the network device being used.  For instance, if you’re running a wired ethernet card with a single port, the name is more than likely going to be eth0, if you’re using a wireless card it might be something like wlan0.  First thing you want to do is determine the interface name of this device.  An easy way to do this is to run the following command:

user@computer:$ ifconfig

You should see something similar to the following:

user@computer:$ ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:3D:2B:AD
inet addr:192.168.0.100 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe3d:2bad/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2855541 errors:0 dropped:0 overruns:0 frame:0
TX packets:1205674 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:412143447 (393.0 MiB) TX bytes:539870133 (514.8 MiB)
Interrupt:75 Base address:0x2024

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:4968261 errors:0 dropped:0 overruns:0 frame:0
TX packets:4968261 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2009641198 (1.8 GiB) TX bytes:2009641198 (1.8 GiB)

In this scenario, eth0 is the network interface name and lo is the loopback name.  Now that we know eth0 is the one we want we’ll need to create a virtual device for it (aka. alias).

Create An Network Interface Alias

First, let’s change directory to the network-scripts folder.

user@computer:$ cd /etc/sysconfig/network-scripts/

Next, we’ll copy the ifcfg-<interface_name> to the alias name.

user@computer:$ cp ifcfg-eth0 ifcfg-eth0:0

In this example we are creating a single alias :0 however, you may create as many as you like.  Simply continue to copy the ifcfg-<interface_name> to the desired alias name (ie. ifcfg-eth0:1, ifcfg-eth0:2, etc).

Configure The Alias

Lastly, we need to configure the alias.  This is the step where you physically configure the interface to be static or use DHCP and set the routing information.

For arguments sake let’s configure it to be static.  Open the ifcfg-<interface_name> in the editor of your choice (ie. vi ifcfg-eth0) and set the following.

DEVICE=eth0:0
BOOTPROTO=static
IPADDR=192.168.0.101
NETMASK=255.255.255.0
GATEWAY=192.168.0.1
ONBOOT=yes

Modify each alias configuration file (ie. ifcfg-<interface_name> for each virtual adapter you add) making sure to change the DEVICE, IPADDR, NETMASK and GATEWAY to suit your network.

Once you’ve modified all of the alias configurations for all the aliases you are going to add, restart the network service and you’re good to go.

user@computer:$ service network restart

You can verify that the virtual interfaces are working by pinging each one individually of by running:

user@computer:$ ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:3D:2B:AD
inet addr:192.168.0.100 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe3d:2bad/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2855541 errors:0 dropped:0 overruns:0 frame:0
TX packets:1205674 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:412143447 (393.0 MiB) TX bytes:539870133 (514.8 MiB)
Interrupt:75 Base address:0x2024

eth0:0 Link encap:Ethernet HWaddr 00:25:90:3B:BB:E4
inet addr:192.168.0.101 Bcast:192.168.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:169 Memory:fb5e0000-fb600000

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:4968261 errors:0 dropped:0 overruns:0 frame:0
TX packets:4968261 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2009641198 (1.8 GiB) TX bytes:2009641198 (1.8 GiB)