안냐세요..
파티션 테이블이 날아갔을때..
파티션이 있는 실린더를 찾아주는 스크립트입니다.
단지 노가다를 줄여주는것이기 때문에..
디스크에 대한 이해가 있는 분만 이 정보를 이용하시길..
side 0, 1 만 찾습니다. 보통 실린더 단위로 나누기 때문에..
raw disk 를 만지기 때문에 당연히 루트여야 가능하고..
ext2find 디바이스 하면 찾아줍니다..
제 버젼의 fdisk 로 정보 긁어오는걸 만들었기 때문에.. (fdisk v2.9w)
다른데선 어케 돌아갈지 보장은 못하고..
| dd 를 좀 조용하게 만드는 옵션을 찾지 못했기 때문에..
| > result 등으로 파이프로 뽑아내 나중에 보는게.. 더 편할듯 합니다.
찾았습니다..
;
고쳤네요.. 쓰실 분 있으지는 모르지만.. =)
2000.04.05.
ext2find
____________________ cut here ----------------------
#!/bin/sh
# a script that find ext2 partition on raw disk
#
# 2000.04.05 Arcy (arcturus at arcy.org)
PATH=/bin:/sbin:/usr/bin:/usr/sbin
if [ ! $1 ] ; then
echo "Usage : ext2find Devicename"
echo " ex) ext2find hda"
echo " ext2find sdb"
exit 1; fi
device=$1
parm=`fdisk /dev/$device -l |head -2|tail -1`
if [ ! "$parm" ] ; then
echo "Wrong device. Try again"
exit 2; fi
let sector=`echo $parm |cut -d -f 5`
let heads=`echo $parm |cut -d -f 3`
let cylinder=`echo $parm |cut -d -f 7`
let side=$heads
echo "Start search for partition.."
let current=0; let res=0
while [ $current != $cylinder ] ; do
let find=$sector*$current*$side+2
for cside in 0 1 ; do
let find+=$cside*$sector
output=`dd if=/dev/$device skip=$find count=1 2> /dev/null |hexdump -v
|head -5
|tail -1 |cut -d -f 4-6`
if [ "$output" = "4e00 00ed 0000" ] ; then
let it=$current+1
echo "I got it, it's cylinder $it on side $cside"
let res+=1
fi
done
let current+=1
done
echo "Search finished.. $res partition(s) found."
------------------- end -------------------