⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 disk partition table.htm

📁 Linux Kernel Programming by Examples(1)[Xeroo]
💻 HTM
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0061)http://www.geocities.com/marco_corvi/games/lkpe/dpt/index.htm -->
<HTML><HEAD><TITLE>The TTY layer</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252"><LINK 
href="Disk Partition Table_file/style.css" rel=stylesheet>
<META content="MSHTML 6.00.2800.1170" name=GENERATOR></HEAD>
<BODY>
<H2>Disk Partition Table</H2>
<DIV>The partition table information is usually written in the first sector (512 
bytes) of the device, which is therefore called master boot sector (MBS). The 
MS-DOS master boot sector begins with a JUMP instruction (three bytes). The disk 
parameters follow (offset 0x003), and then there is the DOS kernel loader (at 
offset 0x03E). The master boot sector is terminated by the magic number, 0xAA55, 
for the bios in the final two bytes (offset 0x1FE). </DIV>
<DIV>A hard disk is more complicated than a floppy, because it has partitions. 
However the BIOS boots from a hard disk as if it were a floppy. Therefore the 
first sector (master boot record) must have the structure of a MBS, ie, the 
first instruction that is executed is at offset 0x000, and there must be the 
magic number 0xAA55 at offset 0x1FE. The master boot record contains the 
information about the dist partition. More precisely each partition is described 
by 16 bytes, 
<UL>
  <LI>0x00: boof-flag (0 = inactive, 0x80 = active) 
  <LI>0x01: start cyl / head / sect: starting cylinder, head, sector of the 
  partition 
  <LI>0x04: system code (0x80 linux, ...) 
  <LI>0x05: end cyl / head / sect 
  <LI>0x08: relative sector number of start sector 
  <LI>0x0c: number of sectors in the partition </LI></UL>The first partition 
descriptor is at offset 0x1BE. The second at 0x1CE, the third at 0x1DE, and the 
fourth at 0x1EE. </DIV>
<DIV><IMG height=200 alt="C/H/S geometry" 
src="Disk Partition Table_file/chs.gif" width=240 align=right VALIGN="TOP"> Hard 
disks used to have a geometry, described by "cylinders", read/write "heads" and 
"sectors" (see figure). Now the disk geometry is more a logical concept than a 
physical one. Nevertheless it is still used. The units of disk are the sectors. 
Each cylinder contains "head" * "sect" sectors. The C/H/S triples are stored in 
three bytes in the format 10+8+6. This is ok if there are at most 1024 
cylinders, whihc nowadays is mostly not the case. Therefore the triples are not 
used by Linux. </DIV>
<DIV>[more about extended partitions] </DIV><BR clear=all>
<DIV><B>Exercise</B> <BR clear=all>Write a C program that reads the partition 
table from your hard disk(s), and check the result with <CODE>fdisk -lu</CODE>. 
</DIV><BR clear=all><BR clear=all>
<DIV><A 
href="http://www.geocities.com/marco_corvi/games/lkpe/dpt/dpt.c">dpt.c</A><BR></DIV><BR 
clear=all><FONT size=-1>Marco Corvi - 2003</FONT> <!-- text below generated by server. PLEASE REMOVE --></OBJECT></LAYER>
<DIV></DIV></SPAN></STYLE></NOSCRIPT></TABLE></SCRIPT></APPLET>
<SCRIPT 
language=JavaScript>var PUpage="76001084"; var PUprop="geocities"; </SCRIPT>

<SCRIPT language=JavaScript src="Disk Partition Table_file/pu5geo.js"></SCRIPT>

<SCRIPT language=JavaScript 
src="Disk Partition Table_file/ygIELib9.js"></SCRIPT>

<SCRIPT language=JavaScript>var yviContents='http://us.toto.geo.yahoo.com/toto?s=76001084&l=NE&b=1&t=1057747149';yviR='us';yfiEA(0);</SCRIPT>

<SCRIPT language=JavaScript src="Disk Partition Table_file/mc.js"></SCRIPT>

<SCRIPT language=JavaScript src="Disk Partition Table_file/geov2.js"></SCRIPT>

<SCRIPT language=javascript>geovisit();</SCRIPT>
<NOSCRIPT><IMG height=1 alt=setstats src="Disk Partition Table_file/visit.gif" 
width=1 border=0></NOSCRIPT> <IMG height=1 alt=1 
src="Disk Partition Table_file/serv.gif" width=1> <!-- w43.geo.scd.yahoo.com compressed/chunked Wed Jul  9 03:39:09 PDT 2003 --></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -