Skip to content

Instantly share code, notes, and snippets.

@dakhnod
Created October 10, 2024 14:06
Show Gist options
  • Select an option

  • Save dakhnod/11f34b9fd033e6688b312881ce6103f9 to your computer and use it in GitHub Desktop.

Select an option

Save dakhnod/11f34b9fd033e6688b312881ce6103f9 to your computer and use it in GitHub Desktop.
Utility to mount a partition from a disk image
#!/bin/bash
if [[ ! "$1" || ! "$2" || ! "$3" ]]; then
echo "Usage: mount_file IMAGE PARTITION_NUMBER MOUNTPOINT"
exit 1
fi
line=(`fdisk -l "$1" | tr -d '*' | grep "$1$2"`)
mount -o loop,offset=$((512 * ${line[1]})),sizelimit=$((512 * ${line[3]})) $1 $3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment