aboutsummaryrefslogtreecommitdiff
path: root/contrib/mount-ext4-ramdisk.sh
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/mount-ext4-ramdisk.sh')
-rwxr-xr-xcontrib/mount-ext4-ramdisk.sh16
1 files changed, 10 insertions, 6 deletions
diff --git a/contrib/mount-ext4-ramdisk.sh b/contrib/mount-ext4-ramdisk.sh
index 66de968..5ff7ef1 100755
--- a/contrib/mount-ext4-ramdisk.sh
+++ b/contrib/mount-ext4-ramdisk.sh
@@ -8,9 +8,13 @@ fi
IMG=$(mktemp /tmp/ext4-ramdisk-XXX.img)
-dd if=/dev/zero of=$IMG bs=1M count=1030
-mkfs.ext4 -q $IMG
-mkdir -p $MNT
-mount $IMG $MNT
-chmod 777 $MNT
-rm $IMG # unlink the file, it will be deleted once the fs is unmounted
+# unlink the file when done, space will be
+# reclaimed once the fs is unmounted. Also
+# cleans up in the error case.
+trap 'rm "$IMG"' EXIT
+
+dd if=/dev/zero of="$IMG" bs=1M count=1030 status=none
+mkfs.ext4 -q "$IMG"
+mkdir -p "$MNT"
+mount "$IMG" "$MNT"
+chmod 777 "$MNT"