pilpil-img-tool/mount_img.sh

26 lines
603 B
Bash
Executable File

#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
cd "$(dirname "$0")"
if [[ -z "${1-}" ]] || [[ ! -e "${1}" ]]; then
echo "No file provided or file not found."
exit
fi
if [[ ! -d ./rootfs ]];then
echo "Creating missing mount point directory."
mkdir ./rootfs
fi
LOOP_DEV="$(sudo losetup -f -P --show "$1")"
sudo mount "$LOOP_DEV"p2 -o rw ./rootfs/
sudo mount "$LOOP_DEV"p1 ./rootfs/boot/
sudo mount --bind /sys ./rootfs/sys/
sudo mount --bind /dev ./rootfs/dev/
sudo mount --bind /dev/pts ./rootfs/dev/pts
sudo mount --bind /proc ./rootfs/proc/
echo "${LOOP_DEV}"