Diskman is a suite of advanced programs designed to perform a variety of low level hard disk releated tasks not normally possible. Diskman is free for non-commerical use. Full script language, backup and restore Long File Names (LFN), archive compatible with DOSLFNBK, delete, create and manipulate disk partitions, quickly format FAT volumes, securely erase either volumes or entire drives, mount and manipulate disk images (such as those created for Rawrite), export volumes or entire physical drives for later restore, quickly copy every file into image files for easy backup and later restore, browse FAT volumes quickly and easily, directly edit disks at the sector level, support for all BIOS supported disks, DOS supported drives and Image files, help repair disks after a virus attack or rescue critical data, backup and restore CMOS memory images, including latest 256 byte chipsets.
 
Search Diskman Forum
 Diskman > Diskman 4 Examples Tuesday 6th February 2007 

Diskman 4 Examples

See also

Diskman 4 News

Diskman 4 Command Reference

Diskman 4 Manual

Display the partition table on the second hard disk from the command line:

DISKMAN DEF SRCDRV DRIVE MOUNT BIOS 0x81;PART DISPLAY $SRCDRV

Quickly wipe the primary hard disk from the command line:

DISKMAN DEF SRCDRV DRIVE MOUNT BIOS 0x81;DRIVE WIPE ALL $SRCDRV

Partition the first hard disk from the command line:

DISKMAN DEF SRCDRV MOUNT BIOS 0x80
VOLUME CREATE PRIMARY $SRCDRV $MAX $FAT32

Start a Console session and enter commands:

A console session may be useful where a number of linked commands are required and it is inconvenient to repeatedly call the Diskman executable. Consoles can also be used where the command line would be too long (DOS is limited to around 128 characters) or an interactive session is required where decisions are to be made along the way.

To start a Console session use the DISKMAN CONSOLE command from the DOS prompt.

Diskman commands now be entered individually (followed by enter) or multiple commands together separated by semicolons. To end the Console session use the EXIT command.

Quickly copy all files and directories (including all hidden and system) using MS-DOS

Diskman includes a 'super XCOPY' function that will copy all files and folders (including hidden and system) from one path to another. This is designed to be used in conjunction with either DOSLFNBK or the Diskman LFNBK range of commands. DOS file copies are limited to the standard 8.3 filename convention and therefore ignore Long File Names. However, coupled with LFN backup/restore and a boot sector merge this can be used to provide a primitive full system backup/restore ability. This method was historically very popular (in previous versions of DM) but is now considered outdated because of the new range of commands such as VOLUME COPY.

#Copy all files from the directory Z:\IMAGE to the C:\ path
DOS BUILD Z:\IMAGE C:\

Backup and restore boot sectors from the Console
Explanation of why this is sometimes necessary

As anyone who has every tried to make a DOS bootable floppy in a NT based machine will know NT formatted floppies cannot boot DOS!. This is because each OS has its own boot sector and the NT boot sector is designed to load NTLDR and not IO.SYS. Solving this problem is historically one of the reasons that Diskman was first written. Any program (including Diskman) can be used to format a volume but if that volume is to become bootable it needs an appropriate boot sector. There are two ways of doing this, either use the format program designed for the OS (not possible to use the Windows 98 FORMAT utility in NT!) or use Diskman.

For example, backup the boot sector from a Windows 98 system boot the machine from a clean floppy or to a command-prompt and start a Diskman Console:

#Mount DOS C: and extract boot sector to backup file
DEF DRV DRIVE MOUNT DOS C:
DEF VOL VOLUME FIND FIRST $DRV
BOOTRECORD SAVE $VOL A:\BACKUP.BIN

The Diskman reference materials frequently talk about files such as WIN98.F32 (Windows 98 FAT32 boot record) etc.

To create a Windows 98 bootable floppy first backup the FAT12 boot record found on an example floppy:

#Mount DOS A: and extract boot sector to backup file
DEF DRV DRIVE MOUNT DOS A:
DEF VOL VOLUME FIND FIRST $DRV
BOOTRECORD SAVE $VOL C:\BACKUP.BIN

Then insert a new floppy, format it and merge the boot sector

#Mount DOS A:, format and merge boot record
DEF DRV DRIVE MOUNT DOS A:
DEF VOL VOLUME FIND FIRST $DRV
VOLUME FORMAT $VOL $FAT12
BOOTRECORD MERGE $VOL C:\BACKUP.BIN

Generally the BOOTRECORD MERGE option should be used to add the specified boot record to a preexisting volume. BOOTRECORD LOAD completely replaces all structures and is explained in more detail in the Diskman 4 manual.

How to create a bootable Windows 2000 hard disk

