Last active
October 21, 2025 11:22
-
-
Save wavezhang/d5724f46e2734c1d054380d6bb071783 to your computer and use it in GitHub Desktop.
Revisions
-
wavezhang revised this gist
Mar 26, 2020 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -3,11 +3,12 @@ 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) -
wavezhang created this gist
Mar 26, 2020 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ #!/bin/bash file=$1 part=$2 dest=$3 mkdir -p $dest if [ -z $part || -z $file || -z $dest ];then echo "usage $0 file part dest" exit 1 fi 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