Skip to content

Instantly share code, notes, and snippets.

@wavezhang
Last active February 4, 2022 08:20
Show Gist options
  • Save wavezhang/d5724f46e2734c1d054380d6bb071783 to your computer and use it in GitHub Desktop.
Save wavezhang/d5724f46e2734c1d054380d6bb071783 to your computer and use it in GitHub Desktop.
#!/bin/bash
file=$1
part=$2
dest=$3
if [[ -z $part || -z $file || -z $dest ]];then
echo "usage $0 file part dest"
exit 1
fi
mkdir -p $dest
npart=$(fdisk -l $file | grep "^$file" | sed 's/*//g' | wc -l)
t=$(( $npart - $part + 1))
sector=$(fdisk -l $file | grep "^$file" | sed 's/*//g' | awk '{print $2}' | tail -$t | head -1)
offset=$(( $sector * 512 ))
mount -o loop,offset=$offset $file $dest
@HIFun-cws
Copy link

???

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment