libgocryptfs/contrib/mount-ext4-ramdisk.sh

21 lines
389 B
Bash
Raw Normal View History

2020-09-14 19:01:33 +02:00
#!/bin/bash -ex
MNT=/mnt/ext4-ramdisk
2021-08-31 19:01:47 +02:00
if mountpoint "$MNT" ; then
2020-09-14 19:01:33 +02:00
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"