| OLD | NEW |
| 1 #!/bin/bash | 1 #!/bin/bash |
| 2 | 2 |
| 3 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 # Script to build a bootable keyfob-based chromeos system image from within | 7 # Script to build a bootable keyfob-based chromeos system image from within |
| 8 # a chromiumos setup. This assumes that all needed packages have been built into | 8 # a chromiumos setup. This assumes that all needed packages have been built into |
| 9 # the given target's root with binary packages turned on. This script will | 9 # the given target's root with binary packages turned on. This script will |
| 10 # build the Chrome OS image using only pre-built binary packages. | 10 # build the Chrome OS image using only pre-built binary packages. |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 fi | 525 fi |
| 526 | 526 |
| 527 # Create root file system disk image to fit on a 1GB memory stick. | 527 # Create root file system disk image to fit on a 1GB memory stick. |
| 528 # 1 GB in hard-drive-manufacturer-speak is 10^9, not 2^30. 950MB < 10^9 bytes
. | 528 # 1 GB in hard-drive-manufacturer-speak is 10^9, not 2^30. 950MB < 10^9 bytes
. |
| 529 if [[ ${FLAGS_factory_install} -eq ${FLAGS_TRUE} ]] ; then | 529 if [[ ${FLAGS_factory_install} -eq ${FLAGS_TRUE} ]] ; then |
| 530 ROOT_SIZE_BYTES=$((1024 * 1024 * 300)) | 530 ROOT_SIZE_BYTES=$((1024 * 1024 * 300)) |
| 531 else | 531 else |
| 532 ROOT_SIZE_BYTES=$((1024 * 1024 * ${FLAGS_rootfs_size})) | 532 ROOT_SIZE_BYTES=$((1024 * 1024 * ${FLAGS_rootfs_size})) |
| 533 fi | 533 fi |
| 534 | 534 |
| 535 dd if=/dev/zero of="${ROOT_FS_IMG}" bs=1 count=1 seek=$((ROOT_SIZE_BYTES - 1)) | 535 # Pad out for the hash tree. |
| 536 sudo losetup "${LOOP_DEV}" "${ROOT_FS_IMG}" | |
| 537 sudo mkfs.ext3 "${LOOP_DEV}" | |
| 538 | |
| 539 # Pad out 10% for the hash tree. This currently _exact_ for | |
| 540 # default configuration. More space may be needed for different options. | |
| 541 ROOT_HASH_PAD=$((FLAGS_rootfs_hash_pad * 1024 * 1024)) | 536 ROOT_HASH_PAD=$((FLAGS_rootfs_hash_pad * 1024 * 1024)) |
| 542 info "Padding the rootfs image by ${ROOT_HASH_PAD} bytes for hash data" | 537 info "Padding the rootfs image by ${ROOT_HASH_PAD} bytes for hash data" |
| 538 |
| 543 dd if=/dev/zero of="${ROOT_FS_IMG}" bs=1 count=1 \ | 539 dd if=/dev/zero of="${ROOT_FS_IMG}" bs=1 count=1 \ |
| 544 seek=$((ROOT_SIZE_BYTES + ROOT_HASH_PAD - 1)) | 540 seek=$((ROOT_SIZE_BYTES + ROOT_HASH_PAD - 1)) |
| 545 # Update to reflect the new capacity in the loop device. | 541 sudo losetup "${LOOP_DEV}" "${ROOT_FS_IMG}" |
| 546 sudo losetup -c "${LOOP_DEV}" | 542 # Specify a block size and block count to avoid using the hash pad. |
| 543 sudo mkfs.ext3 -b 4096 "${LOOP_DEV}" "$((ROOT_SIZE_BYTES / 4096))" |
| 547 | 544 |
| 548 # Tune and mount rootfs. | 545 # Tune and mount rootfs. |
| 549 # TODO(wad) rename the disk label to match the GPT since we | 546 # TODO(wad) rename the disk label to match the GPT since we |
| 550 # can't change it later. | 547 # can't change it later. |
| 551 DISK_LABEL="C-KEYFOB" | 548 DISK_LABEL="C-KEYFOB" |
| 552 sudo tune2fs -L "${DISK_LABEL}" -U "${UUID}" -c 0 -i 0 "${LOOP_DEV}" | 549 sudo tune2fs -L "${DISK_LABEL}" -U "${UUID}" -c 0 -i 0 "${LOOP_DEV}" |
| 553 sudo mount "${LOOP_DEV}" "${ROOT_FS_DIR}" | 550 sudo mount "${LOOP_DEV}" "${ROOT_FS_DIR}" |
| 554 | 551 |
| 555 # Create stateful partition of the same size as the rootfs. | 552 # Create stateful partition of the same size as the rootfs. |
| 556 STATEFUL_LOOP_DEV=$(sudo losetup -f) | 553 STATEFUL_LOOP_DEV=$(sudo losetup -f) |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 768 echo "Developer image created as ${DEVELOPER_IMAGE_NAME}" | 765 echo "Developer image created as ${DEVELOPER_IMAGE_NAME}" |
| 769 fi | 766 fi |
| 770 | 767 |
| 771 print_time_elapsed | 768 print_time_elapsed |
| 772 | 769 |
| 773 echo "To copy to USB keyfob, OUTSIDE the chroot, do something like:" | 770 echo "To copy to USB keyfob, OUTSIDE the chroot, do something like:" |
| 774 echo " ./image_to_usb.sh --from=${OUTSIDE_OUTPUT_DIR} --to=/dev/sdX" | 771 echo " ./image_to_usb.sh --from=${OUTSIDE_OUTPUT_DIR} --to=/dev/sdX" |
| 775 echo "To convert to VMWare image, OUTSIDE the chroot, do something like:" | 772 echo "To convert to VMWare image, OUTSIDE the chroot, do something like:" |
| 776 echo " ./image_to_vm.sh --from=${OUTSIDE_OUTPUT_DIR}" | 773 echo " ./image_to_vm.sh --from=${OUTSIDE_OUTPUT_DIR}" |
| 777 echo "from the scripts directory where you entered the chroot." | 774 echo "from the scripts directory where you entered the chroot." |
| OLD | NEW |