Last active
February 4, 2022 08:20
-
-
Save wavezhang/d5724f46e2734c1d054380d6bb071783 to your computer and use it in GitHub Desktop.
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 | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
???