Rob van der Woude's Scripting Pages

FDISK example: ChkFdisk

I have seen many systems that have both OS/2 and some other operating system (usually NT) installed on two primary partitions. Usually BootManager is used to choose between the operating systems at bootup.

Problems may arise when a second OS/2 is used, for example a maintenance partition with a bare minimal installation of OS/2, or a RIPL server, or just a second full OS/2 on an extended partition.
Especially RIPL systems, that load the operating system from a remote RIPL server, usually store the swap file and temporary files on the local harddisk, on the C: partition. If that C: partition is NTFS (when NT was the previosly booted operating system), OS/2 cannot read from or write to C: and will store the swap file and temporary files on the RIPL server itself. Obviously, this will slow down the system.

The following batch file corrects this problem by checking which partition is active at bootup, and toggling the active partition if necessary.

There is one limitation: it checks for the name that is specified in BootManager for each partition. To use this batch file those names have to match the names used in this batch file exactly.
In this case the HPFS partition is called OS/2 and the NTFS partition is called NT.

@ECHO OFF
REM ChkFdisk.cmd,  Version 2.00
REM Written by Rob van der Woude
REM Checks if OS/2 partition is active on bootup, and makes it active
REM and reboots if not. Also deletes "illegal" swap file on RPL server
REM or extended partition

REM For RPL servers or OS/2 on extended partitions only: specify full
REM path and name of swap file on RPL server or extended partition
SET SWAPFILE=Z:\OS2\SYSTEM\SWAPPER.DAT
REM Otherwise:
REM SET SWAPFILE=

REM Check if OS/2 partition is active (C:)
FDISK /QUERY | FIND "C:" | FIND "OS/2" > NUL
REM If not, set it active
IF ERRORLEVEL 1 GOTO ChgAccess
REM If active, remove swap file from RPL server if necessary
IF NOT "%SWAPFILE%"=="" IF EXIST %SWAPFILE% DEL %SWAPFILE%
GOTO End

:ChgAccess
REM Toggle active partition
FDISK /SETACCESS
REM Check if it succeeded
FDISK /QUERY | FIND "C:" | FIND "OS/2" > NUL
REM If not, display error message
IF ERRORLEVEL 1 GOTO Error
REM Reboot if successfull
SETBOOT /IBD:C:
GOTO End

:Error
REM Error message
ECHO <BELL>Error changing accessible partion:
FDISK /QUERY
PAUSE

:End

 

Note: Note the <BELL> character in the error message. It is the ASCII character 7 ("BELL") which results in a beep when displayed in an MS-DOS or OS/2 command window.

 

Click to view sourceClick to download source
 

page last uploaded: 2015-08-24, 21:06