Chameleon Applications

Chameleon Applications Svn Source Tree

Root/branches/blackosx/trunk/PackageBuilder/Main_Package_Elements/Scripts/CheckPartitionScheme.sh

  • Property svn:executable set to *
1#!/bin/bash
2
3echo "==============================================="
4echo "Check the Partition Scheme"
5echo "******************************************"
6
7# Receives passed value for the Target Disk
8# for example: /dev/disk0s2
9# Then looks for the following:
10# First 8 bytes of the GPTdiskGPTHeader to identify a GUID partition table.
11# Byte number 450 of the GPTdiskProtectiveMBR to identify ID of 'EE' to identify a GPT partition.
12# Byte numbers 466, 482 & 498 of the GPTdiskProtectiveMBR to identify further partitions.
13
14if [ "$#" -eq 1 ]; then
15targetDisk="$1"
16echo "DEBUG: passed argument = $targetDisk"
17fi
18
19
20partitiontable=$( dd 2>/dev/null if="$targetDisk" count=1 skip=1 | dd 2>/dev/null count=8 bs=1 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
21if [ "${partitiontable:0:16}" == "4546492050415254" ]; then
22partitiontable=$( dd 2>/dev/null if="$targetDisk" count=1 | dd 2>/dev/null count=64 bs=1 skip=446 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
23if [ "${partitiontable:8:2}" == "ee" ]; then
24echo "Found System ID 'EE' to identify GPT Partition"
25if [ "${partitiontable:40:2}" == "00" ] && [ "${partitiontable:72:2}" == "00" ] && [ "${partitiontable:104:2}" == "00" ]; then
26echo "Found System ID '00' for each remaining possible partition"
27partitiontable="GPT"
28 else
29partitiontable="GPT/MBR"
30fi
31fi
32else
33partitiontable="MBR"
34fi
35
36echo "${partitiontable} found."
37echo "-----------------------------------------------"
38echo ""
39
40exit 0

Archive Download this file

Revision: 221