Root/
| |
---|---|
Source at commit 2190 created 11 years 2 months ago. By ifabio, Update Graphics card list | |
1 | #!/bin/bash␊ |
2 | ␊ |
3 | echo "==============================================="␊ |
4 | echo "Check the Partition Scheme: GPT, GPT/MBR or MBR?"␊ |
5 | echo "************************************************"␊ |
6 | ␊ |
7 | # Looks for the first 8 bytes of the GPTdiskGPTHeader to identify a GUID partition table.␊ |
8 | # Byte number 450 of the GPTdiskProtectiveMBR to identify ID of 'EE' to identify a GPT partition.␊ |
9 | # Byte numbers 466, 482 & 498 of the GPTdiskProtectiveMBR to identify further partitions.␊ |
10 | #␊ |
11 | # Exit with value 1 for GPT, 2 for GPT/MBR and 3 for MBR. ␊ |
12 | # Exit with value 0 if nothing is found - this shouldn't happen.?␊ |
13 | ␊ |
14 | # Receives targetDisk: for example, /dev/disk0s2␊ |
15 | # Receives targetVolume: Volume to install to.␊ |
16 | # Receives scriptDir: The location of the main script dir.␊ |
17 | ␊ |
18 | ␊ |
19 | if [ "$#" -eq 3 ]; then␊ |
20 | ␉targetDisk="$1"␊ |
21 | ␉targetVolume="$2"␊ |
22 | ␉scriptDir="$3"␊ |
23 | ␉echo "DEBUG: passed argument = $targetDisk"␊ |
24 | ␉echo "DEBUG: passed argument for targetVolume = $targetVolume"␊ |
25 | ␉echo "DEBUG: passed argument for scriptDir = $scriptDir"␊ |
26 | else␊ |
27 | ␉echo "Error - wrong number of values passed"␊ |
28 | ␉exit 9␊ |
29 | fi␊ |
30 | ␊ |
31 | ␊ |
32 | partitiontable=$( 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}' )␊ |
33 | if [ "${partitiontable:0:16}" == "4546492050415254" ]; then␉␊ |
34 | ␉partitiontable=$( 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}' )␊ |
35 | ␊ |
36 | ␉if [ "${partitiontable:8:2}" == "ee" ]; then␊ |
37 | ␉␉#echo "DEBUG: Found System ID 'EE' to identify GPT Partition"␊ |
38 | ␊ |
39 | ␉␉if [ "${partitiontable:40:2}" == "00" ] && [ "${partitiontable:72:2}" == "00" ] && [ "${partitiontable:104:2}" == "00" ]; then␊ |
40 | ␉␉␉#echo "DEBUG: Found System ID '00' for each remaining possible partition"␊ |
41 | ␉␉␉partitiontable="GPT"␊ |
42 | ␉␉␉#echo "DEBUG: ${partitiontable} found."␊ |
43 | ␉␉␉#"$scriptDir"InstallLog.sh "${targetVolume}" "${targetDisk} is using a GPT."␊ |
44 | ␉␉␉exit 1␊ |
45 | ␉ ␉else␊ |
46 | ␉␉␉partitiontable="GPT/MBR"␊ |
47 | ␉␉␉#echo "DEBUG: ${partitiontable} found."␊ |
48 | ␉␉␉#"$scriptDir"InstallLog.sh "${targetVolume}" "${targetDisk} is using a GPT/MBR."␊ |
49 | ␉␉␉exit 2␊ |
50 | ␉␉fi␊ |
51 | ␉fi␊ |
52 | else␊ |
53 | ␉partitiontable="MBR"␊ |
54 | ␉#echo "DEBUG: ${partitiontable} found."␊ |
55 | ␉#"$scriptDir"InstallLog.sh "${targetVolume}" "${targetDisk} is using MBR."␊ |
56 | ␉exit 3␊ |
57 | fi␊ |
58 | ␊ |
59 | #echo "DEBUG: No partition table found."␊ |
60 | "$scriptDir"InstallLog.sh "${targetVolume}" "NOTE: No partition table found."␊ |
61 | ␊ |
62 | exit 0 |