0210-0212.html
来自「linux-unix130.linux.and.unix.ebooks130 l」· HTML 代码 · 共 417 行
HTML
417 行
<HTML>
<HEAD>
<TITLE>Developer.com - Online Reference Library - 0672311739:RED HAT LINUX 2ND EDITION:Filesystems, Disks, and Other Devices</TITLE>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>
-->
<!-- ISBN=0672311739 //-->
<!-- TITLE=RED HAT LINUX 2ND EDITION //-->
<!-- AUTHOR=DAVID PITTS ET AL //-->
<!-- PUBLISHER=MACMILLAN //-->
<!-- IMPRINT=SAMS PUBLISHING //-->
<!-- PUBLICATION DATE=1998 //-->
<!-- CHAPTER=11 //-->
<!-- PAGES=0195-0228 //-->
<!-- UNASSIGNED1 //-->
<!-- UNASSIGNED2 //-->
<P><CENTER>
<a href="0207-0209.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0213-0215.html">Next</A>
</CENTER></P>
<A NAME="PAGENUM-210"><P>Page 210</P></A>
<TABLE WIDTH="360">
<TR><TD>
<B>Device Name</B>
</TD><TD>
<B>Disk</B>
</TD><TD>
<B>Partition</B>
</TD><TD>
<B>Filesystem</B>
</TD><TD>
<B>Mounted At</B>
</TD></TR>
<TR><TD>
/dev/hda1
</TD><TD>
1
</TD><TD>
1
</TD><TD>
ext2
</TD><TD>
/
</TD></TR>
<TR><TD>
/dev/hda3
</TD><TD>
1
</TD><TD>
3
</TD><TD>
ext2
</TD><TD>
/usr
</TD></TR>
<TR><TD>
/dev/hdb1
</TD><TD>
2
</TD><TD>
1
</TD><TD>
ext2
</TD><TD>
/usr/sr
</TD></TR>
<TR><TD>
/dev/hdb5
</TD><TD>
2
</TD><TD>
5
</TD><TD>
ext2
</TD><TD>
/home
</TD></TR>
</TABLE>
<P>Note that the partitions on the first disk have names starting with
/dev/hda, and those on the second have names starting with
/dev/hdb. These prefixes are followed by the number of
the partition.
</P>
<CENTER>
<TABLE BGCOLOR="#FFFF99">
<TR><TD><B>
NOTE
</B></TD></TR>
<TR><TD>
<BLOCKQUOTE>
All is not quite as simple as it could be in the partition table, however. Early hard disk
drives on PCs were quite small (about 10MB), so there was a need for only a small number
of partitions and the format of the partition table originally allowed for only four
partitions. Later on, this became a restriction, and the
extended partition was introduced as a workaround.
<BR><BR>
Inside each extended partition is another partition table. This enables this
extended partition to be divided, in the same way, into
four logical partitions. Partitions that aren't inside an extended partition are sometimes referred to
as primary partitions.
</BLOCKQUOTE></TD></TR>
</TABLE></CENTER>
<BR>
<P>Running fdisk -l shows that my first hard disk is divided up like this:</P>
<TABLE WIDTH="360">
<TR><TD>
<B>Device</B>
</TD><TD>
<B>Begin</B>
</TD><TD>
<B>Start</B>
</TD><TD>
<B>End</B>
</TD><TD>
<B>Blocks</B>
</TD><TD>
<B>ID</B>
</TD><TD>
<B>System</B>
</TD></TR>
<TR><TD>
/dev/hda1
</TD><TD>
1
</TD><TD>
1
</TD><TD>
244
</TD><TD>
122944
</TD><TD>
83
</TD><TD>
Linux native
</TD></TR>
<TR><TD>
/dev/hda2
</TD><TD>
245
</TD><TD>
245
</TD><TD>
375
</TD><TD>
66024
</TD><TD>
82
</TD><TD>
Linux swap
</TD></TR>
<TR><TD>
/dev/hda3
</TD><TD>
376
</TD><TD>
376
</TD><TD>
1060
</TD><TD>
345240
</TD><TD>
83
</TD><TD>
Linux native
</TD></TR>
</TABLE>
<P>In this case, there are three primary partitions, of which one is a swap
partition.
</P>
<H5><A NAME="ch11_ 14">Disk Geometry
</A></H5>
<P>The units of the table in the last section are
cylinders. The partition table allocates a
consecutive block of cylinders to each partition. The term
cylinder itself dates from the days when it was possible to remove a disk pack from a UNIX machine and point to the various parts.
That can't be done here, so here's another way of looking at it.
</P>
<P>Imagine that a hard disk is in fact a stack of pizzas. Each of the pizzas is
a platter, a disk-shaped surface with a magnetic coating designed to hold magnetic encodings. Both sides of these
platters are used. These rotate around the spindle, like the spindle in a record player. (Don't
put pizzas on a record player!) The hard disk has a movable arm containing
several disk heads. Each
</P>
<A NAME="PAGENUM-211"><P>Page 211</P></A>
<P>side of each platter has a separate disk head. If you were to put your fingers between the
pizzas while keeping them straight, this would be the same as the arrangement of the heads on
the arm. All the parts of the platters that the heads pass over in one rotation of the disk is called
a cylinder. The parts of a single platter that one head passes over in one rotation is called
a track. Each track is divided into sectors, as if the pizzas had been already sliced for you. The layout
of a disk, its geometry, is described by the number of cylinders, heads, and sectors comprising
the disk. Another important feature is the rotational speed of the disk—generally, the faster this
is, the faster the hard disk can read or write data.
</P>
<P>You can discover the geometry of one of your hard disks by using the
hdparm command, and typical output might look like this:
</P>
<!-- CODE SNIP //-->
<PRE>
# /sbin/hdparm -g /dev/hdc
/dev/hdc:
geometry = 6232/16/63, sectors = 6281856, start = 0
</PRE>
<!-- END CODE SNIP //-->
<TABLE BGCOLOR=#FFFF99><TR><TD><B>NOTE</B></TD></TR><TR><TD><BLOCKQUOTE>
IBM PCs with older BIOSes can have difficulty with large disks; see the Linux
Large-Disk mini-HOWTO.
</BLOCKQUOTE></TD></TR></TABLE>
<BR>
<H4>Floppy Disks</H4>
<P>Floppy disks are removable low-capacity storage media. As storage devices, they are far
slower than hard disks, but they have the advantage that they are removable and make good media
for transporting modest amounts of data.
</P>
<P>The block devices corresponding to the floppy disks begin with the letters
fd; /dev/fd0 is the first, and any additional ones have increasing numbers. There are many possible formats for
a floppy disk, and the kernel needs to know the format (geometry) of a disk to read it
properly. Linux can usually work out the correct format so the automatic devices
/dev/fd0 (plus /dev/fd1 and so on for extra floppy drives) are usually sufficient, but if for some reason it is
necessary to specify the exact format, further device names are provided for indicating this. The device
/dev/fd0H1440, for example, denotes a 1.44MB high-density floppy. There are many more
devices indicating obscure formats, both older lower-capacity formats and other nonstandard
extra_high-capacity formats. You can even create your own floppy disk formats, using the
serfdprm program.
</P>
<P>The most common reason to use the specific-format device names is that you are formatting
a floppy for the first time. In this situation, the disk is not yet readable, so the kernel will not
be able to autoprobe an existing format. You need to use the name
/dev/fd0H1440, for example, to
</P>
<A NAME="PAGENUM-212"><P>Page 212</P></A>
<P>denote a high-density 3.5-inch disk in the first floppy drive. For device names
representing other formats, refer to the fd manual page. Section 4 of the manual is the section devoted
to devices and so on.
</P>
<P>The process of formatting a floppy is completely destructive to the data on it, and because
it requires writing to the actual device itself, it requires root privileges. It is done like this:
</P>
<!-- CODE SNIP //-->
<PRE>
# fdformat /dev/fd0H1440
Double-sided, 80 tracks, 18 sec/track. Total capacity 1440 kB.
Formatting ... done
Verifying ... done
</PRE>
<!-- END CODE SNIP //-->
<P>After you have formatted a floppy, please don't forget to use
mkfs to build a filesystem on it (see the section "Creating New Filesystems," earlier in this chapter).
</P>
<P>Another popular way of accessing floppy disks is to use the
mtools package, which is a suite of programs designed to enable the user to manipulate DOS-format disks without needing
to mount them. The commands are designed specifically to be similar to MS-DOS
commands. Windows 95 filesystems are also supported. You will find an introduction to the use of
mtools in the mtools manual page. mtools can also be used to access hard disks and disk image
files, and it supports many nonstandard disk formats.
</P>
<H3><A NAME="ch11_ 15">
CD-ROM Drives
</A></H3>
<P>The CD-ROM drive is fundamentally just another kind of read-only block device. These
are mounted in just the same way as other block devices. CD-ROMs almost always contain
standard ISO 9660 filesystems, often with some optional extensions. There is no reason,
however, why any other filesystem should not be used. Once you have mounted your CD-ROM,
it behaves like any other read-only filesystem.
</P>
<P>You can set up and mount your CD-ROM drive using the Red Hat File System Manager,
as explained previously, or by using the following
mount command:
</P>
<!-- CODE SNIP //-->
<PRE>
# mount /dev/cdrom -t iso9660 /mnt/cdrom
</PRE>
<!-- END CODE SNIP //-->
<P>The directory /mnt/cdrom is a very common place to mount one's CD-ROM drive under
Red Hat Linux, because this is where the graphical package manager Glint expects to find the
contents of the Red Hat installation CD-ROM, for example.
</P>
<P>The device name /dev/cdrom is commonly used as a symbolic link to the actual device
name corresponding to the CD-ROM, because at the time the CD-ROM drive became available
for the PC, there was no cheap standard interface for these devices. Each manufacturer chose
or invented an interfacing scheme that was incompatible with everyone else's. For this
reason, there are about a dozen different drivers for CD-ROM drives available in the Linux
kernel. SCSI would have been a sensible standard to have been used, but although SCSI
CD-ROM drives are available, they're not particularly popular.
</P>
<P><CENTER>
<a href="0207-0209.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0213-0215.html">Next</A>
</CENTER></P>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?