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

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: 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 umage into an SSD image. Changes are made in plac e.
scottz-goog 2011/02/23 01:37:50 >80
8
9 # Load common constants and variables.
10 . "$(dirname "$0")/common_minimal.sh"
11
12 usage() {
13 cat <<EOF
14 Usage: $PROG <image> [--force]
15
16 In-place converts recovery <image> into an SSD image. With --force, does not ask for
scottz-goog 2011/02/23 01:37:50 >80
17 confirmation from the user.
18
19 EOF
20 }
21
22 if [ $# -gt 2 ]; then
23 usage
24 exit 1
25 fi
26
27 type -P cgpt &>/dev/null ||
scottz-goog 2011/02/23 01:37:50 Any particular reason why you chose type over whic
28 { echo "cgpt tool must be in the path"; exit 1; }
29
30 # Abort on errors.
31 set -e
32
33 IMAGE=$1
34 IS_FORCE=$2
scottz-goog 2011/02/23 01:37:50 You sort of assume that we are getting --force as
35
36 if [ "${IS_FORCE}" != "--force" ]; then
37 echo "This will modify ${IMAGE} in-place and convert it into an SSD image."
38 read -p "Are you sure you want to continue (y/N)?" SURE
39 SURE="${SURE:0:1}"
40 [ "${SURE}" != "y" ] && exit 1
41 fi
42
43 kerna_offset=$(partoffset ${IMAGE} 2)
scottz-goog 2011/02/23 01:37:50 Are we assuming this is in our path or is this in
44 kernb_offset=$(partoffset ${IMAGE} 4)
45 # Kernel partition sizes should be the same.
46 kern_size=$(partsize ${IMAGE} 2)
47
48 # Move Kernel B to Kernel A.
49 kernb=$(make_temp_file)
50 echo "Replacing Kernel partition A with Kernel partition B"
51 extract_image_partition ${IMAGE} 4 ${kernb}
52 replace_image_partition ${IMAGE} 2 ${kernb}
53
54 # Overwrite the vblock.
55 stateful_dir=$(make_temp_dir)
56 tmp_vblock=$(make_temp_file)
57 mount_image_partition_ro ${IMAGE} 1 ${stateful_dir}
58 sudo cp ${stateful_dir}/vmlinuz_hd.vblock ${tmp_vblock}
59 # Unmount before overwriting image to avoid sync issues.
60 sudo umount -d ${stateful_dir}
61 echo "Overwriting kernel partition A vblock with SSD vblock"
62 sudo dd if=${tmp_vblock} of=${IMAGE} seek=${kerna_offset} bs=512 conv=notrunc
63
64 # Zero out Kernel B partition.
65 echo "Zeroing out Kernel partition B"
66 sudo dd if=/dev/zero of=${IMAGE} seek=${kernb_offset} bs=512 count=${kern_size} conv=notrunc
67 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