# pmdmp - [agnostic] partition map dump



## telemark (Nov 12, 2013)

I wrote this for myself but felt others might need this as well. The goal was to read as many formats as possible, prevent human error, and getting something working asap so we can get to the more interesting stuff.

Hypothetically can handle:
Roamio or Premiere
32bit or 64bit fields
Little or Big Endian
Device or Files or Pipes
MBR skip over
YMMV

Copyright 2014, binary license granted for personal, non-commercial use. Commercial use or redistribution, please request a license.


----------



## telemark (Nov 12, 2013)

Version beta2:
Linux 64bit static linked
Mac OS X 32bit

MD5 (linux/pmdmp) = babafe85b3e5d2a28e4e9b7ffdbd00f7
MD5 (mac/pmdmp) = 541afaa07d0105875b52de64323ea36b


```
Usage examples:
  > pmdmp ~/HD.backup
  > zcat sdb1.gz | pmdmp
  Linux> pmdmp /dev/sdb
  Mac> pmdmp /dev/rdisk1

  1 (0200) : MP : Apple_partition_map :                       Apple :         63 @          1
  2 (0400) : MP :               Image :                 Bootstrap 1 :          8 @  537225104
  3 (0600) : MP :               Image :                    Kernel 1 :          8 @  537225112
  4 (0800) : MP :                Ext2 :                      Root 1 :          8 @  537225120
  5 (0A00) : MP :               Image :                 Bootstrap 2 :          8 @  537225128
  6 (0C00) : MP :               Image :                    Kernel 2 :          8 @  537225136
  7 (0E00) : MP :                Ext2 :                      Root 2 :          8 @  537225144
  8 (1000) : MP :                Swap :                  Linux swap :    1048576 @  537225152
  9 (1200) : MP :                Ext2 :                        /var :    1572864 @  538273728
 10 (1400) : MP :                 MFS :      MFS application region :    1638400 @  546138048
 11 (1600) : MP :                 MFS :            MFS media region :  427358320 @  549414848
 12 (1800) : MP :                 MFS :    MFS application region 2 :    1638400 @  547776448
 13 (1A00) : MP :                 MFS :          MFS media region 2 :  537225040 @         64
 14 (1C00) : MP :                Ext2 :                      SQLite :    6291456 @  539846592

  1 (0200) : MP : Apple_partition_map :                       Apple :          1 +         63 =         64
 13 (1A00) : MP :                 MFS :          MFS media region 2 :         64 +  537225040 =  537225104
  2 (0400) : MP :               Image :                 Bootstrap 1 :  537225104 +          8 =  537225112
  3 (0600) : MP :               Image :                    Kernel 1 :  537225112 +          8 =  537225120
  4 (0800) : MP :                Ext2 :                      Root 1 :  537225120 +          8 =  537225128
  5 (0A00) : MP :               Image :                 Bootstrap 2 :  537225128 +          8 =  537225136
  6 (0C00) : MP :               Image :                    Kernel 2 :  537225136 +          8 =  537225144
  7 (0E00) : MP :                Ext2 :                      Root 2 :  537225144 +          8 =  537225152
  8 (1000) : MP :                Swap :                  Linux swap :  537225152 +    1048576 =  538273728
  9 (1200) : MP :                Ext2 :                        /var :  538273728 +    1572864 =  539846592
 14 (1C00) : MP :                Ext2 :                      SQLite :  539846592 +    6291456 =  546138048
 10 (1400) : MP :                 MFS :      MFS application region :  546138048 +    1638400 =  547776448
 12 (1800) : MP :                 MFS :    MFS application region 2 :  547776448 +    1638400 =  549414848
 11 (1600) : MP :                 MFS :            MFS media region :  549414848 +  427358320 =  976773168
```
Output notes:
PM or MP or NP is the literal field contents but tells you whether it's in 32/64 or LSB/MSB format.

There is a sanity procedure which checks if partitions are adjacent, if you're seeing exclamation marks (!) then there was discontinuity detected. If you're seeing this it's probably a math bug in this program, please report it so it can be fixed.

Change log:
2014-05-10: beta2 - Added code for hypothetical 'PN' (64bit Premiere). None were found on stock drives. Unknown if in wild. Remains untested as such.
2014-05-10: beta1 - Initial public release.


----------



## telemark (Nov 12, 2013)

Version beta3:
Linux 64bit static linked

Change log:
2015-05-06: beta3
Additional output format, which generates arguments for losetup. 
(so that partition devices can be created)


```
> ./pmdmp-static /dev/sdX
Output:
losetup -f /dev/sdX --sizelimit 512
losetup -f /dev/sdX --offset 512 --sizelimit 32256 	# 1 Apple
losetup -f /dev/sdX --offset 176040132608 --sizelimit 512 	# 2 Bootstrap 1
losetup -f /dev/sdX --offset 176040133120 --sizelimit 8388608 	# 3 Kernel 1
losetup -f /dev/sdX --offset 176048521728 --sizelimit 268435456 	# 4 Root 1
losetup -f /dev/sdX --offset 176316957184 --sizelimit 512 	# 5 Bootstrap 2
losetup -f /dev/sdX --offset 176316957696 --sizelimit 8388608 	# 6 Kernel 2
losetup -f /dev/sdX --offset 176325346304 --sizelimit 268435456 	# 7 Root 2
losetup -f /dev/sdX --offset 176593781760 --sizelimit 134217728 	# 8 Linux swap
losetup -f /dev/sdX --offset 176727999488 --sizelimit 536870912 	# 9 /var
losetup -f /dev/sdX --offset 180486095872 --sizelimit 838860800 	# 10 MFS application region
losetup -f /dev/sdX --offset 182163817472 --sizelimit 137909115904 	# 11 MFS media region
losetup -f /dev/sdX --offset 181324956672 --sizelimit 838860800 	# 12 MFS application region 2
losetup -f /dev/sdX --offset 32768 --sizelimit 176040099840 	# 13 MFS media region 2
losetup -f /dev/sdX --offset 177264870400 --sizelimit 3221225472 	# 14 SQLite
```


----------



## vibo (Jun 28, 2003)

Thanks for the pmdmp/pmdmp-static is helped me make sense of the Tivo drive when in my Linux box.

I see that only the root1, root2 and var are file systems:
/dev/loop4 on /mnt/root1 type ext2 (rw,relatime,block_validity,barrier,user_xattr,acl) 
/dev/loop7 on /mnt/root2 type ext2 (rw,relatime,block_validity,barrier,user_xattr,acl)
/dev/loop9 on /mnt/var type ext2 (rw,relatime,block_validity,barrier,user_xattr,acl)

Looks like root2 is a duplicate (backup?) of root1 and /var is various runtime data rather than linux support stuff in the roots. The kernel1 and kernel2 (on my system) are slightly different one is probably the previous/backup version. The bootstrap1/2 are empty (512 bytes of 0) 

I guess my next step is to put telnetd etc into the root directories and switch the disk into the tivo (series 3 with modded rom)


----------

