Jump to content

Upgrade Your Boot Volume to Chameleon 2.0-RC1


zhell
 Share

21 posts in this topic

Recommended Posts

Upgrade Your Boot Partition to Chameleon 2.0-RC1

 

The attached script upgrades the boot loader on your boot partition to the recently released Chameleon 2.0-RC1. It also saves a backup of the current boot loader and allows you to restore with a single command.

Note: The script assumes that you have a separate boot loader volume which contains nothing but the boot loader (Chameleon, PC-EFI,...) and you have Mac OS X installed on its own volume referred to as the system volume.

 

Important Note

 

The official installer for Chameleon 2.0-RC1 is out. If you are not used to the Terminal, please use that.

 

Chameleon 2.0-RC1 is a moving target. The script has been tested for build 431. To use it for a newer build, you need to change the BUILD variable at the top of the script.

 

The layout of the downloaded file Chameleon-2.0RC1-r431-bin.tar.gz may change in future buids. Currently, you need to rename the directory "Optional Extras" to "Extra" for these items to be installed. Also, you may want to remove or edit "smbios.plist". Chameleon 2 has SMBIOS resolution built-in and "smbios.plist" is only needed to fix things it could not get from the BIOS.

Note that the script will remind you if you forget to make those changes or if something else seems amiss.

For versions after 431, further adaptations may be necessary.

 

Update: Version 3

 

As before, the script does not perform any modifications to your system unless you call it with the variable "MODIFY=1" set (see below how to do that). In addition, the script now shows you what would be done and asks you to press a key before it continues, even when "MODIFY=1" is set.

 

Furthermore, you can now restore the earliest or the latest boot loader version that you installed with the script (only Chameleon 1.0.11--2.0-RC1 and PC_EFIv9 have been tested).

 

Custom kernels, such as the Vodoo kernel are not touched (neither overwritten, nor saved). If somebody knows where Chameleon 2 expects the Vodoo kernel to be, please let me know.

 

You are using this script at your own risk.

 

Prerequisites

 

Your boot partition needs to be set up already with Chameleon 1.0.11 or PC_EFIv9, using the "Extra" folder on the boot volume.

Otherwise the script is not for you and it will NOT do anything.

 

If you use Munky's EFI boot method, please use the script in Munky's tutorial topic.

 

Restoring the previous boot loader requires that you be able to boot; if the modification goes wrong, you will need some other disk.

 

Ask yourself how you are going to fix your boot partition if something goes wrong. Remember, this script and Chameleon 2.0-RC1 are not yet widely tested.

 

As said before, if you just call the script, it will not change anything. So giving it a try is safe.

 

If you are convinced that you want to try it, proceed as follows.

 

Preparation

 

First of all, find and download "Chameleon-2.0RC1-r431-bin.tar.gz".

 

Ensure that it was downloaded to your "Downloads" folder in your home directory. Safari will extract it halfway and you will end up with the file

/Users/<your user name>/Downloads/Chameleon-2.0RC1-r431-bin.tar

 

To extract this TAR archive, run the following in Terminal:

cd Downloads
tar xf Chameleon-2.0RC1-r431-bin.tar.gz

If you did not download the file with Safari, it may still have the ending ".tar.gz". In this case, replace "tar xf" above by "tar xzf".

 

Second, download the latest version of the attached ".zip" file and extract the shell script. You may leave it in your Downloads folder, but please ensure it is called "chameleon-2.sh".

 

 

Basic Usage [Version 3]

 

The script is a simple bash shell script that is run in the Terminal.

 

In its present state, the script does not modify anything, it only shows you what it would do.

 

First of all, perform a dry-run, as follows.

  1. Open Terminal and make sure you have a fresh Terminal window (if Terminal is running already, open a new window)
  2. Drag-and-drop the script "chameleon-2.sh" into the Terminal window (do NOT press [Return] yet)
  3. Go to the Finder (i.e. click on the desktop), press Command+Shift+C to open a window at "Computer" and drag-and-drop the boot volume to the Terminal window. This should insert a path that begins with "/Volumes/". Note: Do not drag the volume icon from the sidebar of the Finder window, as this will only provide a cloud of smoke and the icon will go "Poof!".
  4. The command line should now look similar to the following:[/b][/color]
    /Users/admin/Downloads/chameleon-2.sh /Volumes/boot


  5. Take a deep breath and press Return

That's it. Well, almost. The above command will only output what would be done.

 

To actually modify your disk, you need to prepend "MODIFY=1" (plus a space) to the above command line, i.e. the command line should look like

MODIFY=1 /Users/admin/Downloads/chameleon-2.sh /Volumes/boot

 

To achieve this, press the up arrow key once and then move the cursor to the far left using the left arrow key. Finally, type "MODIFY=1 " and hit Return again. Do not forget the space after "MODIFY=1".

 

You may edit the script such that it always modifies by default (see comments in script), but this is not recommended.

 

 

Advanced Usage

 

The script takes two arguments:

First argument: path to the mounted boot partition

Second argument (optional): path to the boot loader, i.e. to a directory that contains subdirectories "Extra" and "i386".

 

To restore, specify "earliest" or "latest" as the second argument. This will restore the "earliest"/"latest" version saved by this script.

You may also provide a complete path to the directory where the boot loader you want to restore is saved. See the script code for details.

 

If you want to capture the commands which the script would run, just redirect STDERR to /dev/null (WITHOUT prepending "MODIFY=1" of course):

/Users/admin/Downloads/chameleon-2.sh /Volumes/boot 2>/dev/null

 

 

Source

 

Note: This is version 3. Minor updates will only be provided as attachments.

#!/usr/bin/env bash

# No unset variables
set -u
# Exit on error
set -e


# Chameleon build number
BUILD=431

# Set MODIFY to 1 to perform modifications
MODIFY=${MODIFY-0}
#MODIFY=1

# Set VERBOSE to 0 to run silent
VERBOSE=${VERBOSE-1}
#VERBOSE=0

# You either need to specify one argument
# or hardcode the following variable definition.

# BOOT_VOLUME is the mount point of your boot partition,
# e.g. if the volume is called "boot", this would be "/Volumes/boot"
# By default, this variable is not set and read from argument 1.
BOOT_VOLUME=
# To hardcode:
# BOOT_VOLUME=/Volumes/boot

# Path to new bootloader folder. 
# You may override this by passing a directory path as the second argument
BOOTER_SRC="$HOME/Downloads/Chameleon-2.0RC1-r${BUILD}-bin"

# Items from the Chameleon-2.0RC1-r${BUILD}-bin "Extra" directory

# Note: The name of the "Extra" directory in the download 
# archive of Chameleon 2 has changed in the past.
# Currently, it seems to be "Optional Extras", with the intention of
# forcing the user to pick from this directory only those items 
# that they want to install.
# 
# Please check if the directory "$BOOTER_SRC/Extra"
# exists and you have read permissions.
# If not, then you either create a new directory there called "Extra"
# and copy over the things that you want to install,
# or you just rename "Optional Extras" to "Extra"

# As this may change, please check if the list is still valid for your version
# of Chameleon 2 and if you really need or want all these items
# Note: If any item does not exist, the script aborts
SRC_EXTRA_ITEMS=('Themes')
# Optional: Config file to fix SMBIOS values (CPU clock, memory clock, etc.)
#SRC_EXTRA_ITEMS+=('smbios.plist')

# To restore from BACKUP, there are two options.
#
# 1. Manually set BOOTER_SRC to the path of the
#    backup directory you wish to restore from, e.g.
#BOOTER_SRC="$BOOT_VOLUME/Library/Archive/Boot_2009-04-01_172932"
#
# 2. Let the script automatically find the earliest or latest backup directory
#    by passing "earliest" or "latest" as the second argument


             ######## NOTHING TO EDIT BELOW ###############

# Determine path to this script
scr_p="${BASH_SOURCE[0]}"; [ -z "$scr_p" ] && exit 2
while ([ -h "${scr_p}" ]); do scr_p="`readlink "${scr_p}"`"; done
SCRIPT_PATH="$(cd "$(dirname "${scr_p}")" > /dev/null && pwd)"; unset scr_p
SCRIPT_FILE="$SCRIPT_PATH/$(basename "${BASH_SOURCE[0]}")"
[ -f "$SCRIPT_FILE" ] \
|| echo "Fatal error: Unable to determine path to script file
\"${BASH_SOURCE[0]}\""


DEBUG=${DEBUG:=0}
VERBOSE=${VERBOSE:=0}

function leave() {
   result=${1-1}

   # Remove signal traps
   trap - EXIT INT TERM KILL

   # Print leave message if function exists
   [[ `type -t leav_msg` = "function" ]] && leave_msg
   exit $result
}

function deb () {
   if [ -z "$*" ]; then
       echo "Usage: deb <word1> <word2> ..." >&2
       return 1
   fi
   local str opt
   str="$1"; opt=${2-''}
   [[ "$opt" && "$opt" = "c" ]] || str="$str\n"
   if [ $DEBUG -eq 1 ]; then
       printf "DEBUG: <| ${*} |>" >&2
   fi
}

function say () {
   if [ -z "$1" ]; then
       echo "Usage: say <string> ..."
       return 1
   fi
   local str opt
   str="$1"; opt=${2-''}
   [[ "$opt" && "$opt" = "c" ]] || str="$str\n"
   if [ $VERBOSE -eq 1 ]; then
       printf "$str" >&2
   fi
}

function nfy () {
   if [ -z "$1" ]; then
       if [ -t 1 ]; then
           echo "Usage: wrn <string> ..." >&1
       else
           echo "Usage: wrn <string> ..." >&2
       fi
       return 1
   fi
   local str opt
   str="$1"; opt=${2-''}
   [[ "$opt" && "$opt" = "c" ]] || str="$str\n"
   if [ -t 1 ]; then
       printf "$str" >&1
   else
       printf "$str" >&2
   fi
}

function wrn () {
   if [ -z "$1" ]; then
       if [ -t 1 ]; then
           echo "Usage: wrn <string> ..." >&1
       else
           echo "Usage: wrn <string> ..." >&2
       fi
       return 1
   fi
   local str opt
   str="\n$1"; opt=${2-''}
   [[ "$opt" && "$opt" = "c" ]] || str="$str\n"
   if [ -t 1 ]; then
       printf "$str" | sed -E 's/^/### /' >&1
   else
       printf "$str" | sed -E 's/^/### /' >&2
   fi
}

PATH_RE='^/'
function clean_path () {
   if [ -z "$*" ]; then
       say "Usage: clean_path <path>"
       return 1
   fi
   local path
   if path="$(set +e; cd "$1" 2>/dev/null && pwd )"; then
       if [[ $path =~ $PATH_RE ]]; then
           echo "$path"
           return 0
       fi
   else
       say "\n\nError: Invalid path \"$1\"" >&2
       say "   Make sure to specify an absolute path" >&2
       say "   where you have listing permission (try \"ls $1\")" >&2
       say "   and that matches regex \"$PATH_RE\"" >&2
       return 2
   fi
}

