Relocate stateful_parition/var to stateful_partition/var_overlay

To avoid needing to migrate fresh dev images's /var contents when
using the encrypted partition, move the /var bits out of the old
stateful_partition/var location into stateful_partition/var_overlay.

The (initially empty) system /var will continue to either live
in stateful_partition/var (in the unencrypted case), or in
stateful_partition/encrypted/var (in the encrypted case).

The contents needed for gmerge will be symlinked into place at runtime
(via CL I6e68b1f334f5d5b3c4d2977008435bd929191ce7). While the installer
already makes sure that /var is not shipped on an image, this change
additionally make sure that the other contents installed by the ebuilds
will not show up in the actual /var either.

BUG=chromium-os:22172
TEST=link build, boot, install, manual testing.

Change-Id: Ie6480a59929818fe5d36a46abf533b648fb78850
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/26355
Reviewed-by: Chris Sosa <sosa@chromium.org>
This commit is contained in:
Kees Cook 2012-06-28 12:33:59 -07:00 committed by Gerrit
parent ccf8f9590d
commit 224817fda9
3 changed files with 9 additions and 9 deletions

View File

@ -1,5 +1,5 @@
#!/bin/bash
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@ -53,7 +53,7 @@ cp ./part_* ./orig_partitions
sudo mount -o loop part_3 rootfs
sudo mount -o loop part_1 stateful_part
sudo mount --bind stateful_part/dev_image rootfs/usr/local
sudo mount --bind stateful_part/var rootfs/var
sudo mount --bind stateful_part/var_overlay rootfs/var
emerge-${BOARD} --root="./rootfs" \
--root-deps=rdeps --nodeps --usepkgonly ${PKGS}

View File

@ -1,4 +1,4 @@
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@ -117,11 +117,11 @@ create_base_image() {
# Prepare stateful partition with some pre-created directories.
sudo mkdir -p "${DEV_IMAGE_ROOT}"
sudo mkdir -p "${STATEFUL_FS_DIR}/var"
sudo mkdir -p "${STATEFUL_FS_DIR}/var_overlay"
# Create symlinks so that /usr/local/usr based directories are symlinked to
# /usr/local/ directories e.g. /usr/local/usr/bin -> /usr/local/bin, etc.
setup_symlinks_on_root "${DEV_IMAGE_ROOT}" "${STATEFUL_FS_DIR}/var" \
setup_symlinks_on_root "${DEV_IMAGE_ROOT}" "${STATEFUL_FS_DIR}/var_overlay" \
"${STATEFUL_FS_DIR}"
# Perform binding rather than symlinking because directories must exist
@ -130,7 +130,7 @@ create_base_image() {
sudo mkdir -p "${ROOT_FS_DIR}/usr/local"
sudo mount --bind "${DEV_IMAGE_ROOT}" "${ROOT_FS_DIR}/usr/local"
sudo mkdir -p "${ROOT_FS_DIR}/var"
sudo mount --bind "${STATEFUL_FS_DIR}/var" "${ROOT_FS_DIR}/var"
sudo mount --bind "${STATEFUL_FS_DIR}/var_overlay" "${ROOT_FS_DIR}/var"
sudo mkdir -p "${ROOT_FS_DIR}/dev"
# We need to install libc manually from the cross toolchain.

View File

@ -1,6 +1,6 @@
#!/bin/bash
# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@ -180,7 +180,7 @@ mount_image() {
fi
# Mount directories and setup symlinks.
sudo mount --bind "${FLAGS_stateful_mountpt}/var" \
sudo mount --bind "${FLAGS_stateful_mountpt}/var_overlay" \
"${FLAGS_rootfs_mountpt}/var"
sudo mount --bind "${FLAGS_stateful_mountpt}/dev_image" \
"${FLAGS_rootfs_mountpt}/usr/local"
@ -188,7 +188,7 @@ mount_image() {
if [ ${FLAGS_read_only} -eq ${FLAGS_FALSE} ]; then
setup_symlinks_on_root "${FLAGS_stateful_mountpt}/dev_image" \
"${FLAGS_stateful_mountpt}/var" "${FLAGS_stateful_mountpt}"
"${FLAGS_stateful_mountpt}/var_overlay" "${FLAGS_stateful_mountpt}"
fi
info "Image specified by ${FLAGS_from} mounted at"\
"${FLAGS_rootfs_mountpt} successfully."