Created
January 18, 2018 03:47
-
-
Save deoren/8b9c4ac22cf852e60798cc81df872b86 to your computer and use it in GitHub Desktop.
Create image file, format it and then mount it
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Untested shell script to create and mount an image file. Pretty much a copy/paste | |
# from this site: | |
# | |
# http://ubuntuhak.blogspot.com/2012/10/how-to-create-format-and-mount-img-files.html | |
img_file="/tmp/bucket.img" | |
img_size_in_mb="1024" | |
mount_point="/tmp/bucket" | |
# Create 1 GB "bucket" | |
sudo dd if=/dev/zero of=${img_file} bs=1M count=${img_size_in_mb} | |
# Format new image file | |
sudo mkfs ext4 -m0 -F ${img_file} | |
sudo mkdir -p ${mount_point} | |
sudo mount -o loop,rw,sync ${img_file} ${mount_point} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As of the time this Gist entry was created, GitHub does not support notifications for comments for mentions to Gist entries (see isaacs/github#21 for details). Please contact me via Twitter or file an issue in the deoren/leave-feedback repo (created for that very purpose) if you wish to receive a response for your feedback. Thank you in advance!