#!/bin/bash

target="union"

function write() {
  [ -z "${1}" ] && return 1

  mkdir -p ${target}/$(dirname ${1})
  cat > ${target}/${1}
}

function chroot() {
  $(which chroot) ${target} env -i /bin/bash
}

function setup_fs() {
  if [ ! -f fs ]; then
    dd if=/dev/null of=fs bs=1k seek=512k
    mkfs.ext4 -q -F fs
  fi

  mkdir -p rootfs ${target}
  mount -n -o loop fs rootfs

  codename=$(lsb_release -c -s)

  case "${codename}" in

  lucid)
    mount -n -t aufs -o br:rootfs=rw:../../base/rootfs=ro+wh none ${target}
    ;;

  precise)
    mount -n -t overlayfs -o rw,upperdir=rootfs,lowerdir=../../base/rootfs none ${target}
    ;;

  *)
    echo "Unsupported: '${codename}'"
    exit 1
    ;;

  esac
}

function teardown_fs() {
  umount ${target}
  umount rootfs
}

#!/bin/bash

target="union"

function write() {
  [ -z "${1}" ] && return 1

  mkdir -p ${target}/$(dirname ${1})
  cat > ${target}/${1}
}

function chroot() {
  $(which chroot) ${target} env -i /bin/bash
}

function setup_fs() {
  if [ ! -f fs ]; then
    dd if=/dev/null of=fs bs=1k seek=512k
    mkfs.ext2 -q -F fs
  fi

  mkdir -p rootfs ${target}
  mount -n -o loop fs rootfs

  codename=$(lsb_release -c -s)

  case "${codename}" in

  lucid)
    mount -n -t aufs -o br:rootfs=rw:../../base/rootfs=ro+wh none ${target}
    ;;

  precise)
    mount -n -t overlayfs -o rw,upperdir=rootfs,lowerdir=../../base/rootfs none ${target}
    ;;

  *)
    echo "Unsupported: '${codename}'"
    exit 1
    ;;

  esac
}

function teardown_fs() {
  umount ${target}
  umount rootfs
}

Use ext2 for ephemeral volumes
warden: Use ext2 for ephemeral volumes

There's no need for journaling and ext2 is faster.

Change-Id: Ife96d3a29eebee0cad73f09180fc56169550a20d
