This commit is contained in:
brent s 2019-11-05 07:07:16 -05:00
parent 37124f066a
commit 33ea96d1e1
3 changed files with 82 additions and 76 deletions

View File

@ -117,6 +117,8 @@
<!-- These deviate from the parted flags (and in the case of the gpt_* ones, have no parted <!-- These deviate from the parted flags (and in the case of the gpt_* ones, have no parted
equivalent it seems). equivalent it seems).
fdisk's "e(x)pert mode" has numerical GUID identifers for these ("Attrs"). fdisk's "e(x)pert mode" has numerical GUID identifers for these ("Attrs").
Details on these are at:
https://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_entries_(LBA_2%E2%80%9333)


BD_PART_FLAGS = BlockDev.PartFlag(-1) BD_PART_FLAGS = BlockDev.PartFlag(-1)
BD_PART_FLAGS_FRIENDLY = dict(zip(BD_PART_FLAGS.value_nicks, BD_PART_FLAGS.value_names)) BD_PART_FLAGS_FRIENDLY = dict(zip(BD_PART_FLAGS.value_nicks, BD_PART_FLAGS.value_names))
@ -125,9 +127,10 @@
<xs:restriction base="xs:string"> <xs:restriction base="xs:string">
<xs:enumeration value="apple_tv_recovery"/> <xs:enumeration value="apple_tv_recovery"/>
<xs:enumeration value="cpalo"/> <xs:enumeration value="cpalo"/>
<xs:enumeration value="gpt_hidden"/> <xs:enumeration value="gpt_hidden"/><!-- No parted equivalent -->
<xs:enumeration value="gpt_no_automount"/> <xs:enumeration value="gpt_no_automount"/><!-- No parted equivalent -->
<xs:enumeration value="gpt_read_only"/> <xs:enumeration value="gpt_read_only"/><!-- No parted equivalent -->
<xs:enumeration value="gpt_system_part"/><!-- No parted equivalent -->
<xs:enumeration value="hpservice"/> <xs:enumeration value="hpservice"/>
<xs:enumeration value="msft_data"/> <xs:enumeration value="msft_data"/>
<xs:enumeration value="msft_reserved"/> <xs:enumeration value="msft_reserved"/>

View File

@ -23,6 +23,7 @@ PARTED_FLAGS = sorted(list(parted.partition.partitionFlag.values()))
PARTED_IDX_FLAG = dict(parted.partition.partitionFlag) PARTED_IDX_FLAG = dict(parted.partition.partitionFlag)
PARTED_FLAG_IDX = {v: k for k, v in PARTED_IDX_FLAG.items()} PARTED_FLAG_IDX = {v: k for k, v in PARTED_IDX_FLAG.items()}
# LIBBLOCKDEV BOOTSTRAPPING (ALLOWED VALUES IN CONFIG) # LIBBLOCKDEV BOOTSTRAPPING (ALLOWED VALUES IN CONFIG)
# https://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_entries_(LBA_2%E2%80%9333)
BD_PARTED_MAP = {'apple_tv_recovery': 'atvrecv', BD_PARTED_MAP = {'apple_tv_recovery': 'atvrecv',
'cpalo': 'palo', 'cpalo': 'palo',
'gpt_hidden': None, # No parted equivalent 'gpt_hidden': None, # No parted equivalent
@ -136,12 +137,12 @@ MSDOS_FSTYPE_IDS = ((1, 'Empty', b'\x00'),
(7, 'FAT16', b'\x06'), (7, 'FAT16', b'\x06'),
(8, 'HPFS/NTFS/exFAT', b'\x07'), (8, 'HPFS/NTFS/exFAT', b'\x07'),
(9, 'AIX', b'\x08'), (9, 'AIX', b'\x08'),
(10, 'AIX bootable', b'\t'), (10, 'AIX bootable', b'\t'), # \x09
(11, 'OS/2 Boot Manager', b'\n'), (11, 'OS/2 Boot Manager', b'\n'), # \x0A
(12, 'W95 FAT32', b'\x0b'), (12, 'W95 FAT32', b'\x0B'),
(13, 'W95 FAT32 (LBA)', b'\x0c'), (13, 'W95 FAT32 (LBA)', b'\x0C'),
(14, 'W95 FAT16 (LBA)', b'\x0e'), (14, 'W95 FAT16 (LBA)', b'\x0E'),
(15, "W95 Ext'd (LBA)", b'\x0f'), (15, "W95 Ext'd (LBA)", b'\x0F'),
(16, 'OPUS', b'\x10'), (16, 'OPUS', b'\x10'),
(17, 'Hidden FAT12', b'\x11'), (17, 'Hidden FAT12', b'\x11'),
(18, 'Compaq diagnostics', b'\x12'), (18, 'Compaq diagnostics', b'\x12'),
@ -149,33 +150,33 @@ MSDOS_FSTYPE_IDS = ((1, 'Empty', b'\x00'),
(20, 'Hidden FAT16', b'\x16'), (20, 'Hidden FAT16', b'\x16'),
(21, 'Hidden HPFS/NTFS', b'\x17'), (21, 'Hidden HPFS/NTFS', b'\x17'),
(22, 'AST SmartSleep', b'\x18'), (22, 'AST SmartSleep', b'\x18'),
(23, 'Hidden W95 FAT32', b'\x1b'), (23, 'Hidden W95 FAT32', b'\x1B'),
(24, 'Hidden W95 FAT32 (LBA)', b'\x1c'), (24, 'Hidden W95 FAT32 (LBA)', b'\x1C'),
(25, 'Hidden W95 FAT16 (LBA)', b'\x1e'), (25, 'Hidden W95 FAT16 (LBA)', b'\x1E'),
(26, 'NEC DOS', b'$'), (26, 'NEC DOS', b'$'), # \x24
(27, 'Hidden NTFS WinRE', b"'"), (27, 'Hidden NTFS WinRE', b"'"), # \x27
(28, 'Plan 9', b'9'), (28, 'Plan 9', b'9'), # \x39
(29, 'PartitionMagic recovery', b'<'), (29, 'PartitionMagic recovery', b'<'), # \x3C
(30, 'Venix 80286', b'@'), (30, 'Venix 80286', b'@'), # \x40
(31, 'PPC PReP Boot', b'A'), (31, 'PPC PReP Boot', b'A'), # \x41
(32, 'SFS', b'B'), (32, 'SFS', b'B'), # \x42
(33, 'QNX4.x', b'M'), (33, 'QNX4.x', b'M'), # \x4D
(34, 'QNX4.x 2nd part', b'N'), (34, 'QNX4.x 2nd part', b'N'), # \x4E
(35, 'QNX4.x 3rd part', b'O'), (35, 'QNX4.x 3rd part', b'O'), # \x4F
(36, 'OnTrack DM', b'P'), (36, 'OnTrack DM', b'P'), # \x50
(37, 'OnTrack DM6 Aux1', b'Q'), (37, 'OnTrack DM6 Aux1', b'Q'), # \x51
(38, 'CP/M', b'R'), (38, 'CP/M', b'R'), # \x52
(39, 'OnTrack DM6 Aux3', b'S'), (39, 'OnTrack DM6 Aux3', b'S'), # \x53
(40, 'OnTrackDM6', b'T'), (40, 'OnTrackDM6', b'T'), # \x54
(41, 'EZ-Drive', b'U'), (41, 'EZ-Drive', b'U'), # \x55
(42, 'Golden Bow', b'V'), (42, 'Golden Bow', b'V'), # \x56
(43, 'Priam Edisk', b'\\'), (43, 'Priam Edisk', b'\\'), # \x5C
(44, 'SpeedStor', b'a'), (44, 'SpeedStor', b'a'), # \x61
(45, 'GNU HURD or SysV', b'c'), (45, 'GNU HURD or SysV', b'c'), # \x63
(46, 'Novell Netware 286', b'd'), (46, 'Novell Netware 286', b'd'), # \x64
(47, 'Novell Netware 386', b'e'), (47, 'Novell Netware 386', b'e'), # \x65
(48, 'DiskSecure Multi-Boot', b'p'), (48, 'DiskSecure Multi-Boot', b'p'), # \x70
(49, 'PC/IX', b'u'), (49, 'PC/IX', b'u'), # \x75
(50, 'Old Minix', b'\x80'), (50, 'Old Minix', b'\x80'),
(51, 'Minix / old Linux', b'\x81'), (51, 'Minix / old Linux', b'\x81'),
(52, 'Linux swap / Solaris', b'\x82'), (52, 'Linux swap / Solaris', b'\x82'),
@ -185,45 +186,45 @@ MSDOS_FSTYPE_IDS = ((1, 'Empty', b'\x00'),
(56, 'NTFS volume set', b'\x86'), (56, 'NTFS volume set', b'\x86'),
(57, 'NTFS volume set', b'\x87'), (57, 'NTFS volume set', b'\x87'),
(58, 'Linux plaintext', b'\x88'), (58, 'Linux plaintext', b'\x88'),
(59, 'Linux LVM', b'\x8e'), (59, 'Linux LVM', b'\x8E'),
(60, 'Amoeba', b'\x93'), (60, 'Amoeba', b'\x93'),
(61, 'Amoeba BBT', b'\x94'), (61, 'Amoeba BBT', b'\x94'),
(62, 'BSD/OS', b'\x9f'), (62, 'BSD/OS', b'\x9F'),
(63, 'IBM Thinkpad hibernation', b'\xa0'), (63, 'IBM Thinkpad hibernation', b'\xA0'),
(64, 'FreeBSD', b'\xa5'), (64, 'FreeBSD', b'\xA5'),
(65, 'OpenBSD', b'\xa6'), (65, 'OpenBSD', b'\xA6'),
(66, 'NeXTSTEP', b'\xa7'), (66, 'NeXTSTEP', b'\xA7'),
(67, 'Darwin UFS', b'\xa8'), (67, 'Darwin UFS', b'\xA8'),
(68, 'NetBSD', b'\xa9'), (68, 'NetBSD', b'\xA9'),
(69, 'Darwin boot', b'\xab'), (69, 'Darwin boot', b'\xAB'),
(70, 'HFS / HFS+', b'\xaf'), (70, 'HFS / HFS+', b'\xAF'),
(71, 'BSDI fs', b'\xb7'), (71, 'BSDI fs', b'\xB7'),
(72, 'BSDI swap', b'\xb8'), (72, 'BSDI swap', b'\xB8'),
(73, 'Boot Wizard hidden', b'\xbb'), (73, 'Boot Wizard hidden', b'\xBB'),
(74, 'Acronis FAT32 LBA', b'\xbc'), (74, 'Acronis FAT32 LBA', b'\xBC'),
(75, 'Solaris boot', b'\xbe'), (75, 'Solaris boot', b'\xBE'),
(76, 'Solaris', b'\xbf'), (76, 'Solaris', b'\xBF'),
(77, 'DRDOS/sec (FAT-12)', b'\xc1'), (77, 'DRDOS/sec (FAT-12)', b'\xC1'),
(78, 'DRDOS/sec (FAT-16 < 32M)', b'\xc4'), (78, 'DRDOS/sec (FAT-16 < 32M)', b'\xC4'),
(79, 'DRDOS/sec (FAT-16)', b'\xc6'), (79, 'DRDOS/sec (FAT-16)', b'\xC6'),
(80, 'Syrinx', b'\xc7'), (80, 'Syrinx', b'\xC7'),
(81, 'Non-FS data', b'\xda'), (81, 'Non-FS data', b'\xDA'),
(82, 'CP/M / CTOS / ...', b'\xdb'), (82, 'CP/M / CTOS / ...', b'\xDB'),
(83, 'Dell Utility', b'\xde'), (83, 'Dell Utility', b'\xDE'),
(84, 'BootIt', b'\xdf'), (84, 'BootIt', b'\xDF'),
(85, 'DOS access', b'\xe1'), (85, 'DOS access', b'\xE1'),
(86, 'DOS R/O', b'\xe3'), (86, 'DOS R/O', b'\xE3'),
(87, 'SpeedStor', b'\xe4'), (87, 'SpeedStor', b'\xE4'),
(88, 'Rufus alignment', b'\xea'), (88, 'Rufus alignment', b'\xEA'),
(89, 'BeOS fs', b'\xeb'), (89, 'BeOS fs', b'\xEB'),
(90, 'GPT', b'\xee'), (90, 'GPT', b'\xEE'),
(91, 'EFI (FAT-12/16/32)', b'\xef'), (91, 'EFI (FAT-12/16/32)', b'\xEF'),
(92, 'Linux/PA-RISC boot', b'\xf0'), (92, 'Linux/PA-RISC boot', b'\xF0'),
(93, 'SpeedStor', b'\xf1'), (93, 'SpeedStor', b'\xF1'),
(94, 'SpeedStor', b'\xf4'), (94, 'SpeedStor', b'\xF4'),
(95, 'DOS secondary', b'\xf2'), (95, 'DOS secondary', b'\xF2'),
(96, 'VMware VMFS', b'\xfb'), (96, 'VMware VMFS', b'\xFB'),
(97, 'VMware VMKCORE', b'\xfc'), (97, 'VMware VMKCORE', b'\xFC'),
(98, 'Linux raid autodetect', b'\xfd'), (98, 'Linux raid autodetect', b'\xFD'),
(99, 'LANstep', b'\xfe'), (99, 'LANstep', b'\xFE'),
(100, 'BBT', b'\xff')) (100, 'BBT', b'\xFF'))

View File

@ -19,6 +19,8 @@ import aif.constants
import aif.utils import aif.utils


# TODO: https://serverfault.com/questions/356534/ssd-erase-block-size-lvm-pv-on-raw-device-alignment # TODO: https://serverfault.com/questions/356534/ssd-erase-block-size-lvm-pv-on-raw-device-alignment
# TODO: caveats? https://gist.github.com/leodutra/8779d468e9062058a3e90008295d3ca6
# https://unix.stackexchange.com/questions/325886/bios-gpt-do-we-need-a-boot-flag




class Partition(object): class Partition(object):