                +----------------------------------------+
                |                                        |
                |            Partition saving            |
                |                                        |
                | http://perso.club-internet.fr/guiboure |
                |  Copyright (c) 1999-2000 D. Guibouret  |
                +----------------------------------------+

Table of contents
-----------------

  0- Preamble
  1- Access type to hard disk
  2- Partitioning
     a) Principle:
     b) Partitions table:
  3- Why saving partitions ?
  4- Why a DOS program ?


0- Preamble
-----------

This file gives some precisions on accessing hard disk, partitioning and use
of this program. Its aim is only to give these precisions (not to give all
details on subjects presented).


1- Access type to hard disk
---------------------------

At BIOS level, there was two type of access to hard disk:
  - with its physical definition (cylinder/head/sector). This access type was
first defined. But it does not allow exceeding a capacity of 8 Gb, which has
been exceeded these last years (and even for smaller disk, physical definition
used does not follow the true physical definition).
  - with a linear access. Disk is seen has a unique lead (as for a CD). Disk
until 2 To could be accessed with this method.

For the program if the second access type is possible, it is the one used even
if the disk is less than 8 Gb.


2- Partitioning
---------------

  a) Principle:
Partitioning allows installing several OSes on the same disk. Each OS has a
part of the disk and manages it as it wants.
It equally allows to create several logical drives for one given OS (by
example, the different units C: D: E: ... with DOS).
For this purpose, informations on partitioning are saved on disk so that each
OS could know to whom is each part of disk: these informations compose
partitions table. Once an OS know which partition(s) it uses, it loads
functionalities with which it accesses to data written on this partition with
taken in care how it must access them (FAT system on DOS, ext2fs on Linux,
...). At this level, OS is unable to access to data of others partitions
(unless it has some extensions which allows it: Linux is able to read DOS
partitions by example).

  b) Partitions table:
Here will be presented only the most common format (sorry for people that have
others OSes, but I do not have informations neither OS to realize tests). This
format is the one used notably by Microsoft, Linux, OS2, BeOS, ... (the only
OS that I know that it does not support it is Solaris x86).
Format of this partitions table is the following:
  - on the first sector of hard disk is saved a table giving 4 partitions
which could eventually be empty. This table allows to define partition type,
position on disk and some others informations.
  - the restriction to 4 partitions has been judged to low, so a notion of
extended partition has been added. For this purpose into the four first
partitions (called now principal partitions) could be defined a partition with
a special type. For a partition with such a type, the first sector of this
partition must be read to find a new table defining 1 or 2 partitions (it
seems that OS2 allows 4 partitions on this new table): the first one contains
data, the second one (if defined) is a new extended partition. So if this
second partition is defined, the sector at its begin must also be read to find
a new table and so on. If the second partition is not defined, partition
search is ended. With this method a list of partition could be build (without
limit a priori).
Informations given by partitions table are:
  - partition type: it is a number associated to each partition type. As there
was no standard defined for these types, each OS maker has chosen a number as
he want.
  - a flag to know if this partition is bootable. This flag could generally be 
defined only for principal partitions.
  - the position of the partition with physical definition on disk (as if we
want to use the first access type to hard disk). The positions of the first 
and of the last sector of partition are given.
  - the position of the partition with linear definition: number of first
sector (relative to begin of extended partition if the partition appertains
to an extended one) and the number of sectors into partition.

As you could see, position informations are duplicated between physical
definition and linear position. If the disk is accessed with linear access, it
is linear position that is used, else it is physical definition.


3) Why saving partition ?
----------------------------------------

It appears that each OS manages its data as it want and do not know what is
made elsewhere. So if we want to save data, we have to write a program for
each OS (and we must follow OS evolution). Another way is to cast of OS level
with accessing directly to disk. Indeed, at disk level data seems not to be
organized, they are only written at a position on disk and we do not need to
know their sense. The restraint is that it is necessary to save all data that
are in relation together: the minimum level is partition.
So when saving a partition, we save all informations without knowing how they
are organized. We are free from OS and it is even possible to save data for
which we still do not know organization method.

Remark:
Minimum set of informations in relation that does not depend off data
representation is the partition. But when saving, it must be taken in care
that some OSes could put in relation several partitions together. By example
if you install Windows on C: drive and then some others programs that modify
register base or add DLLs on D: drive, you have to save both partitions one
after other (because the two become linked).


4) Why a DOS program ?
-----------------------------------

An OS must be chosen. Indeed if we do not need to know data organization,
saved data must be written somewhere with a known organization for the user to
access them (by example to write them on a CD). Choice has been made of DOS
because it is a simple task OS. With a multi tasking OS, imagine problems that
could be caused by a process changing data on a partition when saving (or
restoring) of this partition is in progress. In general there is a way to
avoid simultaneous access, but what could happen if the access to hard disk
must be forbidden during a long time as it is the case with this program (by
example with swapping file under Windows)? And what could happen if the OS
does not hold in full into memory?
DOS advantage is that it could be quickly installed (what is the gain if you
have to lose an hour to install OS before restoring?) and could hold on one
floppy. So with running on one floppy, it is possible to save/restore a
partition even if there was no DOS partition on a computer if this computer is
connected to a network with a Samba server on, or if it has a high capacity
saving system (like ZIP or LS120).
This is the reasons why this program could not be run under Windows and that
it is not advise to use it with an emulator running on a multi tasking 
environment (moreover emulator could not define all functionalities used into
this program).


D. Guibouret <guiboure@club-internet.fr>

All trademarks and registered trademarks are ownership of their respective
holders.
