Small update of manpage
[rrq/maintain_lilo.git] / readme / README.volumeID
1            Technical Documentation for LILO 22.5 and later
2                 Use of the Volume ID (aka serial number)
3
4                         updated: 20-May-2003
5
6
7 MOTIVATION
8 ==========
9
10 In the past, the biggest headache to getting LILO to boot reliably was the
11 determination of the assignment of BIOS device codes to disks.  This
12 assignment is made by the BIOS, and is quite simple on single hard disk
13 systems:  the hard disk receives BIOS device code 0x80.  However, even two
14 disk systems can confuse LILO if the disks are attached non-sequentially:
15 viz., if the disks are /dev/hda and /dev/hdb, they are assigned device codes
16 0x80 and 0x81, respectively; however, if the disks are /dev/hda and /dev/hdc
17 (perhaps, /dev/hdb is an IDE CDROM), LILO will mistakenly think that the
18 second disk is 0x82.  Just because /dev/hdb is not mentioned in the
19 configuration file (/etc/lilo.conf), does not mean that it does not exist. 
20 But on a two-disk system, attaching the second disk to the second IDE
21 controller has performance advantages.  The solution was to explicitly tell
22 LILO, in the configuration file, that the second disk was attached as
23 /dev/hdc:  viz.,
24
25    disk = /dev/hda   bios = 0x80
26    disk = /dev/hdc   bios = 0x81
27
28
29 The above assignment can be determined automatically in most cases, if the
30 system was booted with a recent version of LILO that supports the "BIOS data
31 check".  This scheme makes the results of certain key BIOS calls available
32 to the Boot Installer (/sbin/lilo), even though it cannot execute BIOS calls
33 directly (far too dangerous).  However, if one used a rescue disk created
34 with another boot loader, the BIOS data check information is not available,
35 and the necessity of the two lines above becomes necessary for the initial
36 installation of LILO.
37
38 The BIOS device code assignment situation becomes very unpredictable on
39 systems with multiple disk controllers:  IDE and SCSI, IDE and super-IDE, or
40 three or more controllers.
41
42 Very recent BIOS's now recognize multiple controllers, and will allow
43 designation of ANY disk on ANY controller as the first hard disk to boot. 
44 Since this disk is the boot disk, it will receive BIOS device code 0x80, and
45 the other disks will received BIOS device codes in some order (known only to
46 the BIOS).  Booting from a different disk tomorrow, the BIOS device codes
47 will be assigned in a still different manner.  Hence, on today's newest
48 systems, the BIOS device code is quite variable, a major departure from the
49 past.
50
51
52 THE VOLUME ID
53 =============
54
55 LILO for over four years now, has been aware of an 8 byte area of the Master
56 Boot Record (sector 0) lying just below the Partition Table.  DR-DOS and
57 Windows NT have used 4 bytes of this area for some years now as a unique
58 32-bit Volume ID, or disk Serial Number.  The usage continues with Windows
59 2000, and probably Windows XP (I haven't used this last, but this is a good
60 guess.)  As far as I know, Windows 98 and earlier never use this Volume ID.
61
62 The power of a unique 32-bit identifier on each physical disk volume, is
63 that a volume can now be identified, even if the BIOS device code changes. 
64 So, since the LILO boot record is limited to one sector, and its main goal
65 is to get the bulk of the boot loader into memory, the boot sector no longer
66 needs to know the BIOS device code of the Second Stage Loader; it now needs
67 to know the Volume ID of the disk which contains the Second Stage Loader. 
68 In the past, if the BIOS device code of the volume with the Second Stage
69 Loader ever changed, the dreaded:
70
71 L 01 01 01 01 01 01 ...
72
73 screen would indicate the failure of the First Stage (boot sector) to
74 successfully load the Second Stage.  Sometimes the BIOS error code varied,
75 but the result was the same:  time to go find the rescue floppy.
76
77
78 LILO 22.5
79 =========
80
81 Beginning with 22.5, LILO now insists that every disk have a unique 32-bit
82 identifier in the Volume ID field, and that all volume ID's on a system are
83 unique.  BIOS device codes are still assigned, but they are no more that
84 indices into a table of Volume ID's written into the Second Stage Loader
85 parameter area.  With the table of Volume ID's, a correspondence may be
86 established between BIOS device codes at install-time, and BIOS device codes
87 at boot-time.  If a tranlation from one BIOS device code to another is
88 needed, it will be made.
89
90 Version 22.5 treated only 0x00000000 as an "empty" (or unassigned) Volume
91 ID, and would generate a new one.  Version 22.5.1 treats 0xFFFFFFFF as an
92 unassigned Volume ID also.  More recent field experience indicates that some
93 low-level format programs leave a residue of identical bytes behind, so
94 version 22.5.4 now treats ANY occurrence of repeated bytes in the Volume ID
95 field as unassigned:  viz.,
96
97         0x00000000
98         0x6c6c6c6c
99         0xa5a5a5a5
100         0xFFFFFFFF
101
102 are all considered to be "unassigned" Volume ID's, and will be filled in
103 with a unique 32-bit value.  Any other combination of bits, whether assigned
104 by LILO, or by Windows NT, or by DR-DOS, will be treated as valid, and will
105 not be altered by LILO, except on explicit command.
106
107 Note:  Any failure to locate a Volume ID during the boot process will cause
108 the LILO loader to fall back to the BIOS device code assigned at
109 install-time.  Hence, the boot algorithm will fall back to the older 22.4
110 and earlier scheme, where BIOS device codes are considered fixed.  Thus it
111 is a good idea to get them right at install-time, but no longer absolutely
112 mandatory with Volume ID's in place.
113
114
115 PICTURE OF A MASTER BOOT RECORD
116 ===============================
117
118 The Master Boot Record is sector 0 (cylinder 0, head 0, sector 1) of every
119 hard disk.
120
121 struct BootSector {
122     char code[0x1b6];   /* boot code, BPB, other stuff */
123
124     short unused;       /* spacer, which is not used AFAIK */
125     long  Volume_ID;    /* 32-bit unique physical volume ID */
126     short marker;       /* who wrote the Volume ID */
127
128     struct PartitionTable {
129         char pt_entry[16];      /* primary partition table entry */
130     } partitions[4];    /* entire partition table is 64 bytes */
131
132     short bootID;       /* MUST be 0xAA55 to indicate disk is bootable */
133 } boot_sector;          /* size must be exactly 512 bytes */
134
135 Note:  Floppy disks do not contain partition tables; hence, floppies do not
136 ever have Volume ID's, per the scheme above.  Floppy disk booting is based
137 on BIOS device code, as with all previous versions of LILO.
138
139
140 VOLUME ID MAINTENANCE
141 =====================
142
143 1. Duplicate Volume ID's
144
145 LILO will complain if two disks have duplicate Volume ID's.  This usually
146 happens when the Volume ID field is a residue of a low-level format, or a
147 residue of some older boot program which overwrites the Volume ID field. 
148 With duplicated Volume ID's, LILO will be unable to distinguish the two
149 offending disks at boot-time, hence it may make an error and read the wrong
150 disk.  Thus, it will refuse to install a boot loader as long as this
151 condition persists.  Unassigned ID's are automatically overwritten, and a
152 backup copy of the sector is created, so the fix is to write an "unassigned"
153 value to one of the duplicated fields.  Say /dev/hda and /dev/hdb have
154 duplicate Volume ID's.  Choose the disk with the higher BIOS device code,
155 since it will not be a Windows NT or 2000 disk, and set the Volume ID to
156 zero; viz.,
157
158         lilo -z -M /dev/hdb
159
160 The disk will receive a new Master Boot Record (which boots the first active
161 partition), and the Volume ID will be set to zero.  A subsequent
162 installation of LILO:
163
164         lilo -v
165
166 Should no longer complain about duplicated Volume ID's on /dev/hda and
167 /dev/hdb.  /dev/hdb will at this time receive a newly generated Volume ID,
168 which will be checked for uniqueness against all other disks in the system.
169
170 CAUTION:  NEVER CHANGE THE VOLUME ID OF A WINDOWS 2000 BOOT DISK.
171
172 Windows NT, 2000, and XP (presumably), all use the Volume ID during the boot
173 process.  Changing the ID can render Windows unbootable.  Recovery seems to
174 be possible by zeroing the Volume ID, although Windows would prefer that the
175 Boot Volume ID remain unchanged.  No trouble has been encountered with
176 changing the Volume ID of Windows 2000 data disks, other than the necessity
177 of resetting the drive letter to its former value.  Basically, if you run
178 Windows NT or later, your disks probably already have Volume ID's assigned
179 by Windows.  If they do, leave them alone.  The Windows ID's are completely
180 compatible with the LILO scheme, and vice versa.
181
182 2.  Volume ID check
183
184 The following command was added in LILO 22.5.4:
185
186         lilo -T vol-ID
187
188 The volume ID's will be printed in BIOS order (as of the most recent LILO
189 boot), based upon the BIOS data check information.  If you did not boot with
190 LILO the last time, then the information as of the last boot will not be
191 available.  Any conflicts will be noted, along with the corrective action
192 LILO will take the next time a boot loader is installed (/sbin/lilo
193 command).  This is the preferred check of the state of Volume ID's on the
194 disks.
195
196 Sample output from "lilo -T vol-id":
197
198   BIOS     Volume ID
199
200   0x80     B21AB21A 
201   0x81     EBF5EB74 
202   0x82     EBF5EB7B 
203   0x83     34225390 
204   0x84     78711C09 
205
206 Volume ID's are all unique.
207
208
209 A volume ID check (Volume S/N) will be printed with the following command:
210
211         lilo -t -v2
212
213 The "-t" switch means a "test mode" install, with no boot record written,
214 and your system unmodified.  The "-v2" is needed to set the verbosity of the
215 output high enough to print the table of BIOS device codes used by LILO (not
216 necessarily the same as the BIOS itself), and the corresponding disk Volume
217 ID's.  This information indicates the order of the BIOS device code
218 translate table, as it would be set up for the next boot.  Disks are
219 indicated by major/minor device numbers, in hex.
220
221 Sample output from "lilo -t -v2 | tail":
222
223 ...
224 Mapped 6 (4+1+1) sectors.
225 Added Windows
226
227  BIOS  Volume S/N  Device
228   80    B21AB21A    0300
229   81    EBF5EB74    0340
230   82    EBF5EB7B    1600
231   83    34225390    2100
232   84    78711C09    0800
233 The boot sector and the map file have *NOT* been altered.
234
235
236 In the two examples above, the Volume ID's are in the same BIOS order,
237 indicating that the BIOS device codes are being assigned by LILO for the
238 boot loader in the correct sequence on this 5 disk system.
239