To initialize a blank hard disk for a Windows 2000 installation (via simple file copying) the following script could be used. This assumes that the required bootrecord (FAT32 in this case) and a suitable MBR (capable of booting Windows 2000, so anything Windows 98 or later) have been previously obtained. This script would usually be run from a clean floppy boot.

#Example script to create a Windows 2000 bootable hard disk and 
#install Windows by file copy from a CD
#This example does not explain long file name restore which 
#is also required to produce a fully working system
#LFN restore is covered in a separate example
#Mount first hard disk, create one big partition and load the 
#standard MBR file
DEF DRV DRIVE MOUNT BIOS 0x80
DEF VOL VOLUME CREATE PRIMARY $DRV $FAT32 $MAX
VOLUME ACTIVATE $VOL
MBR MERGE $DRV A:\STDMBR.BIN

#Format partition and load FAT32 bootrecord
VOLUME FORMAT $VOL $FAT32
BOOTRECORD MEGRE $VOL A:\WIN2000.F32

#System must be rebooted here to make volume available 
#to DOS as C:
#Copy Windows 2000 installation from a CD (Z:) and 
#restore long file names
DOS BUILD Z:\ C:\
DOS LFNBK RESTORE C: C:\BACKUP.LFN

Using Diskman to backup long file names

Explanation of why this is sometimes necessary

Windows 95 introduced Long File Names to the world. Previously DOS based systems had been stuck with so-called 8.3 filenames which truncated 'Marketing Report March 2002.DOC' to 'MKRP0302.DOC'. This long overdue change however require that application be LFN aware which in practice meant only Windows programs. Additionally Microsoft didn't include LFN support in the bare DOS kernel (not the extended version available in a Windows box). This meant that most DOS programs were left without LFN support. It is therefore impossible to copy a Windows installation using just the plain DOS XCOPY command without an additional program to handle the long file names.

NB: A word about how LFNs work would be helpful here. To maintain compatibility with older DOS versions Microsoft used a trick to store LFNs on disk. This trick essentially means that to this day each Long File Named file has two file names. The traditional 8.3 name is always present, this is the one used by DOS and older programs. An optional Long Name is also possible but each Long Name is always linked to a short one. It is therefore possible to backup the database of Short->Long Names, copy the short names using any available method and restore the LFN database.

Diskman's LFN database files are fully compatible with the excellent DOSLFNBK by Duncan Murdoch (which is Shareware).

The following command can be used to backup all the long filenames on the DOS C:

DOS LFNBK BACKUP C: C:\BACKUP.LFN

Similarly to restore all the long filenames use the following command

DOS LFNBK RESTORE C: C:\BACKUP.LFN

Quickly copy one DOS volume to another (including Long File Names)

The following DM4 script may be useful to copy a drive quickly:

#Copy drive C: to D: including all attributes and LFNS
DEF DRVSRC DRIVE MOUNT
DOS C: DEF
SRCVOL VOLUME FIND FIRST $DRVSOURCE
DEF DRVDEST DRIVE MOUNT
DOS D: DEF
DESTVOL VOLUME FIND FIRST $DRVDEST
VOLUME COPY $SRCVOL $DESTVOL

Using Diskman to do a primitive system backup/restore

By combining Diskman's fast XCOPY functionality with LFN backup/restore it is possible to make a primitive system backup/restore system that supports LFNS.

#Backup long filenames to LFN database and the copy all files
DOS LFNBK BACKUP C: C:\BACKUP.LFN
DOS BUILD C:\ Z:\

#Restore previous backup and long filenames
DOS BUILD Z:\ C:\
DOS LFNBK RESTORE C: C:\BACKUP.LFN

Quickly backup all files and folders (including long filenames)

The previous example used DOS based methods to backup and then restore a system volume. The following method avoids the separate steps to backup/restore files and then backup/restore LFNS and a suitable boot record. In this example all operations are merged into one.

#Create a 2GB image file and mount it as a RAWP 
#(partitioned)drive
DOS CREATE Z:\IMAGE.BIN
DEF DESTDRV DRIVE MOUNT RAWP Z:\IMAGE.BIN

#Create a big partition inside the image and format it
DEF DESTVOL VOLUME CREATE PRIMARY $DESTDRV $MAX $FAT32
VOLUME FORMAT $DESTVOL

#Mount the first hard disk, find the one and only volume on it, 
#copy the MBR, boot record and lastly all the files into the image
DEF SRCDRV DRIVE MOUNT BIOS 0x80
MBR CMERGE $SRCDRIVE $DESTDRV
DEF SRCVOL VOLUME FIND FIRST $SRCDRV
BOOTRECORD COPY $SRCVOL $DESTVOL
VOLUME COPY $SRCVOL $DESTVOL

This process can be reversed to perform a restore operation.

Script to backup critical disk structures (MBR+Partition table and all recognized boot sectors)

#Mount the first hard disk and make current
DEF DRV DRIVE MOUNT BIOS 0x80

#Save the MBR (and partition tables) to a floppy
MBR SAVE $SRCDRV A:\MBR.BIN

#Loop through all the volumes on the drive saving 
#their boot records
DEF SRCVOL VOLUME FIND FIRST $SRCDRV
IF $SRCVOL EQUALS 0 GOTO END
:LOOP
BOOTRECORD SAVE $SRCVOL A:\BOOTREC.$VOL$
DEF SRCVOL VOLUME FIND NEXT $SRCVOL
IF $SRCVOL EQUALS 0 GOTO END
GOTO LOOP
:END
DRIVE UNMOUNT $SRCDRIVE
PRINT Finished!

Copy system partition to a new hard drive

Explanation of why this is not as simple as it first seems

After purchasing a brand new 80GB drive to replace your previous 4GB device you may be confronted with how to get it setup with all of your software. There are many ways to crack this problem, each with its advantages, disadvantages and some with risks and/or costs. The method that is appropriate depends on the exact result required. Assuming the you want a verbatim copy of the software already installed and configured then the following script could be useful. Please note that there are some limitations to this method as presented here, these are noted below.

Methods available:

1. Use Diskman!
2. Reinstall the OS. This may not be as bad as it sounds and will result in a nice tidy system :)
3. Use XCOPY. If you don't mind loosing those long filenames this will work
4. Use a commerical package such as Norton Ghost or PowerQuest DriveImage. These are both ultra capable but expensive for a one-off event.

Assumption: There system initially had one 4GB hard disk, installed with Windows 98 and partitioned as one FAT32 partition. The replacement drive is 80GB and is temporarily installed as the second (the exact method, e.g. Primary/Slave etc. doesn't matter) drive in the system. The script is running from a bootable floppy disk that contains Diskman and has booted the system:

#Mount first hard disk
DEF SRCDRV DRIVE MOUNT BIOS 0x80

#Locate the 4GB 'source' volume
DEF SRCVOL VOLUME FIND FIRST $SRCDRV

#Mount second (new hard disk)
DEF DESTDRV DRIVE MOUNT BIOS 0x81

#Delete all partitions on the second drive (if any)
#A 'delete all' command is currently on the suggestion list. 
#MBR WIPE does a similar job
MBR WIPE $DESTDRV

#Create maximum sized FAT32 partition on the new drive 
#and make it active
DEF DESTVOL VOLUME CREATE PRIMARY $DESTDRV $MAX $FAT32
VOLUME ACTIVATE $DESTVOL

#Format new partition as FAT32
VOLUME FORMAT $DESTVOL $FAT32

#Merge the existing MBR and boot record from source to 
#destination (these are not files!)
MBR CMERGE $SRCDRV $DESTDRV
BOOTRECORD CMERGE $SRCVOL $DESTVOL

#Copy all files from source to destination
VOLUME COPY $SRCVOL $DESTVOL

#Unmount all drives and finish
DRIVE UNMOUNT ALL
PRINT Drive copy is finished. Please shutdown the machine and 
install the new drive as the primary device.
EXIT

Notes: The example assumes that both partitions were FAT32. If this were not the case then a suitable bootrecord would have to be provided. The Diskman 4 manual explains which boot records may be necessary and how they can be obtained. The script presented above does not include any error checking. If this were a one-off event the script could be manually entered (and run line-by-line) at the Diskman Console. If the source system was installed Windows NT/2000/XP there would be a couple of other issues to consider: (a) The settings in the BOOT.INI file, these are unlikely to matter in the example as the source partition was the only one present (b) The GUID issues associated with Windows 2000/XP - again these are unlikely to effect this example.

29-10-02 Thanks to Paul O'Brien for pointing out a couple of errors in this example. These have now been fixed.

Backup/Restore of BIOS (CMOS) settings

Explanation of why this is sometimes useful

Most users think that a full system backup is just the sum of all the files stored on the hard disk. This is not true. Lurking in the firmware of your PC are lots more settings which influence the way the system functions. Commonly called the BIOS or CMOS setup program this can usually be accessed with the F2 or DEL key at system startup. The settings modified via this setup program are stored in battery backed CMOS memory which is designed to retain the settings for many years. Most systems has 128 or 256 bytes of CMOS memory.

Diskman can be used to backup/restore or view the CMOS memory settings.

#Backup CMOS settings 
CMOS SAVE A:\BACKUP.MOS

Backup/Restore an entire PC

AKA A production strategy for PC systems

The examples described in this document can be combined to produce a reliable PC cloning system. The basic method would be as follows:

1. Backup master machine. This should include MBR, Bootrecord, CMOS settings, LFNS and files
2. Restore the above onto multiple machines.

This example is left for the reader to attempt!


 
    Diskman ©1999-2004. All Rights Reserved, A Bespoke Site