Created
December 20, 2019 03:03
-
-
Save yudenzel/48765078502926133f974c77ab98469e to your computer and use it in GitHub Desktop.
Load ext4 image and Bash into 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
function load-img () { | |
sudo id; | |
IMAGE_NAME="$1"; | |
IMAGE_FILE="${IMAGE_NAME}.img"; | |
if [[ -f "${IMAGE_FILE}" ]]; then | |
loop_dev=$(sudo losetup --show -f "${IMAGE_FILE}"); | |
echo "loop_dev = ${loop_dev}"; | |
mnt_pnt="mnt_${IMAGE_FILE}_$(basename "${loop_dev}")"; | |
mkdir "${mnt_pnt}" | |
sudo mount "${loop_dev}" "${mnt_pnt}"; | |
cd "${mnt_pnt}" && echo "launching Bash at ${mnt_pnt} ..." && bash -l && cd -; | |
sudo umount "${loop_dev}"; | |
sudo losetup -d "${loop_dev}"; | |
rm -rf "${mnt_pnt}"; | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment