mirror of
https://github.com/flatcar/scripts.git
synced 2025-11-26 21:11:54 +01:00
cros_make_image_bootable: Do a final sanity check on the rootfs by running e2fsck
This is a complement to the proposed fix for http://crosbug.com/9447, and I am getting it out first since it is a relatively simple change. This change ensures that the rootfs on the image output by cros_make_image_bootable wasn't corrupted accidentally (for example, no boot.desc was provided and the defaults were incorrect for the image). This should catch rootfs errors that we end up discovering at delta AU time. BUG=chromium-os:9578 TEST= Ran cros_make_image_bootable manually on an existing image with and without boot.desc. As expected, without boot.desc the output image rootfs had errors. Also ran ./build_image - which worked fine too. Change-Id: I4ed3a56634f37ab7d5ff2dc052ad607740356a40 Review URL: http://codereview.chromium.org/5216003
This commit is contained in:
parent
b2d2212bb9
commit
d02793a5d7
@ -250,6 +250,24 @@ make_image_bootable() {
|
||||
-s "${FLAGS_statefulfs_mountpoint}"
|
||||
}
|
||||
|
||||
verify_image_rootfs() {
|
||||
local image=$1
|
||||
local rootfs_offset="$(partoffset ${image} 3)"
|
||||
local rootfs_size="$(partsize ${image} 3)"
|
||||
|
||||
local rootfs_tmp_file=$(mktemp)
|
||||
trap "rm ${rootfs_tmp_file}" EXIT
|
||||
sudo dd if="${image}" of="${rootfs_tmp_file}" bs=512 skip="${rootfs_offset}"
|
||||
|
||||
# This flips the read-only compatibility flag, so that
|
||||
# e2fsck does not complain about unknown file system capabilities.
|
||||
enable_rw_mount "${rootfs_tmp_file}"
|
||||
info "Running e2fsck to check root file system for errors"
|
||||
sudo e2fsck -fn "${rootfs_tmp_file}" ||
|
||||
die "Root file system has errors, please ensure boot.desc and/or \
|
||||
command line parameters are correct"
|
||||
}
|
||||
|
||||
# Use default of current image location if the output dir doesn't exist.
|
||||
if [ ! -d ${FLAGS_output_dir} ]; then
|
||||
warn "Output dir not found, using ${IMAGE_DIR}."
|
||||
@ -265,7 +283,8 @@ mkdir -p ${FLAGS_rootfs_mountpoint}
|
||||
mkdir -p ${FLAGS_statefulfs_mountpoint}
|
||||
mkdir -p ${FLAGS_espfs_mountpoint}
|
||||
|
||||
make_image_bootable ${IMAGE}
|
||||
make_image_bootable "${IMAGE}"
|
||||
verify_image_rootfs "${IMAGE}"
|
||||
|
||||
if [ ${FLAGS_cleanup_dirs} -eq ${FLAGS_TRUE} ]; then
|
||||
rmdir ${FLAGS_rootfs_mountpoint}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user