#!/bin/sh set -ex IMG=$HOME/ext4.img MNT=/ext4 if [ "$1" != 'mount' ]; then rm -f $IMG truncate --size 128M $IMG fi DEV=$(sudo losetup --find --show $IMG) if [ "$1" != 'mount' ]; then sudo mkfs.ext4 $DEV sudo tune2fs -f -o journal_data $DEV fi sudo mkdir -p $MNT sudo mount -o data=journal $DEV $MNT sudo chown -R ubuntu:ubuntu $MNT