author | Mary Ding <mary.ding@oracle.com> |
Thu, 23 Aug 2012 14:23:37 -0700 | |
changeset 1769 | 36ef49b30618 |
parent 1617 | 0a764388bf3b |
permissions | -rwxr-xr-x |
197
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
1 |
#!/usr/bin/bash |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
2 |
# |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
3 |
# CDDL HEADER START |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
4 |
# |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
5 |
# The contents of this file are subject to the terms of the |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
6 |
# Common Development and Distribution License (the "License"). |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
7 |
# You may not use this file except in compliance with the License. |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
8 |
# |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
9 |
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
10 |
# or http://www.opensolaris.org/os/licensing. |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
11 |
# See the License for the specific language governing permissions |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
12 |
# and limitations under the License. |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
13 |
# |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
14 |
# When distributing Covered Code, include this CDDL HEADER in each |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
15 |
# file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
16 |
# If applicable, add the following below this CDDL HEADER, with the |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
17 |
# fields enclosed by brackets "[]" replaced with your own identifying |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
18 |
# information: Portions Copyright [yyyy] [name of copyright owner] |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
19 |
# |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
20 |
# CDDL HEADER END |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
21 |
# |
1617
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
22 |
# Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. |
197
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
23 |
# |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
24 |
|
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
25 |
# Make sure we get the right versions of the commands |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
26 |
PATH=/usr/sbin:/usr/bin |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
27 |
|
680
416390c26142
3446 usbcopy cannot work with localized message command.
David Miner <dminer@opensolaris.org>
parents:
313
diff
changeset
|
28 |
# Ensure that commands whose output we're parsing don't localize numeric |
416390c26142
3446 usbcopy cannot work with localized message command.
David Miner <dminer@opensolaris.org>
parents:
313
diff
changeset
|
29 |
# formats on us |
416390c26142
3446 usbcopy cannot work with localized message command.
David Miner <dminer@opensolaris.org>
parents:
313
diff
changeset
|
30 |
export LC_ALL=C |
416390c26142
3446 usbcopy cannot work with localized message command.
David Miner <dminer@opensolaris.org>
parents:
313
diff
changeset
|
31 |
|
1617
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
32 |
function cleanup { |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
33 |
|
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
34 |
{ |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
35 |
|
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
36 |
# unmounting, and uninstalling the lofi'ed devices and |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
37 |
# cleanup temporary files. |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
38 |
|
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
39 |
for devs in $(mount -p | grep $usbdev | awk '{print $1}'); do |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
40 |
umount -f $devs |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
41 |
done |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
42 |
|
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
43 |
lofiadm "${img}" && \ |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
44 |
lofiadm -d "${img}" |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
45 |
|
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
46 |
if [[ -d "${usbmntpt}" ]]; then |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
47 |
rmdir "${usbmntpt}" |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
48 |
fi |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
49 |
|
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
50 |
rm -f $fdi |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
51 |
} > /dev/null 2>&1 |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
52 |
|
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
53 |
} |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
54 |
|
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
55 |
function error_handler { |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
56 |
|
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
57 |
print -u2 "\nError:\n" |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
58 |
print -u2 -r -- "${progname}: $*" |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
59 |
cleanup |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
60 |
|
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
61 |
exit 1 |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
62 |
|
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
63 |
} |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
64 |
|
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
65 |
function setup_grub2 { |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
66 |
|
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
67 |
# There are pre-built MBR stage 1 and UEFI system images on the USB image. |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
68 |
# These need to be used instead of trying to construct it ourselves in order |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
69 |
# to avoid grub2 version mismatches. |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
70 |
mbrimg="$usbmntpt/boot/mbr.img" |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
71 |
uefiimg="$usbmntpt/boot/uefi.img" |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
72 |
|
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
73 |
# cat the (MBR) usb.img and (ESP) uefi.img to the USB device. |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
74 |
cat $mbrimg $uefiimg > $dev || \ |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
75 |
error_handler "Failed to write ${mbrimg} and ${uefiimg} to ${dev}" |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
76 |
|
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
77 |
# Read the geometry of the physical device |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
78 |
while read pcyl ncyl acyl bcyl nhead nsect secsiz; do |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
79 |
devblksize=$secsiz |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
80 |
devblocks=$(($ncyl * $nhead * $nsect)) |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
81 |
done < <(fdisk -G $dev | grep -v "*") |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
82 |
|
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
83 |
# Size the embedded MBR image |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
84 |
mbrnbytes=$(ls -lL $mbrimg | awk '{print $5}') |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
85 |
mbrnblocks=$(($mbrnbytes / $devblksize)) |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
86 |
|
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
87 |
# Size the uefi.img |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
88 |
uefinbytes=$(ls -lL $uefiimg | awk '{print $5}') |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
89 |
uefinblocks=$(($uefinbytes / $devblksize)) |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
90 |
|
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
91 |
# fdisk table should end up looking like this. |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
92 |
# The first line/partition for the ESP is already embedded in the mbr image |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
93 |
# that we just cat'd to the disk. So we need to add the solaris partition. |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
94 |
# id active bhead bsect bcyl ehead esect ecyl rsect numsect |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
95 |
# 239 0 0 0 0 0 0 0 mbrnblocks(a) uefinblocks(b) |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
96 |
# 191 0 0 0 0 0 0 0 (a)+(b):(c) diskblocks-(c) |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
97 |
solstart=$(($mbrnblocks + $uefinblocks)) |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
98 |
solnblocks=$(($devblocks - $solstart)) |
1769
36ef49b30618
7190711 ultra20 hangs while trying to load GRUB from USB when booting s11u1_15 or later
Mary Ding <mary.ding@oracle.com>
parents:
1617
diff
changeset
|
99 |
addsolpart="191:128:0:0:0:0:0:0:$solstart:$solnblocks" |
1617
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
100 |
fdisk -A $addsolpart $dev |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
101 |
|
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
102 |
# fdisk is stupid and overwrites the MBR boot code region with mboot so we |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
103 |
# have to rewrite the first 440 bytes of the MBR image to restore what it |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
104 |
# so helpfully overwrote. |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
105 |
dd if=$mbrimg bs=1 count=440 oseek=0 of=$bdev 2>/dev/null|| \ |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
106 |
error_handler "Failed to restore MBR stage1 image from ${usbimg}" |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
107 |
|
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
108 |
} |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
109 |
|
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
110 |
|
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
111 |
function setup_legacy_grub { |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
112 |
|
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
113 |
# Install grub stages to usb. The USB image is already lofi mounted so no need |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
114 |
# to mount the USB device. |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
115 |
echo Installing grub to USB device $s0cdev |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
116 |
installgrub -mf $usbmntpt/boot/grub/stage1 $usbmntpt/boot/grub/stage2 $s0cdev > /dev/null |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
117 |
|
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
118 |
} |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
119 |
|
313
5f65f3b84896
3355 usbcopy utters that device is not writable when root privs needed
Jack Schwartz <Jack.A.Schwartz@Sun.COM>
parents:
197
diff
changeset
|
120 |
if [ `/usr/bin/id -u` != "0" ] ; then |
5f65f3b84896
3355 usbcopy utters that device is not writable when root privs needed
Jack Schwartz <Jack.A.Schwartz@Sun.COM>
parents:
197
diff
changeset
|
121 |
echo "Must be root to run." |
5f65f3b84896
3355 usbcopy utters that device is not writable when root privs needed
Jack Schwartz <Jack.A.Schwartz@Sun.COM>
parents:
197
diff
changeset
|
122 |
exit 1 |
5f65f3b84896
3355 usbcopy utters that device is not writable when root privs needed
Jack Schwartz <Jack.A.Schwartz@Sun.COM>
parents:
197
diff
changeset
|
123 |
fi |
5f65f3b84896
3355 usbcopy utters that device is not writable when root privs needed
Jack Schwartz <Jack.A.Schwartz@Sun.COM>
parents:
197
diff
changeset
|
124 |
|
197
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
125 |
if [ $# != 1 ]; then |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
126 |
echo "Usage: $0 <USB image path>" |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
127 |
exit 1 |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
128 |
fi |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
129 |
|
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
130 |
img=$1 |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
131 |
if [ ! -r $img ] && [ ! -c $img ]; then |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
132 |
echo "Error: $img does not exist." |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
133 |
exit 1 |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
134 |
fi |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
135 |
# Image size (in MB) |
1617
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
136 |
ibytes=$(ls -lL $img | awk '{print $5}') |
197
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
137 |
isz=$((ibytes >> 20)) |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
138 |
|
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
139 |
#nawk script to output the details of plugged in USB drives |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
140 |
i=0 |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
141 |
while read p l s m d; do |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
142 |
phys[$i]=$p |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
143 |
log[$i]=$l |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
144 |
size[$i]=$s |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
145 |
mult[$i]=$m |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
146 |
desc[$i]=$d |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
147 |
((i++)) |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
148 |
done < <(rmformat 2>/dev/null | nawk 'BEGIN { |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
149 |
FS = ":"; |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
150 |
bustype = "USB"; |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
151 |
} |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
152 |
/Logical Node/ { |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
153 |
lnode = 1; |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
154 |
node = $2; |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
155 |
} |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
156 |
/Physical Node/ { |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
157 |
physdev = $2 |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
158 |
} |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
159 |
/Connected Device/ { |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
160 |
devname = $2 |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
161 |
} |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
162 |
/Bus/ { |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
163 |
bus = $2; |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
164 |
} |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
165 |
/Size/ && lnode && bus ~ bustype { |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
166 |
size = $2; |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
167 |
printf("%s\t%s\t%s\t%s\n", physdev, node, size, devname); |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
168 |
lnode = 0; |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
169 |
}') |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
170 |
|
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
171 |
echo Found the following USB devices: |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
172 |
j=0 |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
173 |
while [ $j -lt $i ]; do |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
174 |
echo "$j: ${log[$j]} ${size[$j]} ${mult[$j]} ${desc[$j]}" |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
175 |
((j++)) |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
176 |
done |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
177 |
while read -p "Enter the number of your choice: " choice; do |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
178 |
if [ -z "${choice}" ]; then |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
179 |
continue |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
180 |
fi |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
181 |
if [ $choice -lt 0 ] || [ $choice -ge $i ]; then |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
182 |
echo "Invalid choice" |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
183 |
continue |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
184 |
fi |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
185 |
break |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
186 |
done |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
187 |
|
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
188 |
dev=${log[$choice]} |
1617
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
189 |
bdev=${dev/rdsk/dsk} |
197
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
190 |
s0cdev=${dev/p0/s0} |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
191 |
s0bdev=${s0cdev/rdsk/dsk} |
1769
36ef49b30618
7190711 ultra20 hangs while trying to load GRUB from USB when booting s11u1_15 or later
Mary Ding <mary.ding@oracle.com>
parents:
1617
diff
changeset
|
192 |
p2cdev=${dev/p0/p2} |
36ef49b30618
7190711 ultra20 hangs while trying to load GRUB from USB when booting s11u1_15 or later
Mary Ding <mary.ding@oracle.com>
parents:
1617
diff
changeset
|
193 |
p2bdev=${p2cdev/rdsk/dsk} |
736
0bcc64a2a823
10098 usbcopy does not deal with smedia mounted usb flash properly
Alexander Eremin <eremin@milax.org>
parents:
680
diff
changeset
|
194 |
mountdev=${s0bdev/s0} |
197
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
195 |
if [ ! -b $s0bdev ] || [ ! -c $s0cdev ]; then |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
196 |
echo "Missing device nodes for $dev" |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
197 |
exit 1 |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
198 |
fi |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
199 |
|
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
200 |
if [ ! -n "$dev" ]; then |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
201 |
echo INFORMATION: No USB selected/found.. Please plug in and try again |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
202 |
exit 1 |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
203 |
fi |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
204 |
|
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
205 |
sz=${size[$choice]} |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
206 |
multiplier=${mult[$choice]} |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
207 |
|
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
208 |
case "$multiplier" in |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
209 |
GB) sz=$(( ${sz%%.*} * 1000 + ${sz##*.} * 100 ));; |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
210 |
MB) sz=${sz%%.*};; |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
211 |
*) echo "Unknown capacity indicator: '$multiplier'"; exit 1;; |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
212 |
esac |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
213 |
|
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
214 |
while true; |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
215 |
do |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
216 |
echo "" |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
217 |
echo WARNING: All data on your USB storage will be lost. |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
218 |
echo Are you sure you want to install to |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
219 |
echo -n ${desc[$choice]}, $sz MB at $dev ? |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
220 |
read -p " (y/n) " yn |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
221 |
case $yn in |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
222 |
[yY]* ) |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
223 |
if [ ! -w $dev ]; then |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
224 |
echo "Device $dev is not writable" |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
225 |
echo "Installation aborted" |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
226 |
exit 1 |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
227 |
fi |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
228 |
if [ $sz -lt $isz ]; then |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
229 |
echo "Image ($isz MB) is larger than the device ($sz MB)" |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
230 |
echo "Installation aborted" |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
231 |
exit 1 |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
232 |
fi |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
233 |
break ;; |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
234 |
[nN]* ) |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
235 |
echo "Installation aborted" |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
236 |
exit 0 ;; |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
237 |
* ) |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
238 |
echo Invalid choice.. Exiting |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
239 |
exit 0 ;; |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
240 |
esac |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
241 |
done |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
242 |
|
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
243 |
# Ensure we have things unmounted |
736
0bcc64a2a823
10098 usbcopy does not deal with smedia mounted usb flash properly
Alexander Eremin <eremin@milax.org>
parents:
680
diff
changeset
|
244 |
for devs in $(mount -p | grep $mountdev | awk '{print $1}'); |
0bcc64a2a823
10098 usbcopy does not deal with smedia mounted usb flash properly
Alexander Eremin <eremin@milax.org>
parents:
680
diff
changeset
|
245 |
do |
0bcc64a2a823
10098 usbcopy does not deal with smedia mounted usb flash properly
Alexander Eremin <eremin@milax.org>
parents:
680
diff
changeset
|
246 |
umount -f $devs > /dev/null 2>&1 |
0bcc64a2a823
10098 usbcopy does not deal with smedia mounted usb flash properly
Alexander Eremin <eremin@milax.org>
parents:
680
diff
changeset
|
247 |
done |
680
416390c26142
3446 usbcopy cannot work with localized message command.
David Miner <dminer@opensolaris.org>
parents:
313
diff
changeset
|
248 |
|
416390c26142
3446 usbcopy cannot work with localized message command.
David Miner <dminer@opensolaris.org>
parents:
313
diff
changeset
|
249 |
# Drop in config file to ensure HAL ignores the disk, otherwise it will attempt |
416390c26142
3446 usbcopy cannot work with localized message command.
David Miner <dminer@opensolaris.org>
parents:
313
diff
changeset
|
250 |
# to mount it after the partition table is rewritten |
416390c26142
3446 usbcopy cannot work with localized message command.
David Miner <dminer@opensolaris.org>
parents:
313
diff
changeset
|
251 |
fdi=/etc/hal/fdi/preprobe/10osvendor/99-usbcopy.fdi |
1617
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
252 |
trap cleanup SIGTERM EXIT |
680
416390c26142
3446 usbcopy cannot work with localized message command.
David Miner <dminer@opensolaris.org>
parents:
313
diff
changeset
|
253 |
|
416390c26142
3446 usbcopy cannot work with localized message command.
David Miner <dminer@opensolaris.org>
parents:
313
diff
changeset
|
254 |
cat >$fdi << EOF |
416390c26142
3446 usbcopy cannot work with localized message command.
David Miner <dminer@opensolaris.org>
parents:
313
diff
changeset
|
255 |
<?xml version="1.0" encoding="UTF-8"?> |
416390c26142
3446 usbcopy cannot work with localized message command.
David Miner <dminer@opensolaris.org>
parents:
313
diff
changeset
|
256 |
<deviceinfo version="0.2"> |
416390c26142
3446 usbcopy cannot work with localized message command.
David Miner <dminer@opensolaris.org>
parents:
313
diff
changeset
|
257 |
<device> |
1617
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
258 |
<match key="block.device" string="$bdev"> |
680
416390c26142
3446 usbcopy cannot work with localized message command.
David Miner <dminer@opensolaris.org>
parents:
313
diff
changeset
|
259 |
<merge key="info.ignore" type="bool">true</merge> |
416390c26142
3446 usbcopy cannot work with localized message command.
David Miner <dminer@opensolaris.org>
parents:
313
diff
changeset
|
260 |
</match> |
416390c26142
3446 usbcopy cannot work with localized message command.
David Miner <dminer@opensolaris.org>
parents:
313
diff
changeset
|
261 |
</device> |
416390c26142
3446 usbcopy cannot work with localized message command.
David Miner <dminer@opensolaris.org>
parents:
313
diff
changeset
|
262 |
</deviceinfo> |
416390c26142
3446 usbcopy cannot work with localized message command.
David Miner <dminer@opensolaris.org>
parents:
313
diff
changeset
|
263 |
EOF |
197
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
264 |
|
1617
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
265 |
# lofi mount the USB image file into a temp dir |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
266 |
usbmntpt="$(mktemp -d)" |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
267 |
usbdev="$(lofiadm -a "${img}")" || \ |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
268 |
error_handler "Failed to lofiadm ${img}" |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
269 |
mount -F ufs -o ro $usbdev $usbmntpt || \ |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
270 |
error_handler "Failed to mount ${usbdev} on ${usbmntpt}" |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
271 |
|
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
272 |
haslegacygrub=0 |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
273 |
if [ -f $usbmntpt/boot/grub/grub.cfg ] ; then |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
274 |
# GRUB2 |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
275 |
setup_grub2 |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
276 |
elif [ -f $usbmntpt/boot/grub/menu.lst ] ; then |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
277 |
# Legacy GRUB |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
278 |
# Install fdisk table with Solaris using entire disk, default VTOC |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
279 |
haslegacygrub=1 |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
280 |
fdisk -B $dev |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
281 |
else |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
282 |
error_handler "Failed to find boot loader configuration" |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
283 |
fi |
197
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
284 |
|
1769
36ef49b30618
7190711 ultra20 hangs while trying to load GRUB from USB when booting s11u1_15 or later
Mary Ding <mary.ding@oracle.com>
parents:
1617
diff
changeset
|
285 |
# Remove the PBR from the Solaris partition to ensure no stray data confuses |
36ef49b30618
7190711 ultra20 hangs while trying to load GRUB from USB when booting s11u1_15 or later
Mary Ding <mary.ding@oracle.com>
parents:
1617
diff
changeset
|
286 |
# some BIOSes |
36ef49b30618
7190711 ultra20 hangs while trying to load GRUB from USB when booting s11u1_15 or later
Mary Ding <mary.ding@oracle.com>
parents:
1617
diff
changeset
|
287 |
dd if=/dev/zero of=${p2bdev} count=1 > /dev/null 2>&1 |
36ef49b30618
7190711 ultra20 hangs while trying to load GRUB from USB when booting s11u1_15 or later
Mary Ding <mary.ding@oracle.com>
parents:
1617
diff
changeset
|
288 |
[[ $? -ne 0 ]] && { echo Failed to zero Solaris PBR on USB device. ; exit 1; } |
36ef49b30618
7190711 ultra20 hangs while trying to load GRUB from USB when booting s11u1_15 or later
Mary Ding <mary.ding@oracle.com>
parents:
1617
diff
changeset
|
289 |
|
197
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
290 |
# Now create root partition. We want to find number of cylinders in backup |
1617
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
291 |
# partition from label created by fdisk and then generate root partition |
197
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
292 |
# using whole disk minus cylinder 1 |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
293 |
acyls=$(prtvtoc $dev | awk '/accessible/{print $2}') |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
294 |
cyls=$((acyls - 1)) |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
295 |
format -e $dev >/dev/null <<EOF |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
296 |
partition |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
297 |
0 |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
298 |
root |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
299 |
wm |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
300 |
1 |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
301 |
${cyls}c |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
302 |
label |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
303 |
0 |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
304 |
y |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
305 |
EOF |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
306 |
|
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
307 |
# Copy image to USB. |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
308 |
echo "Copying and verifying image to USB device" |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
309 |
SECONDS=0 |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
310 |
# For now, copy in 16k chunks, 4MB at a time |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
311 |
# NOTE: To avoid problems, cmb should be >= 1 and bs should evenly |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
312 |
# divide into csz. |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
313 |
bs=$((16 << 10)) |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
314 |
cmb=4 |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
315 |
|
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
316 |
csz=$((cmb << 20)) |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
317 |
bcnt=$((csz / bs)) |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
318 |
icnt=$((isz / cmb)) |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
319 |
|
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
320 |
maxt=3 |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
321 |
i=0 |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
322 |
retries=0 |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
323 |
|
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
324 |
while [[ $i -le $icnt ]]; do |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
325 |
tries=0 |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
326 |
pcnt="($((i * 100 / icnt))%)" |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
327 |
s=$((i * bcnt)) |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
328 |
|
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
329 |
echo -ne "R $i / $icnt $pcnt \\r" |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
330 |
imgsum=$(dd bs=$bs count=$bcnt conv=sync \ |
1473
9da5f7c960d6
7089049 need to replace md5sum with digest -a sum in order for usbcopy to work.
Mary Ding <mary.ding@oracle.com>
parents:
1247
diff
changeset
|
331 |
iseek=$s if=$img 2>/dev/null | digest -a md5) |
197
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
332 |
[[ $? -ne 0 ]] && { echo Read from image failed. ; exit 1; } |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
333 |
|
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
334 |
while [[ $((tries++)) -lt $maxt ]]; do |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
335 |
echo -ne "W $i / $icnt $pcnt \\r" |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
336 |
recs=$(dd bs=$bs count=$bcnt conv=sync iseek=$s oseek=$s \ |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
337 |
if=$img of=$s0cdev 2>&1 | awk -F+ '/records out/{print $1}') |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
338 |
[[ $? -ne 0 ]] && { echo Write to device failed. ; exit 1; } |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
339 |
|
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
340 |
echo -ne "V $i / $icnt $pcnt \\r" |
1473
9da5f7c960d6
7089049 need to replace md5sum with digest -a sum in order for usbcopy to work.
Mary Ding <mary.ding@oracle.com>
parents:
1247
diff
changeset
|
341 |
devsum=$(dd bs=$bs count=$recs iseek=$s if=$s0cdev 2>/dev/null | digest -a md5) |
197
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
342 |
[[ $? -ne 0 ]] && { echo Read from device failed. ; exit 1; } |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
343 |
|
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
344 |
[[ "$imgsum" = "$devsum" ]] && break; |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
345 |
done |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
346 |
[[ $tries -gt 1 ]] && ((retries++)) |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
347 |
|
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
348 |
if [[ $tries -gt $maxt ]]; then |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
349 |
echo "Verification failed after $maxt attempts on block $i" |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
350 |
exit 1 |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
351 |
fi |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
352 |
|
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
353 |
((i++)) |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
354 |
done |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
355 |
|
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
356 |
speed="$((isz / SECONDS)).$((isz * 10 / SECONDS % 10))MB/s" |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
357 |
echo "Finished $isz MB in $SECONDS seconds ($speed)" |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
358 |
echo "$retries block(s) re-written due to verification failure" |
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
359 |
|
1617
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
360 |
if [ $haslegacygrub -eq 1 ] ; then |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
361 |
# Legacy GRUB. Install boot loader to USB physical device |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
362 |
setup_legacy_grub |
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
363 |
fi |
680
416390c26142
3446 usbcopy cannot work with localized message command.
David Miner <dminer@opensolaris.org>
parents:
313
diff
changeset
|
364 |
|
1617
0a764388bf3b
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) Install Phase I:
Niall Power <niall.power@oracle.com>
parents:
1473
diff
changeset
|
365 |
cleanup |
680
416390c26142
3446 usbcopy cannot work with localized message command.
David Miner <dminer@opensolaris.org>
parents:
313
diff
changeset
|
366 |
|
197
ac1383e6038c
2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff
changeset
|
367 |
echo "Completed copy to USB" |
680
416390c26142
3446 usbcopy cannot work with localized message command.
David Miner <dminer@opensolaris.org>
parents:
313
diff
changeset
|
368 |
exit 0 |