Skip to content

Instantly share code, notes, and snippets.

@vpack
Created March 4, 2015 14:10
Show Gist options
  • Save vpack/b78f7237872fdc4fbe70 to your computer and use it in GitHub Desktop.
Save vpack/b78f7237872fdc4fbe70 to your computer and use it in GitHub Desktop.
Mounting a file as a filesystem
# Create a new file
dd if=/dev/zero of=my_fs bs=1M count=1024
Or
truncate -s 30M my_fs
# Check if the device is not already in use before using it
sudo losetup /dev/loop0
sudo losetup /dev/loop0 my_fs
# Make a file system and mount it
sudo mkfs -t ext3 -m 1 -v /dev/loop0
sudo mount -t ext3 /dev/loop0 /mnt/new
# Done. Now let tear it down !!
sudo unmount /mnt/new
sudo losetup -d /dev/loop0
# Gone !!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment