libgocryptfs/contrib/mount-ext4-ramdisk.sh
Jakob Unterwurzacher 95caa66e0b contrib/mount-ext4-ramdisk.sh: clean up in error case
Also fix all shellcheck warnings.
2020-09-18 13:21:07 +02:00

21 lines
387 B
Bash
Executable File

#!/bin/bash -ex
MNT=/mnt/ext4-ramdisk
if mountpoint $MNT ; then
exit 1
fi
IMG=$(mktemp /tmp/ext4-ramdisk-XXX.img)
# 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"