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

📄 0317-0319.html

📁 linux-unix130.linux.and.unix.ebooks130 linux and unix ebookslinuxLearning Linux - Collection of 12 E
💻 HTML
字号:






<HTML>

<HEAD>

<TITLE>Developer.com - Online Reference Library - 0672311623:SAMS TEACH YOURSELF LINUX IN 24 HOURS:Handling Files</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=0672311623 //-->

<!-- TITLE=SAMS TEACH YOURSELF LINUX IN 24 HOURS //-->

<!-- AUTHOR=BILL BALL, STEPHEN SMOOGEN //-->

<!-- PUBLISHER=MACMILLAN //-->

<!-- IMPRINT=SAMS //-->

<!-- PUBLICATION DATE=1998 //-->

<!-- CHAPTER=21 //-->

<!-- PAGES=0313-0328 //-->

<!-- UNASSIGNED1 //-->

<!-- UNASSIGNED2 //-->







<P><CENTER>

<a href="0313-0316.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0320-0322.html">Next</A>

</CENTER></P>



<A NAME="PAGENUM-317"><P>Page 317</P></A>

<P>



<CENTER>

<TABLE BGCOLOR="#FFFF99">

<TR><TD><B>

CAUTION

</B></TD></TR>

<TR><TD>

<BLOCKQUOTE>

You should know that editing the filesystem table by hand is

inherently dangerous. You learned to add quotas in Hour 20, &quot;Basic System

Administration,&quot; but generally you should not edit this file by hand. Instead, use Red

Hat's graphical filesystem configuration tool,

fstool, discussed in Hour 22. Use this tool if you need to add a hard drive, new partitions, and so on. Although you

can edit the fstab file, before you do, make sure you have a backup boot disk on

hand, and make a copy of the fstab file before you edit it.

</BLOCKQUOTE></TD></TR>

</TABLE></CENTER>

</P>

<P>Normally the root operator mounts and unmounts filesystems. But if you take my

advice and don't run Linux as root all the time, you'll have to

use the su command to mount and unmount filesystems. By using the

user option of the mount command, you won't have to

use the su command to mount CD-ROMs. You can, for example, change the original

fstab entries to

</P>

<!-- CODE SNIP //-->

<PRE>

/dev/cdrom      /mnt/cdrom           iso9660 noauto,ro,user 0 0

/dev/hdb        /mnt/cdrom           iso9660 noauto,ro,user 0 0

</PRE>

<!-- END CODE SNIP //-->



<P>You'll now be able to mount CD-ROMs without having to be the root operator, by using

</P>



<!-- CODE SNIP //-->

<PRE>

# mount /dev/cdrom

</PRE>

<!-- END CODE SNIP //-->



<P>or

</P>



<!-- CODE SNIP //-->

<PRE>

# mount /mnt/cdrom

</PRE>

<!-- END CODE SNIP //-->



<P>This will automatically mount your CD-ROM's filesystem at the

/mnt/cdrom path. You'll also be able to switch your disks with

the umount command, for example:

</P>

<!-- CODE SNIP //-->

<PRE>

# umount /dev/cdrom

</PRE>

<!-- END CODE SNIP //-->



<P>or

</P>

<!-- CODE SNIP //-->

<PRE>

# umount /mnt/cdrom

</PRE>

<!-- END CODE SNIP //-->



<P>Although you should enable this type of convenience only if you're using Linux on

a standalone computer, and only for certain types of filesystems, such as CD-ROMs, it

is convenient, especially for removable filesystems. Another type of removable filesystem

is the venerable floppy drive. The next section discusses floppy drives, and is followed by

a discussion of a package of floppy utilities that can make life easier when dealing

with floppies under Linux.

</P>





<A NAME="PAGENUM-318"><P>Page 318</P></A>







<H3><A NAME="ch21_ 7">

Formatting a Floppy

</A></H3>



<P>This section introduces you to three programs you might need to format a floppy

under Linux and takes you step-by-step through the process. You might find this

information useful if you want to back up files or use the floppy to install and test new software.

You'll also learn how to format and then mount your floppy in Linux native format using the

ext2 filesystem (used for your Linux partition, and the root, or

/, directory).

</P>



<P>The floppy devices are located under the /dev

directory, and there are quite a few of them. You'll find a device corresponding to just about any type of floppy device ever made.

You can look at the /dev directory for floppy devices as follows:

</P>

<!-- CODE //-->

<PRE>

# ls /dev/fd*

/dev/fd0        /dev/fd0H1722   /dev/fd0h1600   /dev/fd1E3200   /dev/fd1H830

/dev/fd0CompaQ  /dev/fd0H1743   /dev/fd0h360    /dev/fd1E3520   /dev/fd1d360

/dev/fd0D1040   /dev/fd0H1760   /dev/fd0h410    /dev/fd1E3840   /dev/fd1h1200

/dev/fd0D1120   /dev/fd0H1840   /dev/fd0h420    /dev/fd1H1440   /dev/fd1h1440

/dev/fd0D360    /dev/fd0H1920   /dev/fd0h720    /dev/fd1H1600   /dev/fd1h1476

/dev/fd0D720    /dev/fd0H360    /dev/fd0h880    /dev/fd1H1680   /dev/fd1h1494

/dev/fd0D800    /dev/fd0H720    /dev/fd1        /dev/fd1H1722   /dev/fd1h1600

/dev/fd0E2880   /dev/fd0H820    /dev/fd1CompaQ  /dev/fd1H1743   /dev/fd1h360

/dev/fd0E3200   /dev/fd0H830    /dev/fd1D1040   /dev/fd1H1760   /dev/fd1h410

/dev/fd0E3520   /dev/fd0d360    /dev/fd1D1120   /dev/fd1H1840   /dev/fd1h420

/dev/fd0E3840   /dev/fd0h1200   /dev/fd1D360    /dev/fd1H1920   /dev/fd1h720

/dev/fd0H1440   /dev/fd0h1440   /dev/fd1D720    /dev/fd1H360    /dev/fd1h880

/dev/fd0H1600   /dev/fd0h1476   /dev/fd1D800    /dev/fd1H720

/dev/fd0H1680   /dev/fd0h1494   /dev/fd1E2880   /dev/fd1H820

</PRE>

<!-- END CODE //-->



<P>This section concentrates on the more common device for 3.5-inch, 1.44MB floppies.<BR>

These are

</P>



<BLOCKQUOTE>

/dev/fd0&#151;Drive A<BR>

/dev/fd1&#151;Drive B

</BLOCKQUOTE>





<P>A number of supported floppy formats are listed in

the fdprm, or floppy drive parameter file, under the

/etc/ directory. Take a look at a portion of the file:

</P>



<!-- CODE //-->

<PRE>

# /etc/fdprm  -  floppy disk parameter table



# Common disk formats. Names are of the form

#  actual media capacity/maximum drive capacity

# (Note: although 5.25&quot; HD drives can format disks at 1.44M, they're listed

#        as 1200 because that's the common maximum size.)



#               size sec/t hds trk stre gap  rate spec1 fmt_gap

360/360          720     9   2  40    0 0x2A 0x02 0xDF     0x50

1200/1200       2400    15   2  80    0 0x1B 0x00 0xDF     0x54

360/720          720     9   2  40    1 0x2A 0x02 0xDF     0x50

720/720         1440     9   2  80    0 0x2A 0x02 0xDF     0x50

720/1440        1440     9   2  80    0 0x2A 0x02 0xDF     0x50

360/1200         720     9   2  40    1 0x23 0x01 0xDF     0x50

720/1200        1440     9   2  80    0 0x23 0x01 0xDF     0x50

1440/1440       2880    18   2  80    0 0x1B 0x00 0xCF     0x6C

...

</PRE>

<!-- END CODE //-->



<A NAME="PAGENUM-319"><P>Page 319</P></A>







<P>The format you'll most likely be interested in is the 1440/1440 description of today's

3.5-inch high-density drives. Using this name, you'll use

the setfdprm (set floppy disk parameter) command (found under the

/usr/bin directory), to associate your drive A: floppy with

its device, /dev/fd0, as follows:

</P>



<!-- CODE SNIP //-->

<PRE>

# setfdprm -p /dev/fd0 1440/1440

</PRE>

<!-- END CODE SNIP //-->



<P>After that, you can proceed with a low-level format of your drive.

To do this, you'll use the fdformat (floppy disk formatting) command (found under the

/usr/bin directory). Insert a blank disk in your drive and then use

</P>



<!-- CODE SNIP //-->

<PRE>

# fdformat /dev/fd0

Double-sided, 80 tracks, 18 sec/track. Total capacity 1440 kB.

Formatting ... done

Verifying ... done

</PRE>

<!-- END CODE SNIP //-->



<P>Here, you've told the fdformat command to do a low-level format of the

/dev/fd0 device. Be careful! Make sure to specify the correct device.

</P>



<TABLE BGCOLOR=#FFFF99>

<TR><TD>TIME SAVER</TD></TR>

<TR><TD>

<BLOCKQUOTE>

You should also know that you can alternatively use a specific floppy device

to do the low-level format, for example:

<!-- CODE SNIP //-->

<PRE>

          # fdformat /dev/fd0H1440

</PRE>

<!-- END CODE SNIP //-->



This tells fdformat to use the specific floppy device for high-density drives, in

this case, the A: drive.

</BLOCKQUOTE>

</TD></TR>

</TABLE>



<P>The next step is to create a filesystem on the floppy. You'll use

the mke2fs command to make a Linux second extended filesystem on the floppy. The

mke2fs command, found under the /sbin directory, has at least two dozen command-line options, but you'll only use a few,

for example:

</P>



<!-- CODE //-->

<PRE>

# mke2fs -c -v -L &quot;Linux1&quot; /dev/fd0

mke2fs 1.10, 24-Apr-97 for EXT2 FS 0.5b, 95/08/09

Linux ext2 filesystem format

Filesystem label=Linux1

360 inodes, 1440 blocks

72 blocks (5.00%) reserved for the super user

First data block=1

Block size=1024 (log=0)

Fragment size=1024 (log=0)

1 block group

8192 blocks per group, 8192 fragments per group

360 inodes per group



Running command: badblocks -s /dev/fd0 1440

Checking for bad blocks (read-only test): done

Writing inode tables: done

Writing superblocks and filesystem accounting information: done<BR>

</PRE>

<!-- END CODE //-->





<P><CENTER>

<a href="0313-0316.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0320-0322.html">Next</A>

</CENTER></P>











</td>
</tr>
</table>

<!-- begin footer information -->









</body></html>

⌨️ 快捷键说明

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