📄 ch05.htm
字号:
<P>-2 Extended VGA
<BLOCKQUOTE>
<P>-1 Normal VGA
</BLOCKQUOTE>
<P>The <TT>rdev</TT> program resides in <TT>/sbin</TT>. <TT>rdev</TT> is very handy
and also is used to set the root and swap partitions, ramdisk size, and more in a
compiled kernel. It means&tm;Ñu don't have to recompb|e the kernel to make
these changes. Use <TT>rdev -?</TT> for a list of options.
<H3 ALIGN="CENTER"><A NAME="Heading11<FONT COLOR="#000077">Accessing DOS Files</FONT></H3>
<P>You can always mount the DOS directories and disks to get to DOS files. There
is a set of tools called <TT>mtools</TT> that expedites this procedure. Look at the
man pages for a complete description of this handy toolset. The following commands
are available for Linux:
<TABLE BORDER="0">
<TR ALIGN="LEFT" rowspan="1">
<TD WIDTH="121" ALIGN="LEFT"><TT>mattrib</TT></TD>
<TD ALIGN="LEFT">Changes MS-DOS file attribute flags.</TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD WIDTH="121" ALIGN="LEFT"><TT>mbadblocks</TT></TD>
<TD ALIGN="LEFT">Marks bad blocks on an MS-DOS diskette.</TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD WIDTH="121" ALIGN="LEFT"><TT>mcd</TT></TD>
<TD ALIGN="LEFT">Changes MS-DOS directory.</TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD WIDTH="121" ALIGN="LEFT"><TT>mcopy</TT></TD>
<TD ALIGN="LEFT">Copies MS-DOS files to/from UNIX.</TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD WIDTH="121" ALIGN="LEFT"><TT>mdel</TT></TD>
<TD ALIGN="LEFT">Deletes an MS-DOS file.</TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD WIDTH="121" ALIGN="LEFT"><TT>mdir</TT></TD>
<TD ALIGN="LEFT">Displays an MS-DOS directory.</TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD WIDTH="121" ALIGN="LEFT"><TT>mformat</TT></TD>
<TD ALIGN="LEFT">Adds an MS-DOS file system to a low-level formatted diskette.</TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD WIDTH="121" ALIGN="LEFT"><TT>mlabel</TT></TD>
<TD ALIGN="LEFT">Makes an MS-DOS volume label.</TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD WIDTH="121" ALIGN="LEFT"><TT>mmd</TT></TD>
<TD ALIGN="LEFT">Makes an MS-DOS subdirectory.</TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD WIDTH="121" ALIGN="LEFT"><TT>mmount</TT></TD>
<TD ALIGN="LEFT">Mounts an MS-DOS FAT-formatted floppy.</TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD WIDTH="121" ALIGN="LEFT"><TT>mmove</TT></TD>
<TD ALIGN="LEFT">Moves or renames an MS-DOS file.</TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD WIDTH="121" ALIGN="LEFT"><TT>mrd</TT></TD>
<TD ALIGN="LEFT">Removes an MS-DOS subdirectory.</TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD WIDTH="121" ALIGN="LEFT"><TT>mren</TT></TD>
<TD ALIGN="LEFT">Renames an existing MS-DOS file.</TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD WIDTH="121" ALIGN="LEFT"><TT>mtest</TT></TD>
<TD ALIGN="LEFT">Tests and displays configuration information.</TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD WIDTH="121" ALIGN="LEFT"><TT>mtools</TT></TD>
<TD ALIGN="LEFT">A public domain collection of programs that enable UNIX systems to read, write, and
manipulate files on an MS-DOS file system (typically a disk). Each program attempts
to emulate the MS-DOS equivalent command.</TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD WIDTH="121" ALIGN="LEFT"><TT>mtype</TT></TD>
<TD ALIGN="LEFT">Displays the contents of an MS-DOS file.</TD>
</TR>
</TABLE>
<CENTER>
<H3><A NAME="Heading12<FONT COLOR="#000077">Configuring mtools</FONT></H3>
</CENTER>
<P>An entry in the file <TT>/etc/mtools</TT> contains the following fields: <TT>drive</TT>,
<TT>device</TT>, <TT>fat</TT>, <TT>cylinders</TT>, <TT>heads</TT>, <TT>sectors</TT>,
and <TT>offset</TT>. Two examples of entries from <TT>/etc/mtools</TT> are</P>
<PRE><FONT COLOR="#0066FF">A /dev/fd0 12 80 2 15
C /dev/hda1 16 0 0 0
</FONT></PRE>
<P>which define the DOS disk in drive A as accessible through the device <TT>/dev/fd0</TT>,
having a 12-bit FAT, 80 cylinders, 2 heads, and 15 sectors per track; DOS disk in
drive C is accessible through the device <TT>/dev/hda1</TT>, has a 16-bit FAT, and
its geometry is simply that of the hard disk where it lives. The last three numbers
can be zero if you want; this enables <TT>mtools</TT> to try to figure out the disk's
geometry itself, and perhaps to fail. A 12-bit FAT is common for floppies but might
occur in small hard-disk partitions. A 16-bit FAT is common for hard disks.</P>
<P>This is an extract of my <TT>/etc/mtools</TT> file:</P>
<PRE><FONT COLOR="#0066FF">A /dev/fd0 12 0 0 0 # 3.5 1.4 Meg (autodetect)
B /dev/fd1 12 0 0 0 # 5.25 1.2 Meg (autodetect)
C /dev/hda1 16 0 0 0 # 1st partition of my Disk
</FONT></PRE>
<P>There are two detailed <TT>README</TT> files in the <TT>mtools.n2</TT> distribution.
These files treat compiling and using <TT>mtools</TT>. There is a file <TT>README.mtools</TT>
that treats only using <TT>mtools</TT>, which is a part of the MCC interim version
of Linux.
<DL>
<DT></DT>
</DL>
<DL>
<DD>
<HR>
<A NAME="Heading13<FONT COLOR="#000077"><B>TIP: </B></FONT>If you want to get
to the MS-DOS files the hard way, you can use <TT>mount -t msdos /dev/hda1 /msdos</TT>
to mount the partition <TT>/dev/hda1</TT> as an MS-DOS file system on the directory
<TT>/msdos</TT>. The directory <TT>/msdos</TT>, however, must exist before this command
can be executed. The caveat to using this approach, however, is that the mount point
is not persistent when the system is rebooted. Therein lies the advantage to using
<TT>mtools</TT>--the mount points will remain even after system reboots.
<HR>
</DL>
<CENTER>
<H3><A NAME="Heading14<FONT COLOR="#000077">Handling Multiple CD-ROMs</FONT></H3>
</CENTER>
<P>Use the following shell script to mount the CD-ROM drive:</P>
<PRE><FONT COLOR="#0066FF">#
# This should be run while logged in as root
echo "Execute: mount -t iso9660 /dev/cdrom /cdrom"
#
mount -t iso9660 /dev/cdrom /cdrom
</FONT></PRE>
<DL>
<DT><FONT COLOR="#0066FF"></FONT></DT>
</DL>
<DL>
<DD>
<HR>
<A NAME="Heading15<FONT COLOR="#000077"><B>CAUTION:</B> </FONT>Don't pull the
CD-ROM out if it's already mounted; use <TT>umount /cdrom</TT> before swapping disks.
<HR>
</DL>
<CENTER>
<H3><A NAME="Heading16<FONT COLOR="#000077">Adding New File Systems</FONT></H3>
</CENTER>
<P>Although this may not seem to be the appropriate place in the book for the topic
of creating file systems to expand your files system space, it is. After you have
worked with Linux for a while, you will want extra space for all the files you accumulate.
If you are not familiar with the way files work in Linux, you might want to familiarize
yourself with Chapter 8, "File System."</P>
<P>In most cases, you will want to expand the <TT>/usr</TT> partition to allow for
more programs. Most programs wind up under the <TT>/usr</TT> partition by default
and it's easy to run out of room. A key point to keep in mind is that you do not
have to have your entire file structure on the same drive or under the <TT>/</TT>
(<TT>root</TT>) directory. The major restriction is that <TT>/:</TT>, <TT>/sbin</TT>,
<TT>/bin</TT>, <TT>/lib</TT>, <TT>/dev</TT>, and <TT>/conf</TT> have to exist on
the root drive for Linux to boot. Any other file systems, including <TT>/usr</TT>,
can be mounted afterward.</P>
<P>Let's start with the example of adding a new physical drive to your system. You
can just as easily extend this example to that of creating new partitions on your
existing drive and creating a file system on them.</P>
<P>My example here deals with the hard drive on an IDE controller, so my first drive
is addressed as<TT>/dev/hda</TT> and the second as <TT>/dev/hdb</TT>. If you have
a SCSI controller, you will have <TT>/dev/sda</TT> and<TT>/dev/sdb</TT> for the first
and second drives, respectively.</P>
<P>You have to do the next operation as <TT>root</TT>, so read the instructions here
carefully and be careful when deleting files. The usual check and balance system
of confirming permissions on deleting important files does not apply to the superuser.</P>
<P>Create a new partition on your new disk as we did in Chapter 3, "Installing
Linux." You can run <TT>fdisk /dev/hdb</TT> to run <TT>fdisk</TT> directly on
the second partition. As a summary, you will use the <TT>n</TT> command to create
a new partition, specify the size in <TT>+Megabytes</TT>, and assign a type 83 for
Linux native type of partition. After you have created the new partition, it's a
good idea to reboot. Most of the documentation I have read on Linux says that it's
not necessary, but I am of the old school of thought about being safe and not sorry.</P>
<P>On your return from the reboot, you will create the extended file system with
the <TT>mke2fs</TT> command. The extended file system is the preferred file system
because it allows for clean boots without having to worry about a file system check
every time you reboot. The syntax for this command to create a file system is</P>
<PRE><FONT COLOR="#0066FF">mke2fs -c partition size-in-blocks
</FONT></PRE>
<P>Therefore, to create your new file system with 480,000 blocks, you would use this
command:</P>
<PRE><FONT COLOR="#0066FF"># mke2fs -c /dev/hdb1 4800000
</FONT></PRE>
<P>where the <TT>/dev/hdb1</TT> is the first partition on drive B, the <TT>-c</TT>
flag checks the newly created blocks for errors, and the size is 480,000 blocks.
Be prepared for an onslaught of messages about inodes, blocks, and so forth. This
process may take a while, so be patient.</P>
<P>Now you can mount this new file system with the <TT>mount</TT> command. First,
create an empty directory in your root directory, let's call it <TT>/data</TT>.</P>
<PRE><FONT COLOR="#0066FF"># cd /
# mkdir data
# mount -t ext2 /dev/hdb1 /data
</FONT></PRE>
<P>The <TT>mount</TT> command shown above will mount the file system in the second
drive as <TT>/data</TT>. The <TT>-t</TT> option specifies what type of file system
exists on the new partition. You can now copy files into this new <TT>/data</TT>
partition. Now you can use this partition for extra space.</P>
<P>The problem is that this mount is valid only for the duration while your machine
is running. If you want this to be mounted automatically at boot time, you should
edit the <TT>/etc/fstab</TT> file and add the following line:</P>
<PRE><FONT COLOR="#0066FF">/dev/hdb1 /data ext2 defaults 1 1
</FONT></PRE>
<P>The line will cause <TT>init</TT>, the boot process for Linux, to mount the <TT>/dev/hdb1</TT>
partition on to the<TT>/data</TT> directory as an extended file system using the
default <TT>mount</TT> parameters.
<CENTER>
<H3><A NAME="Heading17<FONT COLOR="#000077">Linux Loadable Modules</FONT></H3>
</CENTER>
<P>The Linux kernel (since version 1.2.0) also supports loadable modules. Using loadable
modules enables you to build a minimal kernel and add or remove mo
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -