fix(*): use /media/state and overlays dir

/mnt/stateful_partition was already a little unruly with
/mnt/stateful_partition/home and /mnt/stateful_partition/var_overlay
serving similar functional purposes.

Then we needed to also add /opt and /srv overlays.

I also have wanted to get rid of the ugly and weird
/mnt/stateful_partition name so lets just have one big move.

/mnt/stateful_partition -> /media/state
/mnt/stateful_partition/var_overlay -> /media/overlays/var
/mnt/stateful_partition/home -> /media/overlays/home

From there we add /media/overlays/srv and /media/overlays/opt
This commit is contained in:
Brandon Philips 2013-07-26 08:41:33 -07:00
parent 0ece58228f
commit cf8be2c320
4 changed files with 23 additions and 13 deletions

View File

@ -28,4 +28,4 @@ STATE="${ROOT}-STATE"
[ -d "$STATE" ] || sudo mkdir -p "$STATE"
sudo systemd-nspawn --boot --read-only --machine="$HOSTNAME-$BOARD" \
--directory="$ROOT" --bind="$STATE:/mnt/stateful_partition"
--directory="$ROOT" --bind="$STATE:/media/state"

View File

@ -4,6 +4,9 @@
. "${SRC_ROOT}/platform/dev/toolchain_utils.sh" || exit 1
# Overlays are parts of the disk that live on the stateful partition
ROOT_OVERLAYS=(var opt srv home)
cleanup_mounts() {
local prev_ret=$?
@ -142,21 +145,28 @@ create_base_image() {
sudo mount -o loop "${oem_fs_img}" "${oem_fs_dir}"
# Prepare stateful partition with some pre-created directories.
sudo mkdir "${stateful_fs_dir}/dev_image"
sudo mkdir "${stateful_fs_dir}/var_overlay"
for i in ${ROOT_OVERLAYS}; do
sudo mkdir -p "${stateful_fs_dir}/overlays/$i"
sudo mkdir -p "${root_fs_dir}/$i"
sudo mount --bind "${stateful_fs_dir}/overlays/$i" "${root_fs_dir}/$i"
done
sudo mkdir -p "${stateful_fs_dir}/images/dev"
# 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 "${stateful_fs_dir}/dev_image" \
"${stateful_fs_dir}/var_overlay" "${stateful_fs_dir}"
setup_symlinks_on_root "${stateful_fs_dir}/images/dev" \
"${stateful_fs_dir}/overlays/var" \
"${stateful_fs_dir}"
# Perform binding rather than symlinking because directories must exist
# on rootfs so that we can bind at run-time since rootfs is read-only.
info "Binding directories from stateful partition onto the rootfs"
# Setup the dev image for developer tools
sudo mkdir -p "${root_fs_dir}/usr/local"
sudo mount --bind "${stateful_fs_dir}/dev_image" "${root_fs_dir}/usr/local"
sudo mkdir -p "${root_fs_dir}/var"
sudo mount --bind "${stateful_fs_dir}/var_overlay" "${root_fs_dir}/var"
sudo mount --bind "${stateful_fs_dir}/images/dev" "${root_fs_dir}/usr/local"
sudo mkdir -p "${root_fs_dir}/dev"
info "Binding directories from OEM partition onto the rootfs"

View File

@ -735,7 +735,7 @@ setup_symlinks_on_root() {
# Give args better names.
local dev_image_target=$1
local var_target=$2
local dev_image_root="$3/dev_image"
local dev_image_root="$3/images/dev"
# If our var target is actually the standard var, we are cleaning up the
# symlinks (could also check for /usr/local for the dev_image_target).

View File

@ -179,15 +179,15 @@ mount_image() {
fi
# Mount directories and setup symlinks.
sudo mount --bind "${FLAGS_stateful_mountpt}/var_overlay" \
sudo mount --bind "${FLAGS_stateful_mountpt}/overlays/var" \
"${FLAGS_rootfs_mountpt}/var"
sudo mount --bind "${FLAGS_stateful_mountpt}/dev_image" \
sudo mount --bind "${FLAGS_stateful_mountpt}/images/dev" \
"${FLAGS_rootfs_mountpt}/usr/local"
# Setup symlinks in /usr/local so you can emerge packages into /usr/local.
if [ ${FLAGS_read_only} -eq ${FLAGS_FALSE} ]; then
setup_symlinks_on_root "${FLAGS_stateful_mountpt}/dev_image" \
"${FLAGS_stateful_mountpt}/var_overlay" "${FLAGS_stateful_mountpt}"
setup_symlinks_on_root "${FLAGS_stateful_mountpt}/images/dev" \
"${FLAGS_stateful_mountpt}/overlays/var" "${FLAGS_stateful_mountpt}"
fi
info "Image specified by ${FLAGS_from} mounted at"\
"${FLAGS_rootfs_mountpt} successfully."