How to Create a Bootable OS X Yosemite USB Drive from OS X

Requirements

  1. 8GB+ USB drive with nothing important on it
  2. Computer running OS X

1. In Disk Utility format your USB drive as HFS+

2. Open up a terminal and mount the Yosemite Installer

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

3. Restore the Yosemite InstallESD.dmg to your USB drive.  Replace “USBDrive” with the name of your drive.  You will be prompted for a Yes or No.  Hit y and then Enter to continue and erase all the data on the USB drive.

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

4. Delete and add some packages.

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

5. Copy some more files.

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/

7. Detach the USB Drive

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

8. Plug the drive into a mac and start the installation.

How to set a Static ip Address in OS X from Command Line

You can set a static ip address in OS X with the following command. Replace en0 with the appropriate interface.

sudo ipconfig set en0 INFORM 192.168.10.12

The default ethernet interface on a Mac is usually en0. You can run ifconfig to view all the interfaces available on the machine.

The ip address will last until you reboot.

How to Reset an OS X Password

You first need to boot your Mac into single user mode by booting it up while holding down the “command+s” keys.

Once your in Single User Mode type in

mount -uw /

That will mount your Mac hard drive. Now run

launchctl load /System/Library/LaunchDaemons/com.apple.opendirectoryd.plist

and now you can change the password.  Replace “username” and “password” with the username for the user and the new password.

dscl . passwd /Users/username password

Now you can reboot the machine

reboot

and log in with the new password.

How to Install an OS X .pkg file from Command Line

The following command installs the .pkg to the local hard disk.

installer -pkg /Users/username/Desktop/package.pkg -target LocalSystem

You can also replace “LocalSystem with a “/” they both do the same thing.

If you want to install the package on a different disk you can change the -target to the drives path.

installer -pkg package.pkg -target "/Volumes/Macintosh HD2"

You can find more about the command by typing “man installer” in the terminal.

How to reset Minecraft Demo timer without resetting the World – MacOS

Open up Finder and hit the Shift, Command, and “G” key simultaneously and then type in ~/Library/Application Support/minecraft/saves/Demo_World and hit return.

This should put you in your Demo World minecraft directory.

Now delete the “level.dat” and “level.dat_old” files and restart minecraft.  Your time should now be reset… As well as your Objectives.

Create a Bootable OS X Thumb Drive on Linux

NOTE:  This is a post has not been completely tested.  So use at your own risk.  This text will be removed once the post is completely tested.

 

What you need

  1. InstallESD.dmg
  2. 7zip installed on your computer
  3. Thumb Drive with 8gb of space on it
  4. A few other things installed

Getting Ready

So first we need to make sure we have a few things installed.

yum install hfsplusutils gparted p7zip dmg2img

on Debian based systems use

sudo apt-get install hfsplus hfsprogs hfsutils gparted p7zip-full

Now that we have all the tools we need we can move on.

 

Navigate to were your InstallESD.dmg file is.  Then run the following command.

7z x InstallESD.dmg

After it is finished cd into the InstallMacOSX.pkg

cd InstallMacOSX

now run

dmg2img InstallESD.dmg

Now you have a new file called InstallESD.img.

Open up Gparted (or your favorite disk tool) and find your thumb drive.  Format the drive with a GUID Partition Table and make sure it is HFS+. When it is finished formating, Find the thumb drive and unmount it, and then click restore.  It is under the “More actions” button on the top right.  Find your InstallESD.img file and click Restore.
You are now finished.  Have Fun!

 

 

How to Install wget on OS X

The wget tool is an extremely useful command that allows you to download files from websites from the command line.  Before you begin you should make sure you have Xcode installed.  If you don’t, just download it from the App Store, its free.

To install wget on your mac you first need to download the source code from here.  Next you need to extract the tarball.  You can do this by double clicking the file in Finder or you can run the following command in the terminal

tar -zxvf ~/Downlaods/wget-1.14.tar.gz

Run the rest of these commands in the Terminal app.

Next we will cd into the directory.

cd ~/Downloads/wget-1.14

Then,

./configure --with-ssl=openssl

Make it

make

and finally install it.

sudo make install

And of course make sure it works.

wget --help

Congratulations, you have successfully compiled wget from source.

 

How to create a bootable OS X Mountain Lion (10.8) USB drive from Linux

Found this from here, since it was useful I decided to paste it here.

I saw a few guides on how to make a bootable OS X flash drive, but not many on how to do it without already having access to an OS X machine. Here are my ugly notes on creating a bootable OS X Mountain Lion (10.8)USB drive from/with Linux.

The copy of OS X 10.8 (Mountain Lion) I downloaded was in the form of a file named “InstallESD.dmg”. First, you’ll need to open it. You will need p7zip installed. If you try to dmg2img this file, you won’t get very far, so just extract it with 7-zip:

7z x InstallESD.dmg

The unrolled dmg file I found was 4348218934 bytes in size and had an md5sum of 8b4869920cd740414fe6b7e3f0b1be3e. Inside was another file with the same name (although it is slightly smaller) which is the actual install image. The internal dmg file (the one we really want) was 4333438336 bytes in size and had an md5sum of 68fd407bb74e4a2dd1913ce8bae80fc4. It must be converted prior to mounting, and for this you will need dmg2img installed.

cd InstallMacOSX.pkg 
dmg2img InstallESD.dmg 

The resulting img file was only 137322496 in bytes and had an md5sum of 05b5788f10f7300c457e2aed735eb83a. Now find the offset to properly mount the install partition in the resulting file.

hexdump -C InstallESD.img | grep “48 2b 00 04”
00008400  48 2b 00 04 80 00 01 00  31 30 2e 30 00 00 00 00  |H+……10.0….|

I got “00008400” which is hex for 33792 in decimal:

$echo $((0x00008400))
33792

We need to subtract 1024 from this number to find the target offset:

$echo ‘33792-1024’|bc
32768

Now make the loop device:

losetup -o 32768 /dev/loop0 /path/to/InstallMacOSX.pkg/InstallESD.img

And finally, mount it:

mount -t hfsplus /dev/loop0 /mnt/tmp/or/wherever/you/want

Next, I re-initialized an 8GB USB flash drive with an MSDOS partition table and created an HFS+ partition with gparted after installing these packages: hfsprogs hfsplus hfsutils.

Next, mount the HFS+ USB device R/W and cd to the /mount/point/of/loop/device and copy the contents of the mounted image:

tar cvf – * | tar xvf – -C /mount/point/to/hfs/usb/drive

Sync, unmount, insert USB drive into the Mac and power it on while holding down the OPTION key.