diff options
author | Jakob Unterwurzacher | 2020-09-18 13:21:07 +0200 |
---|---|---|
committer | Jakob Unterwurzacher | 2020-09-18 13:21:07 +0200 |
commit | 95caa66e0b7e55e71aeed2a0a3160e68fd5fe595 (patch) | |
tree | 751787e0d1d38b70c8c61ef42bc39723ab3841e0 /contrib | |
parent | 55fcacfc27aeb5217b637fa60f4f562aa7daf633 (diff) |
contrib/mount-ext4-ramdisk.sh: clean up in error case
Also fix all shellcheck warnings.
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/mount-ext4-ramdisk.sh | 16 |
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" |