Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(507)

Side by Side Diff: scripts/image_signing/convert_recovery_to_ssd.sh

Issue 6533015: Add script to in-place modify a recovery image to ssd (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/vboot_reference.git@master
Patch Set: 80 chars Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | scripts/image_signing/sign_official_build.sh » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/bin/bash
2
3 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
6
7 # Script to convert a recovery image into an SSD image. Changes are made in-
8 # place.
9
10 # Load common constants and variables.
11 . "$(dirname "$0")/common_minimal.sh"
12
13 usage() {
14 cat <<EOF
15 Usage: $PROG <image> [--force]
16
17 In-place converts recovery <image> into an SSD image. With --force, does not ask for
18 confirmation from the user.
19
20 EOF
21 }
22
23 if [ $# -gt 2 ]; then
24 usage
25 exit 1
26 fi
27
28 type -P cgpt &>/dev/null ||
29 { echo "cgpt tool must be in the path"; exit 1; }
30
31 # Abort on errors.
32 set -e
33
34 IMAGE=$1
35 IS_FORCE=$2
36
37 if [ "${IS_FORCE}" != "--force" ]; then
38 echo "This will modify ${IMAGE} in-place and convert it into an SSD image."
39 read -p "Are you sure you want to continue (y/N)?" SURE
40 SURE="${SURE:0:1}"
41 [ "${SURE}" != "y" ] && exit 1
42 fi
43
44 kerna_offset=$(partoffset ${IMAGE} 2)
45 kernb_offset=$(partoffset ${IMAGE} 4)
46 # Kernel partition sizes should be the same.
47 kern_size=$(partsize ${IMAGE} 2)
48
49 # Move Kernel B to Kernel A.
50 kernb=$(make_temp_file)
51 echo "Replacing Kernel partition A with Kernel partition B"
52 extract_image_partition ${IMAGE} 4 ${kernb}
53 replace_image_partition ${IMAGE} 2 ${kernb}
54
55 # Overwrite the vblock.
56 stateful_dir=$(make_temp_dir)
57 tmp_vblock=$(make_temp_file)
58 mount_image_partition_ro ${IMAGE} 1 ${stateful_dir}
59 sudo cp ${stateful_dir}/vmlinuz_hd.vblock ${tmp_vblock}
60 # Unmount before overwriting image to avoid sync issues.
61 sudo umount -d ${stateful_dir}
62 echo "Overwriting kernel partition A vblock with SSD vblock"
63 sudo dd if=${tmp_vblock} of=${IMAGE} seek=${kerna_offset} bs=512 conv=notrunc
64
65 # Zero out Kernel B partition.
66 echo "Zeroing out Kernel partition B"
67 sudo dd if=/dev/zero of=${IMAGE} seek=${kernb_offset} bs=512 count=${kern_size} conv=notrunc
68 echo "${IMAGE} was converted to an SSD image."
OLDNEW
« no previous file with comments | « no previous file | scripts/image_signing/sign_official_build.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698