function runcmd() {
   if [[ -z "$*" ]]; then
       say "Usage: runcmd <command> <arg1> <arg2> ..."
       return 1
   fi
   deb $*
   local cmd_type cmd_ok cmd_err cmd args
   cmd_ok=0; cmd_err=''; args=''

   if cmd_type="$(type -t "$1")"; then

       case $cmd_type in
           builtin)
           cmd="$1"
           cmd_ok=1
           ;;

           file)
           cmd="$(type -p "$1")"
           [[ $? -eq 0 ]] && cmd_ok=1
           cmd_err="   Command \"$1\" not in \$PATH.\n    PATH=\"$PATH\"\n"
           ;;

           *)
           cmd_err="   Invalid type of command \"$1\": \"$cmd_type\"\n"
           ;;
       esac

   else
       wrn "\n\nError: Cannot run command line\n\n    $*\n\n"
       wrn "   Unable to determine type of command \"$1\"\n"
       return 2
   fi
   if [ $cmd_ok -ne 1 ]; then
       wrn "\n\nError: Cannot run command line\n\n    $*\n\n"
       wrn "$cmd_err"
       return 2
   fi
   while shift && [[ $# -gt 0 ]]; do
       if [[ ! -z "$1" ]]; then
           args="$args '$1'"
       fi
   done
   args="${args# }"
   [[ $VERBOSE -eq 1 ]] && echo $cmd $args
   [[ $MODIFY -eq 1 ]] || return 0

   if ! echo $cmd $args | $SHELL; then
       wrn "\n\n### Error running command \n
$cmd\n
   with arguments\n
$args\n
   Working directory:\n
$(pwd)\n"
       return 3
   fi
}

function usage() {

   say "\nUsage: `basename $0` <boot volume> \\
       [ <boot loader dir> | earliest | latest ]

First argument [REQUIRED]
   <boot volume>: directory where your boot volume is mounted.
       Example: /Volumes/boot

Second argument [OPTIONAL]
   EITHER of:
   <boot loader dir>: directory holding the boot loader.
       Example: \"$HOME/Downloads/Chameleon-2.0RC1-r${BUILD}-bin\"
       Required subdirectories:
       <dir>/i386:
           boot0, boot1h, boot
       <dir>/Extra:
           Themes
           Optional items:
           [smbios.plist], [com.apple.Boot.plist], [DSDT.aml]

   earliest:
       Restore earliest saved boot loader configuration

   latest:
       Restore latest saved boot loader configuration

Important: Only absolute paths are supported, i.e.,
paths that begin with a forward slash '/'.
\n"
   leave 1
}

function leave_msg() {

   say "\n\nPrinting diagnostic output\n"
   say "Run on `date '+%Y-%m-%d at %H:%M:%S'`\n"
   say "\nOutput of \"mount\":\n"
   mount
   say "\nOutput of \"env\":\n"
   env
}

# Set to 1 to disable prompt for confirmation
JUST_DO_IT=

INTERACTIVE=
if [ -t 0 ] && [ -t 1 -o -t 2 ]; then
   INTERACTIVE=1
fi

if [[ $# -lt 1 || $# -gt 2 ]] \
   || [[ -z "$1" || "$1" = "unset" \
       || "$1" = "-h" || "$1" = "*-help" ]]; then
   usage
else
   BOOT_VOLUME="$(clean_path "$1")"
fi

# Contents of "i386" directory in boot loader directory.
# This list will almost surely NOT change.
# In the unlikely event that one of those files is provided
# under a different name, DO NOT just adopt the list below
# as messing up these files will probably ERASE YOUR ENTIRE DISK.
# Note: If any item does not exist, the script aborts
SRC_BIN_ITEMS=('boot0' 'boot1h' 'boot')

# Directory to save current bootloader
BACKUP="$BOOT_VOLUME/Library/Archive"

BOOTER_SAVE="$BACKUP/Boot_`date '+%Y-%m-%d_%H%M%S'`"

#
# Check if user wants to restore
#
ARG2=${2-''}
ARG3=${3-''}

LATEST_RE='^latest$'
EARLIEST_RE='^(restore|earliest)$'
RESTORE_RE="$LATEST_RE|$EARLIEST_RE"
BACKUP_TS_RE='^Boot_[-_0-9]+$'
RESTORING=0

if [[ ! -z $ARG2 ]]; then
   if [[ $ARG2 =~ $RESTORE_RE ]]; then
       bkup=
       if [[ $ARG2 =~ $LATEST_RE ]]; then
           say "\n*** Restore latest saved version of boot loader"
           bkup="$( /bin/ls "$BACKUP" \
               | egrep "$BACKUP_TS_RE" | tail -1)"
       elif [[ $ARG2 =~ $EARLIEST_RE ]]; then
           say "\n*** Restore earliest saved version of boot loader"
           bkup="$( /bin/ls "$BACKUP" \
               | egrep "$BACKUP_TS_RE" | head -1)"
       fi
       if [[ -d "$BACKUP/$bkup" && $bkup =~ $BACKUP_TS_RE ]]; then
           say "*** This backup version is timestamped $bkup\n"
       else
           wrn "Error:
Unable to find backup of boot loader
Try to specify the absolute path to the boot loader directory
as the second argument, e.g.
\"$BOOTER_SAVE\""
           leave 1
       fi
       BOOTER_SRC="$BACKUP/$bkup"
       RESTORING=1
   elif [ -d "$ARG2" ]; then
       path="$( clean_path "$ARG2" )"
       BACKUP_RE="^$BACKUP/"
       if [[ $path =~ $BACKUP_RE ]]; then
           RESTORING=1
       else
           wrn "
You seem to be passing the path to a boot loader stored on a volume
different from the given boot volume.

This is perfectly fine if you just want to install a new boot loader.

However, if you meant to restore a previous boot loader backup
created by this script, please carefully check the secod argument
you passed before continuing. The second argument was:
\"$ARG2\"
"
       fi
       BOOTER_SRC="$path"
   else
       wrn "Error: Invalid second argument:
\"$ARG2\"
Expected \"restore\", \"latest\", \"earliest\",
or the absolute path to a boot loader backup created by this script, e.g.
\"$BOOTER_SAVE\""

       leave 1
   fi
fi

# Path to "Extra" directory
SRC_EXTRA="$BOOTER_SRC/Extra"

# Path to "i386" directory in Chameleon-2.0RC1-r${BUILD}-bin directory
SRC_BIN="$BOOTER_SRC/i386"

if [ ! -d "$BOOT_VOLUME/Extra" ]; then
   wrn "The specified boot volume \"$BOOT_VOLUME\"
   does not have a directory \"Extra\" at the root level
   If you still want to install on that volume,
   please create this directory using the command below:\n
   sudo mkdir \"$BOOT_VOLUME/Extra\""
   leave 1
fi


DISK_RE='^disk[0-9]$'
PART_RE='^disk[0-9]s[1-9]$'


BOOTER_SRC="$( clean_path "$BOOTER_SRC" )"
BOOTER_BIN_DIR="$BOOTER_SRC/i386"

for dir in "$BOOTER_SRC" "$BOOTER_BIN_DIR" "$SRC_EXTRA"; do
   if [ ! -d "$dir" ]; then
       if [[ "$dir" = "$SRC_EXTRA" && $RESTORING -ne 1 ]]; then
               wrn "
Note: The name of the \"Extra\" directory in the download archive
of Chameleon 2 has changed in the past.
"

           # Try guessing the name of the directory
           extra_tmp="$(find "$BOOTER_SRC" -name '*xtra*' -type d)"
           if [ -d "$extra_tmp" ]; then
               wrn "Maybe we can guess the name of the \"Extra\" directory.

Is \"$(basename "$extra_tmp")\" the correct directory? Its contents are:
$(ls -C "$extra_tmp")

Then, either create a new directory
\"$SRC_EXTRA\"
and copy those things that you want to install from
\"$extra_tmp\"
into the new \"Extra\" directory just created.

Or, if you want to install everything, just rename
the existing directory \"$(basename "$extra_tmp")\" to \"Extra\".

To achieve the latter, you may want to run
sudo mv \"$extra_tmp\" \"$SRC_EXTRA\"
"
           else
               wrn "You need to create a new directory
\"$SRC_EXTRA\"
and copy the things that you want to install from the download archive
into that directory"
           fi
       else
       wrn "
Error: Invalid path or directory does not exist:
\"$dir\".\n
Please check if the directory
\"$SRC_EXTRA\"
exists and you have read permissions"

       fi
       wrn "
Nothing has been touched yet.
Exiting
"
       leave 2
   fi
done

#
# Auto-detect device identifiers of boot disk and boot partition
#

# BOOT_DISK is the device identifier of the disk you want to modify
# probably "disk0", but could also be "disk1", "disk2",...

BOOT_DISK="$( diskutil info "$BOOT_VOLUME" \
   | awk '/Part Of Whole:/ {print $4}' )"

# BOOT_PART is the device identifier of the boot partition you want to modify,
# e.g. "disk0s2", but could also be "disk0s3", "disk1s2",...
#
BOOT_PART="$( diskutil info "$BOOT_VOLUME" \
   | awk '/Device Identifier:/ {print $3}' )"

if [[ $BOOT_DISK =~ $DISK_RE ]] \
   && [[ $BOOT_PART =~ $PART_RE ]]; then
   say "\nVerifying auto-detected device identifiers...." c
else
   usage
fi


if mount | egrep "^/dev/${BOOT_DISK}s[0-9]+ on $BOOT_VOLUME \(hfs" >/dev/null \
   && mount | egrep "^/dev/$BOOT_PART on $BOOT_VOLUME \(hfs" >/dev/null; then
   say "OK\n\n"
   if [ $RESTORING -eq 1 ]; then
       say "\n*** Restoring previously saved boot loader from
*** \"$BOOTER_SRC\"
*** on disk \"$BOOT_DISK\"
*** with boot volume \"$BOOT_PART\" mounted at \"$BOOT_VOLUME\"\n\n"
   else
       nfy "\n*** Setting up the boot loader from
*** \"$BOOTER_SRC\"
*** on disk \"$BOOT_DISK\"
*** with boot volume \"$BOOT_PART\" mounted at \"$BOOT_VOLUME\"\n\n"
   fi
else
   wrn "Error: 
Either of
   BOOT_DISK=\"$BOOT_DISK\"
   BOOT_PART=\"$BOOT_PART\"
   BOOT_VOLUME=\"$BOOT_VOLUME\"
are not set correctly.
Note: The volume BOOT_PART
needs to be a partition of the disk BOOT_DISK
and it must already be mounted at BOOT_VOLUME"
   leave 3
fi

say "Verify Chameleon boot loader binaries exist in directory
\"$SRC_BIN\"... "
for i in ${SRC_BIN_ITEMS[*]}; do
   say "  \"$(basename "$SRC_BIN/$i")\": " c
   if [ -e "$SRC_BIN/$i" ]; then
       say "OK" c
   else
       wrn "\nError: Missing item \"$SRC_BIN/$i\""
       leave 1
   fi
done
say "\nRequired boot loader binaries found\n"


if [ $RESTORING -eq 1 ]; then
   say "Verify Chameleon \"Extra\" directory. Since we are restoring an 
earlier version of the boot loader, we only check
if this directory exists and is not empty"
   if [[ -d "$SRC_EXTRA" && "$(ls "$SRC_EXTRA")" ]]; then
       say "\"Extra\" directory exists and has the following contents:"
       ls "$SRC_EXTRA"
   else
       wrn "\nError: \"Extra\" directory 
   \"$SRC_EXTRA\"
   to restore from does not exist or it is empty"
       leave 1
   fi

else
   say "Verify Chameleon \"Extra\" items exist in directory
\"$SRC_EXTRA\"... "
   for i in ${SRC_EXTRA_ITEMS[*]}; do
       say "  \"$(basename "$SRC_EXTRA/$i")\": " c
       if [ -e "$SRC_EXTRA/$i" ]; then
           say "OK" c
       else
           wrn "\nError: Missing item \"$SRC_EXTRA/$i\""
           leave 1
       fi
   done
   say "\nRequired \"Extra\" items found\n"
fi


if [ $MODIFY -eq 1 ]; then
   if [[ $INTERACTIVE && $JUST_DO_IT -ne 1 ]]; then
       reply=''
       attempts=3
       yesno_re='^[yYnN]$'
       yes_re='^[yY]$'
       nfy "Continue?\n"
       while [[ ! $reply =~ $yesno_re && $attempts -gt 0 ]]; do
           ((--attempts))
           nfy "\nHit 'y' to continue, 'n' to cancel [yN]: " c
           if read -s -t 300 -n 1 reply; then
               nfy $reply
           else
               wrn "Timeout waiting for user input"
               wrn "No modifications have been made yet"
               leave 3
           fi
       done
       if [[ ! $reply =~ $yes_re ]]; then
           nfy "User cancelled"
           nfy "No modifications have been made yet"
           leave 1
       fi

   fi

   nfy "\n\n############## COMMITTING CHANGES #################\n\n"
else
   nfy "\n* * * * Note: No modifications are being made"
   nfy "* * * * Set variable \"MODIFY=1\" to modify\n\n"
fi

# Create directory to hold backup of current bootloader
say "\nSave backup of current bootloader at"
say "\"$BOOTER_SAVE\"...\n"

runcmd sudo mkdir -p "$BOOTER_SAVE"
SAVE_BIN="$BOOTER_SAVE/i386"

runcmd sudo mkdir "$SAVE_BIN"

runcmd sudo dd if="/dev/r${BOOT_DISK}" of="$SAVE_BIN/sector0" \
   bs=512 count=1
runcmd sudo dd if="$SAVE_BIN/sector0" of="$SAVE_BIN/boot0" \
   bs=446 count=1
runcmd sudo dd if="/dev/r${BOOT_PART}" of="$SAVE_BIN/boot1h" \
   bs=512 count=2

if [ $RESTORING -eq 1 ]; then
   runcmd sudo mv "${BOOT_VOLUME}/boot" "$SAVE_BIN/"
   runcmd sudo mv "${BOOT_VOLUME}/Extra" "$BOOTER_SAVE/"
else
   runcmd sudo cp -p "${BOOT_VOLUME}/boot" "$SAVE_BIN/"
   runcmd sudo cp -pR "${BOOT_VOLUME}/Extra" "$BOOTER_SAVE/"
fi

say "\nBackup complete. To restore, use the following command line:\n
\"$SCRIPT_FILE\" \"$BOOT_VOLUME\" \"$BOOTER_SAVE\"\n
To restore the {latest | earliest} backup, just use
\"$SCRIPT_FILE\" \"$BOOT_VOLUME\" latest
or
\"$SCRIPT_FILE\" \"$BOOT_VOLUME\" earliest"


say "\n\nFirst, copy items from \"Extra\" to boot volume\n"

if [ $RESTORING -eq 1 ]; then
   runcmd sudo cp -pR "$SRC_EXTRA" "$BOOT_VOLUME/"
else
   for i in ${SRC_EXTRA_ITEMS[*]}; do
       if [ $MODIFY -eq 1 ]; then
           if [ -e "$BOOT_VOLUME/Extra/$i" ]; then
               wrn "Item \"$BOOT_VOLUME/Extra/$i\" exists"
               if [ -e "$BOOTER_SAVE/Extra/$i" ]; then
                   wrn "A backup has been saved at
\"$BOOTER_SAVE/Extra/$i\""
                   runcmd sudo rm -r "$BOOT_VOLUME/Extra/$i"
               else
                   wrn "Please move it away if you want to replace it\"\n"
                   continue
               fi
           fi
       fi
       #say "Copy \"$i\" to Extra directory"
       runcmd sudo cp -pR "$SRC_EXTRA/$i" "$BOOT_VOLUME/Extra/"
       runcmd sudo chown root:wheel "$BOOT_VOLUME/Extra/$i"
       runcmd sudo chmod go=u-w "$BOOT_VOLUME/Extra/$i"
   done
fi


say "\n\nSecond, install last stage boot loader
(the file called \"boot\" at the root of the disk)\n"

runcmd sudo cp -p "$SRC_BIN/boot" "$BOOT_VOLUME"
runcmd sudo chown root:wheel "$BOOT_VOLUME/boot"
runcmd sudo chmod go=u-w "$BOOT_VOLUME/boot"
runcmd sudo chflags hidden "$BOOT_VOLUME/boot"

# Flush disk cache
runcmd sudo sync

say "\n\nThird, install master boot record (MBR) to \"/dev/r${BOOT_DISK}\"\n"

runcmd sudo fdisk -f "$SRC_BIN/boot0" -u -y "/dev/r${BOOT_DISK}"

say "\n\nFinally, install volume boot record (VBR) to \"/dev/r${BOOT_DISK}\""

runcmd sudo dd if="$SRC_BIN/boot1h" of="/dev/r${BOOT_PART}" 2>/dev/null

# Flush disk cache
runcmd sudo sync

say "\nAll finished successfully. Have fun with your new bootloader!\n"

## EOF

 

 

Example of a Restore Run

 

Here's an example script run restoring the previous ("latest") boot loader version.

 

a
admin@blue ~$ MODIFY=1 \
   /Users/admin/Library/Hackintosh/chameleon-2.0rc1/chameleon-2.sh \
   /Volumes/boot latest

*** Restore latest saved version of boot loader
*** This backup version is timestamped Boot_2009-04-06_021942


Verifying auto-detected device identifiers....OK



*** Restoring previously saved boot loader from
*** "/Volumes/boot/Library/Archive/Boot_2009-04-06_021942"
*** on disk "disk0"
*** with boot volume "disk0s2" mounted at "/Volumes/boot"


Verify Chameleon boot loader binaries exist in directory
"/Volumes/boot/Library/Archive/Boot_2009-04-06_021942/i386"... 
 "boot0": OK  "boot1h": OK  "boot": OK
Required boot loader binaries found

Verify Chameleon "Extra" directory. Since we are restoring an 
earlier version of the boot loader, we only check
if this directory exists and is not empty
"Extra" directory exists and has the following contents:
Extensions.cached       Themes                  smbios.plist
Extensions.mkext        com.apple.Boot.plist
Continue?


Hit 'y' to continue, 'n' to cancel [yN]: y


############## COMMITTING CHANGES #################



Save backup of current bootloader at
"/Volumes/boot/Library/Archive/Boot_2009-04-06_022017"...

/usr/bin/sudo 'mkdir' '-p' '/Volumes/boot/Library/Archive/Boot_2009-04-06_022017'
/usr/bin/sudo 'mkdir' '/Volumes/boot/Library/Archive/Boot_2009-04-06_022017/i386'
/usr/bin/sudo 'dd' 'if=/dev/rdisk0' \
   'of=/Volumes/boot/Library/Archive/Boot_2009-04-06_022017/i386/sector0' \
   'bs=512' 'count=1'
1+0 records in
1+0 records out
512 bytes transferred in 0.000201 secs (2547430 bytes/sec)
/usr/bin/sudo 'dd' \
   'if=/Volumes/boot/Library/Archive/Boot_2009-04-06_022017/i386/sector0' \
   'of=/Volumes/boot/Library/Archive/Boot_2009-04-06_022017/i386/boot0' \
   'bs=446' 'count=1'
1+0 records in
1+0 records out
446 bytes transferred in 0.000055 secs (8098093 bytes/sec)
/usr/bin/sudo 'dd' 'if=/dev/rdisk0s2' \
   'of=/Volumes/boot/Library/Archive/Boot_2009-04-06_022017/i386/boot1h' \
   'bs=512' 'count=2'
2+0 records in
2+0 records out
1024 bytes transferred in 0.005094 secs (201019 bytes/sec)
/usr/bin/sudo 'mv' '/Volumes/boot/boot' \
   '/Volumes/boot/Library/Archive/Boot_2009-04-06_022017/i386/'
/usr/bin/sudo 'mv' '/Volumes/boot/Extra' \
   '/Volumes/boot/Library/Archive/Boot_2009-04-06_022017/'

Backup complete. To restore, use the following command line:

"/Users/admin/Library/Hackintosh/chameleon-2.0rc1/chameleon-2.sh" \
   "/Volumes/boot" "/Volumes/boot/Library/Archive/Boot_2009-04-06_022017"

To restore the {latest | earliest} backup, just use
"/Users/admin/Library/Hackintosh/chameleon-2.0rc1/chameleon-2.sh" \
   "/Volumes/boot" latest
or
"/Users/admin/Library/Hackintosh/chameleon-2.0rc1/chameleon-2.sh" \
   "/Volumes/boot" earliest


First, copy items from "Extra" to boot volume

/usr/bin/sudo 'cp' '-pR' \
   '/Volumes/boot/Library/Archive/Boot_2009-04-06_021942/Extra' \
   '/Volumes/boot/'


Second, install last stage boot loader
(the file called "boot" at the root of the disk)

/usr/bin/sudo 'cp' '-p' \
   '/Volumes/boot/Library/Archive/Boot_2009-04-06_021942/i386/boot' \
   '/Volumes/boot'
/usr/bin/sudo 'chown' 'root:wheel' '/Volumes/boot/boot'
/usr/bin/sudo 'chmod' 'go=u-w' '/Volumes/boot/boot'
/usr/bin/sudo 'chflags' 'hidden' '/Volumes/boot/boot'
/usr/bin/sudo 'sync'


Third, install master boot record (MBR) to "/dev/rdisk0"

/usr/bin/sudo 'fdisk' '-f' \
   '/Volumes/boot/Library/Archive/Boot_2009-04-06_021942/i386/boot0' \
   '-u' '-y' '/dev/rdisk0'


Finally, install volume boot record (VBR) to "/dev/rdisk0"
/usr/bin/sudo 'dd' \
   'if=/Volumes/boot/Library/Archive/Boot_2009-04-06_021942/i386/boot1h' \
   'of=/dev/rdisk0s2'
/usr/bin/sudo 'sync'

All finished successfully. Have fun with your new bootloader!

 

The latest version is always provided as a ".zip" file below.

 

 

Download

 

 

The instructions are always for the latest version, so please use the latest one.

Version 3

Major changes

- Changed order in which actions are performed, i.e., first copy stuff around and overwrite the boot blocks only in the end.

- Still more sanity checks

 

 

Questions and Feedback

 

Thanks a lot for your questions and problem reports. Please do NOT ask the Chameleon team questions relating to this script. Instead, please add a post below or PM me.

 

However, if your system boots, then the script has probably worked. Questions about Chameleon 2.0-RC1 are best posted to

this post about Chameleon 2.0-RC1, which is also read by all other users who may be more competent to help than me.

chameleon_2.sh.zip

Link to comment
Share on other sites

Just added a much improved version 2

 

Major changes

  • 1. Auto-detects almost everything, you only need to drag-and-drop the script and your boot volume to a Terminal window
  • 2. Saves abackup of the previous boot loader and allows to restore the previous boot loader

Link to comment
Share on other sites

The link for munky's script is broken again, will you be making a new one and why do they keep getting removed.

Apologies for the inconvenience. I have no idea why they keep removing my posts. I'm not the only one. Also, I do not get any notification when the topic is removed, it just disappears.

 

Anyway, I have posted

the script in Munky's tutorial topic and I hope it will stay there for a few days before some moderator removes it again.

Link to comment
Share on other sites

I am currently having problems with Chameleon v2 as it wont boot XP without a error message & when trying to boot Windows 7 I get a flashing cursor.

 

It works fine before I install Chameleon v2, will this script update the loader but will still keep the functionality it had before?

 

The following error I get on XP is:

Invalid BOOT.INI file
Booting from C:\Windows\
NTDETECT Failed

 

I am currently using EasyBCD for Windows 7 to boot and that allows me to boot XP & OSX. I would love to use this new loader as it is loads better than the text version.

 

I hope this tutorial helps me.

 

Please can you let me know.

 

All the best

 

NSCXP2005

Link to comment
Share on other sites

I am currently having problems with Chameleon v2 as it wont boot XP without a error message & when trying to boot Windows 7 I get a flashing cursor.

 

It works fine before I install Chameleon v2, will this script update the loader but will still keep the functionality it had before?

The script installs Chameleon 2 according to the instructions provided by the developers. The problem loading Windows is probably independent of how you install Chameleon 2. In my case, I cannot boot Vista unless I make its partition active. This has also been the case for any previous version of Chameleon I have used.

 

I hope this clears it up a bit.

Link to comment
Share on other sites

I just want to clarify, if I set XP to be active I will be able to boot it using Chameleon or would I have to set Windows 7 as active for them both to work?

 

Thanks for the response

 

NSCXP2005

If you set XP to active, Chameleon will probably not be loaded as the MBR will go directly into XP. But that's the only way that allows me to boot Vista. For XP there might be better ways.

Link to comment
Share on other sites

Thanks to all who downloaded the script.

 

Just a tiny request: It would be really helpful for me and other readers to know if it actually works, or if it fried your machine.

 

Thanks so much.

Link to comment
Share on other sites

Does anybody know how to get this version of Chameleon working with XP & Windows 7?

 

I would really appreciate the advice.

 

All the best

 

NSCXP2005

 

I installed Chameleon on the Mac OS X Drive and I was able to boot into both Windows XP and Windows Vista.

 

First I installed XP, then Windows 7 then Mac OS X Retail and then the Chameleon Boot Loader....Now I can boot in to all three systems....

Link to comment
Share on other sites

I installed Chameleon on the Mac OS X Drive and I was able to boot into both Windows XP and Windows Vista.

 

First I installed XP, then Windows 7 then Mac OS X Retail and then the Chameleon Boot Loader....Now I can boot in to all three systems....

 

I have a multi-OS X systems, Vista64 and Ubuntu each on their own internal SATA HDD and multi-OS X systems on an eSATA External HDD......

 

Chameleon 2.0_RC1 seems to have problems booting to the Vista HDD and the Ubuntu HDD from both the internal OS X HDD and the eSATA External HDD......

 

I have for the present gone back to Pre-Chameleon bootloader for OS X volumes, and use EasyBCD1.7.2 in Vista to boot to either OS X or Ubuntu or Vista......

Link to comment
Share on other sites

  • 1 month later...

No Luck here, when I run chameleon-2.sh it get the following message:

 

### Error: 
  ### Either of
  ###	 BOOT_DISK="disk0"
  ###	 BOOT_PART="disk0s1"
  ###	 BOOT_VOLUME="/Volumes/Leopard"
  ### are not set correctly.
  ### Note: The volume BOOT_PART
  ### needs to be a partition of the disk BOOT_DISK
  ### and it must already be mounted at BOOT_VOLUME

 

Leopard is the correct volume name - disk is 500GB SATA single mbr partition formatted as hfsj, current bootloader is Darwin 5..0.132 / Chameleon 1.0.12 (installed from iAtkos 10.5.5), with exisiting /Extra folder

 

I tried using disk utility to repair permissions, still no go

also, if it matters I've updated to 10.5.7

chameleon package is Chameleon-2.0RC1-r431

 

any ideas why I'm getting this? The volume name is correct, and disk utility shows the mount point as / and osx is running so its already mounted (right?). Am I missing something obvious here? lol if so please go easy, I'm fairly new :unsure:

 

if my settings are right and it should hypothetically be working, is there some log I could go look for possible error message to explain what's causing the error?

Link to comment
Share on other sites

No Luck here, when I run chameleon-2.sh it get the following message:

 

### Error: 
  ### Either of
  ###	 BOOT_DISK="disk0"
  ###	 BOOT_PART="disk0s1"
  ###	 BOOT_VOLUME="/Volumes/Leopard"
  ### are not set correctly.
  ### Note: The volume BOOT_PART
  ### needs to be a partition of the disk BOOT_DISK
  ### and it must already be mounted at BOOT_VOLUME

 

[...]

if my settings are right and it should hypothetically be working, is there some log I could go look for possible error message to explain what's causing the error?

 

Welcome to the forum, and thanks for your detailed feedback.

 

It looks like you are doing everything right, the script should proceed with your setup and your command line arguments. In other words, the script is being too cautious from what I can tell. Sorry about that. :-(

 

Please provide the output of the following commands:

BOOT_DISK="disk0"
BOOT_PART="disk0s1"
BOOT_VOLUME="/Volumes/Leopard"

mount | egrep "^/dev/${BOOT_DISK}s[0-9]+ on $BOOT_VOLUME \(hfs"

mount | egrep "^/dev/$BOOT_PART on $BOOT_VOLUME \(hfs"

mount
diskutil list

These commands should all run fine without sudo. Please copy-paste the above lines into terminal and post the complete output, including the command lines you pasted.

 

Of course you may remove any output you consider private. Also, if you prefer, send it to me as a private message.

 

Thanks a lot!

 

zhell

Thanks a lot.

Link to comment
Share on other sites

Hey thanks for such a quick reply. I opened Terminal and posted each line, but only the last mount and diskutil lines gave any output - here is the entire terminal session:

 

Last login: Sat May 23 15:03:22 on console
ellis-dees:~ ellisdee$ BOOT_DISK="disk0"
ellis-dees:~ ellisdee$ BOOT_PART="disk0s1"
ellis-dees:~ ellisdee$ BOOT_VOLUME="/Volumes/Leopard"
ellis-dees:~ ellisdee$ 
ellis-dees:~ ellisdee$ mount | egrep "^/dev/${BOOT_DISK}s[0-9]+ on $BOOT_VOLUME \(hfs"
ellis-dees:~ ellisdee$ mount | egrep "^/dev/$BOOT_PART on $BOOT_VOLUME \(hfs"
ellis-dees:~ ellisdee$ mount
/dev/disk0s1 on / (hfs, local, journaled)
devfs on /dev (devfs, local)
fdesc on /dev (fdesc, union)
map -hosts on /net (autofs, automounted)
map auto_home on /home (autofs, automounted)
ellis-dees:~ ellisdee$ diskutil list
/dev/disk0
  #:					   TYPE NAME					SIZE	   IDENTIFIER
  0:	 FDisk_partition_scheme						*465.8 Gi   disk0
  1:				  Apple_HFS Leopard				 465.8 Gi   disk0s1
ellis-dees:~ ellisdee$

Link to comment
Share on other sites

Hey thanks for such a quick reply. I opened Terminal and posted each line, but only the last mount and diskutil lines gave any output - here is the entire terminal session:

Thanks, this helps me a great deal to help you.

 

The "problem" is that the script is meant for a setup where you have a separate partition for your boot loader, therefore it does not work out of the box with your setup of only one partition that holds both the boot loader and the system.

 

The idea behind such a setup is that it allows you to completely separate those parts that are needed for a Hackintosh (the stuff on the "boot loader volume") and the plain vanilla Mac OS X Leopard (the stuff on the "system volume").

 

Therefore, the "boot volume" is expected to be mounted on "/Volumes/<name of boot volume>", however, in your case it is mounted on "/".

 

You could easily adapt the script to work for you be ensuring that the "if ... then" statement doing these "mount

| egrep" checks evaluates to true.

The simplest would be to replace everything between "if" and "then" by just "true", as follows:

if mount | egrep "^/dev/${BOOT_DISK}s[0-9]+ on $BOOT_VOLUME \(hfs" >/dev/null \
&& mount | egrep "^/dev/$BOOT_PART on $BOOT_VOLUME \(hfs" >/dev/null; then

is replaced by

if true; then

 

Good luck!

Link to comment
Share on other sites

  • 3 weeks later...

It worked fine for me. It detected all my hard drives and allowed me to boot into Mac OS X 10.5.7, Windows 7 and Windows Vista. However, here's a rather silly question: I can't seem to find the command line interface in the event I need to boot into verbose or safe mode. Basically, if I have to start up with -v -f or some such, how do I do it? There's no command line visible and pressing F8 doesn't do anything.

Link to comment
Share on other sites

The script worked for me. Installation went fine. BUT I'm still having problems with Chameleon 2.

 

Installed Windows 7 on first partition

Installed iPC Final on second partition (with Chameleon 1)

Used your script to upgrade to Chameleon 2 RC. Like I said, installation went fine, but on reboot, I see the BIOS post and after boot0: done, it immediately restarts and I have a loop. What did I do wrong?

Link to comment
Share on other sites

It worked fine for me. It detected all my hard drives and allowed me to boot into Mac OS X 10.5.7, Windows 7 and Windows Vista. However, here's a rather silly question: I can't seem to find the command line interface in the event I need to boot into verbose or safe mode. Basically, if I have to start up with -v -f or some such, how do I do it? There's no command line visible and pressing F8 doesn't do anything.

Thanks a lot for the feedback.

Just select the partition to boot, then start typing "-v -f" etc, it will appear at the bottom left.

 

The script worked for me. Installation went fine. BUT I'm still having problems with Chameleon 2.

 

Installed Windows 7 on first partition

Installed iPC Final on second partition (with Chameleon 1)

Used your script to upgrade to Chameleon 2 RC. Like I said, installation went fine, but on reboot, I see the BIOS post and after boot0: done, it immediately restarts and I have a loop. What did I do wrong?

Probably something was different in your setup from mine. Could you please run the script again and post the entire output? Put it in

[codebox]...[/codebox]

tags. Thanks

Link to comment
Share on other sites

Thanks a lot for the feedback.

Just select the partition to boot, then start typing "-v -f" etc, it will appear at the bottom left.

 

 

Probably something was different in your setup from mine. Could you please run the script again and post the entire output? Put it in

[codebox]...[/codebox]

tags. Thanks

 

 

Probably something was different in your setup from mine. Could you please run the script again and post the entire output? Put it in

[codebox]...[/codebox]

tags. Thanks

 

 

Probably something was different in your setup from mine. Could you please run the script again and post the entire output? Put it in

[codebox]...[/codebox]

tags. Thanks

 

 

Probably something was different in your setup from mine. Could you please run the script again and post the entire output? Put it in "codebox" tags. Thanks

 

Say it 3 times and it creates emphasis.

Link to comment
Share on other sites

Say it 3 times and it creates emphasis.

;) Thanks for noticing. If you reply to two posts, it will only create one and it looks as if it did not save it. That's why I tried again, and again... wonderful BBS system we have here.

Link to comment
Share on other sites

 Share

×
×
  • Create New...