From 130d363aaa7fa4b201d76c61ec0447e216902c85 Mon Sep 17 00:00:00 2001 From: Aaron Plattner Date: Tue, 18 Oct 2011 08:54:57 -0700 Subject: [PATCH] Bind-mount /run if it exists Ubuntu 11.10, for whatever reason, moved /dev/shm to /run/shm. Since /run is not mounted in the chroot, /dev/shm is a dangling symlink and various things that require shared memory start failing. If /run and /run/shm exist, bind-mount them in the chroot. Because /run doesn't yet exist in the SDK tarballs, try to create it (and /run/shm if necessary) as root if it and can't be created as a normal user. BUG=chromium-os:19871 TEST=Run cros_sdk, verify that /dev/shm has the expected contents Change-Id: I61583c1c0d409c1234fa8d8930a9b64544c9a8e7 Reviewed-on: https://gerrit.chromium.org/gerrit/10222 Tested-by: Aaron Plattner Reviewed-by: David James Commit-Ready: David James --- sdk_lib/enter_chroot.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/sdk_lib/enter_chroot.sh b/sdk_lib/enter_chroot.sh index 3d7582f5a4..3fb61d7b9b 100755 --- a/sdk_lib/enter_chroot.sh +++ b/sdk_lib/enter_chroot.sh @@ -104,8 +104,12 @@ function ensure_mounted { *) # Attempt to make the mountpoint as the user. This depends on the # fact that all mountpoints that should be owned by root are - # already present. - mkdir -p "${mounted_path}" + # already present. However, when distributions add new paths (such as + # Ubuntu 11.10's /run), it might not yet exist in the chroot. If that + # happens, just create it as root. + if ! mkdir -p "${mounted_path}" 2>/dev/null; then + sudo mkdir -p "${mounted_path}" + fi # NB: mount_args deliberately left unquoted debug mount ${mount_args} "${source}" "${mounted_path}" @@ -238,6 +242,12 @@ function setup_env { ensure_mounted none "-t sysfs" /sys ensure_mounted /dev "--bind" /dev ensure_mounted none "-t devpts" /dev/pts + if [ -d /run ]; then + ensure_mounted /run "--bind" /run + if [ -d /run/shm ]; then + ensure_mounted /run/shm "--bind" /run/shm + fi + fi ensure_mounted "${FLAGS_trunk}" "--bind" "${CHROOT_TRUNK_DIR}" if [ $FLAGS_ssh_agent -eq $FLAGS_TRUE ]; then