Coder Social home page Coder Social logo

eprigorodov / mkosxinstallusb Goto Github PK

View Code? Open in Web Editor NEW
44.0 4.0 10.0 18 KB

Linux shell script that creates USB flash drive booting OS X installer

License: Apache License 2.0

Shell 100.00%
osx linux installer usb boot maverick yosemite elcapitan

mkosxinstallusb's Introduction

mkosxinstallusb

Linux shell script that creates bootable USB flash drive with OS X installer.

OS X installer application contains a disk image "InstallESD.dmg" that can be used to create a bootable USB flash drive. The procedure is well described in the media, see references below.

This script automates process on Linux platform, doing essentially the following:

mkdir -p /mnt/OSX_InstallESD /mnt/OSX_BaseSystem /mnt/usbstick

# convert installer disk image to raw format
dmg2img "Install OS X <Version>.app/Contents/SharedSupport/InstallESD.dmg" InstallESD.img
kpartx -a InstallESD.img
mount /dev/mapper/loop0p2 /mnt/OSX_InstallESD

# convert base system disk image to raw format
dmg2img /mnt/OSX_InstallESD/BaseSystem.dmg BaseSystem.img
kpartx -a BaseSystem.img
mount /dev/mapper/loop1p1 /mnt/OSX_BaseSystem

# partition the USB flash drive, /dev/sdX
sgdisk -o /dev/sdX
sgdisk -n 1:0:0 -t 1:AF00 -c 1:"disk image" -A 1:set:2 /dev/sdX
mkfs.hfsplus -v "OS X Base System" /dev/sdX1
mount /dev/sdX1 /mnt/usbstick

# copy installer files
rsync -aAEHW /mnt/OSX_BaseSystem/ /mnt/usbstick/
rm -f /mnt/usbstick/System/Installation/Packages
rsync -aAEHW /mnt/OSX_InstallESD/Packages /mnt/usbstick/System/Installation/
rsync -aAEHW /mnt/OSX_InstallESD/BaseSystem.chunklist /mnt/usbstick/
rsync -aAEHW /mnt/OSX_InstallESD/BaseSystem.dmg /mnt/usbstick/
sync

Usage: ./mkosxinstallusb.sh </dev/sdX> "Install OS X <Version>.app", where </dev/sdX> is a block device for target USB flash drive, e.g. /dev/sdb.

Known problems:

References:

mkosxinstallusb's People

Contributors

eprigorodov avatar mvastola avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

mkosxinstallusb's Issues

High Sierra

I know that the readme states:

High Sierra installers are not supported yet,

But do you know of a manual way of creating the bootable USB?

Suggestion: Ensure USB disk is properly configured

This is just a suggestion.

In my case, I had used the USB stick for other stuff and was previously imaged with dd, so despite the stick being physically 8Gb, my Linux was only seeing it as a much smaller disk (2Gb). This caused issues later on when rsyncing the Packages folder onto the stick as it was running out of space!.

The solution for me was to do this to my stick before running the mkosxinstallusb script:

sudo dd if=/dev/zero of=/dev/sdb bs=1M status=progress
sudo sync

That made it be an 8Gb disk again.

Maybe mkosxinstallusb could incorporate this step before running sgdisk -o $stick_dev to make the process more robust for some corner cases. Something like this:

[...]
echo "\n# partitioning USB drive"
if [ -b "$stick_dev" ]
then
    for device in $(lsblk -lnp -o NAME "$stick_dev" | tac)
    do
        umount -l "$device" 2>/dev/null || true
    done
fi
dd if=/dev/zero of=$stick_dev bs=1M status=progress
sync
sgdisk -o $stick_dev
sgdisk -n 1:0:0 -t 1:AF00 -c 1:"disk image" -A 1:set:2 $stick_dev
sync
[...]

The installer fails if date is out of sync

HOW TO REPRODUCE:

  1. Reset the Mac SMC, by on boot up holding the keys Command (โŒ˜), Option, P, and R.
  2. With a MacOS USB try to install the system.

RESULT:
The installer complains that it's unable to continue due to missing packages.

SOLUTION:
In readme.md indicate the fix:
"If the installer is unable to find the packages, in the utility "Terminal" enter (using two digit fields): date [month][day][hour][minute][year]"

REFERENCES:
https://discussions.apple.com/thread/7251878

I don't have a BaseSystem.dmg

Hi there,

I tried this with the El Capitan DMG downloaded from Apple. The file is named InstallMacOSX.dmg (not InstallESD.dmg, I have searched google for this file but the one offered by Internet Archive is just the same "InstallMacOSX.dmg" file I already have from Apple).

When I convert to .img and mount, I don't have a "BaseSystem.dmg" file in the mounted dir, just a InstallMacOSX.pkg".... what did I do wrong? I don't have access to a Mac running MacOS, so I can't get any "InstallESD.dmg" from a system folder.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.