Skip to content

Instantly share code, notes, and snippets.

@silenceshell
Last active January 7, 2019 07:39
Show Gist options
  • Save silenceshell/e9117aa5ff5b162528cbe2a561523f7a to your computer and use it in GitHub Desktop.
Save silenceshell/e9117aa5ff5b162528cbe2a561523f7a to your computer and use it in GitHub Desktop.
create a loopback file and mount it
#!/bin/bash
# sudo loopmount file size mount-point
touch $1
truncate -s $2 $1
mke2fs -t ext4 -F $1 1> /dev/null 2> /dev/null
if [[ ! -d $3 ]]; then
echo $3 " not exist, creating..."
mkdir $3
fi
mount $1 $3
df -h |grep $3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment