Skip to content

Commit

Permalink
add /NOIPL argument to prevent writing IPL on MBR initialization
Browse files Browse the repository at this point in the history
IPL area is filled with zero instead. Some BIOSes contain heuristics
which allow them to skip the device upon boot if they detect the
first bytes of the IPL being zero.

FreeDOS 1.3 installation under VMware accidentally works because of
this, because FDISK 1.3 fails to write proper boot code when
initializing the MBR.

The INT 18 method introduced to the boot code via 301ba27 should render
this obsolete.
  • Loading branch information
boeckmann committed Jan 18, 2025
1 parent 301ba27 commit 538f218
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
7 changes: 7 additions & 0 deletions source/fdisk/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,13 @@ int main( int argc, char *argv[] )
command_ok = TRUE;
}

if ( 0 == strcmp( arg[0].choice, "NOIPL" ) ) {
/* prevent writing IPL upon MBR initialisation */
flags.no_ipl = TRUE;
Shift_Command_Line_Options( 1 );
command_ok = TRUE;
}

if ( 0 == strcmp( arg[0].choice, "PRI" ) ) {
flags.use_iui = FALSE;
Command_Line_Create_Primary_Partition();
Expand Down
1 change: 1 addition & 0 deletions source/fdisk/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ typedef struct flags_structure {
int monochrome;
int maximum_drive_number;
int more_than_one_drive;
int no_ipl;
int partitions_have_changed;
int partition_type_lookup_table;
int reboot;
Expand Down
3 changes: 2 additions & 1 deletion source/fdisk/pdiskio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1330,7 +1330,8 @@ int Write_Partition_Tables( void )
goto drive_error;
}

if ( *(unsigned short *)( sector_buffer + 510 ) != 0xAA55 ) {
if ( ( *(unsigned short *)( sector_buffer + 510 ) != 0xAA55 ) &&
( flags.no_ipl != TRUE ) ) {
/* install MBR code if we install a new MBR */
memcpy( sector_buffer, bootnormal_code, SIZE_OF_IPL );
}
Expand Down

0 comments on commit 538f218

Please sign in to comment.