; perform DFSDISK analysis on disk $1, selection in $2, geo in $3 $4 $5, superblock-FS in $6 and base filename in $7
; ~ param1 = [disk]~ param2 = [ALL | CYL]~ param3 = [cyl]~ param4 = [head]~ param5 = [sector]~ param6 = [filesystem]~ param7 = [basename]~~Do NOT run this script directly, instead use the menu and dialog:~~         Actions -> DFSDISK,  find  Partitions~
;
;;defaultparam 1 1
;;defaultparam 2 cylinders
;;defaultparam 3 .
;;defaultparam 4 .
;;defaultparam 5 .
;;defaultparam 6 FDISK
;;defaultparam 7 dfsdiski
;;prompt 1
;
screen on
say
say Making a partition-info backup for disk $1 ... using basename: $7
screen off
say
say The resulting .PD$1 file can be used at a later time to restore all partition
say tables, bootsector and LVM-sectors to the same disk or another (virtual) one.
;
fdisk psave $1 '$7' DFSDISK ANALYSIS; save binary copies of relevant sectors
;say
;say Save partition info for ALL disks in an XML formatted file
;part -xml -file:'$7.xm$1'
say
say Show all driveletters known by the currently running operating system,
say and show the freespace on each when the filesystem is known and OK.
vol -f-   ;show volumes for booted operating system
say
say Show a table with all partitions and freespace that are CURRENTLY defined
say in the partitiontables on all disks accessible to DFSee.
fdisk -m  ;fdisk mode plus default table display, geo/mbr/int13
say
say Repeat table of partitions and freespace with all numeric information
say on partition begin and end sectors, sizes and starting cylinder.
say Separate lines are included here for every extended partition container.
say Also, ALL warnings even very minor ones will be displayed here.
part -e -n -w      ;number centric table display and ALL warnings
part -s            ;include decimal values, comma-separated table

set pedantic on
disk -r $1         ;re-select disk, include ALL int13 details available
set pedantic off
;
screen on
say
say "Partition search using 'bsfind $1 $2', geo $3 $4 $5" and $6 superblocks
say "Do NOT press the <Esc> key, except to abort!  Please wait ..."
screen off
say
say Results in a list of partition-table sectors, bootsectors and LVM-sectors
say for the CURRENT but also for any OLD/DELETED/DAMAGED partitions.
say It should be used to determine what the CORRECT partitions are, and
say what commands are needed to recover them (NEWMBR/DELETE/CREATE/FIX...)
;
geo $3 $4 $5       ;set and/or display geometry
fs  -Q $6          ;set filesystem for superblock search, no warnings to screen
bsfind * $2        ;find partitioning sectors plus optional superblocks
;
screen on
say
say Exporting search results and finish analysis report for disk $1
screen off
say The saved list can be used later for further analysis, by importing it to
say the same or another (virtual) disk, including the actual sector data (-d)
;
export '$7.sn$1' -d ;export results to file, including data
say
say BSFIND results listed in detailed mode, allowing for better identification
say of the partitions (labels, type etc) and other info needed for recovery
list -b          ;list them in detailed bootsector mode
say
say Show the current partition-table sectors for this disk
walk $1 -v       ;walk the MBR/EBR chain showing all tables
say
say Show detailed partition list including superblocks and ALLOCation information
part -d -V -a    ;show part details plus ALLOC, this disk only
say
say Show several 'most used' sectors using their well-known positions
disk $1          ;Re-select whole disk and display the MBR
H 0              ;MBR itself, full sector HEX
H 1              ;LDM privhead structure for W2k/XP LDM disks
0x3e             ;LBA LVM info sector DLAT primaries
0x3f             ;LBA Bootsector of 1st if primary
0x42             ;LBA BMP-sector of 1st if this is IBM BootManager
0x45             ;LBA Spare-boot of 1st if primary FAT32
0x800            ;LBA Bootsector of 1st if primary on GPT
0x3ec1           ;LBA EBR sector of 1st if logical
0x3f00           ;LBA Bootsector of 1st if logical
0x3f06           ;LBA Spare-boot of 1st if logical FAT32
chs 0 0 63       ;CHS LVM info sector DLAT primaries
chs 0 1 1        ;CHS Bootsector of 1st if primary
chs 1 0 1        ;CHS EBR sector of 1st if logical
chs 1 1 1        ;CHS Bootsector of 1st if logical
say
say Show BMGR/SETBOOT configuration and primary data sector
setboot -list -q
bmp
say
say Make sure correct disk ($1) is selected again
disk $1
geo
say
say Show all LVM-related information sectors, if LVM is present on the disk
plist -related lvm $1   ;list of all LVM-information if present
say
say Show any Apple-Partition MAP sectors in a table, and verbose
apmap
apmap -v
say
say Show allocation for the whole disk in 20 lines
alloc -l:20
say
say Running another BSFIND on only the start of the disk, but searching in ALL
say sectors to have at least some important info if the geometry is wrong.
base  0 10000    ;limit to first 32Mb of disk
bsfind  *  all   ;and search ALL sectors
list -b          ;list them in detailed bootsector mode
say
say List all partition and LVM (related) information for the disk
pt * -d -related
say
say Make sure correct disk ($1) is selected again
disk $1
say
say Dump start of disk to compressed image for detailed analysis when needed
image -B -q '$7.mb$1' 0 1        ;MBR alone
image -B -q '$7.im$1' 1 800 -z   ;LDR area and more
screen on
