📄 505-508.html
字号:
<HTML>
<HEAD>
<TITLE>Using Linux:Managing the Filesystem</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=0789716232//-->
<!--TITLE=Using Linux//-->
<!--AUTHOR=William Ball//-->
<!--PUBLISHER=Macmillan Computer Publishing//-->
<!--IMPRINT=Que//-->
<!--CHAPTER=29//-->
<!--PAGES=505-508//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="503-505.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="508-510.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<P><FONT SIZE="+1"><B><I>Formatting and creating a Linux floppy fstab entry</I></B></FONT></P>
<DL>
<DD><B>1.</B> Log on as the root operator and insert a blank disk into your floppy drive.
<DD><B>2.</B> Use the <TT>mkfs</TT> command, followed by the <TT>–t</TT> option, the name of a filesystem, and the floppy device name on the command line to format a floppy:
<!-- CODE //-->
<PRE>
<B># mkfs -t ext2 /dev/fd1</B>
mke2fs 1.10, 24-Apr-97 for EXT2 FS 0.5b, 95/08/09
Linux ext2 filesystem format
Filesystem label=
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
Writing inode tables: done
Writing superblocks and filesystem accounting
information: done
</PRE>
<!-- END CODE //-->
<DD><B>3.</B> After the <TT>mkfs</TT> command creates the filesystem on your disk, you can include the disk in your filesystem’s table by changing an existing line referring to a <TT>vfat</TT> filesystem on <TT>/dev/fd1</TT>, or by creating a new line.
<BR>Log on as the root operator, and then, using your favorite text editor, open the <TT>/etc/fstab</TT> file. Type an entry for your floppy like this:
<!-- CODE SNIP //-->
<PRE>
/dev/fd1 /mnt/floppy ext2
user,sync,errors=continue 0 0
</PRE>
<!-- END CODE SNIP //-->
<DD><B>4.</B> You can then use the <TT>mount</TT> command to mount your new Linux disk, like this:
<!-- CODE SNIP //-->
<PRE>
<B># mount -t ext2 /dev/fd1 /mnt/floppy</B>
</PRE>
<!-- END CODE SNIP //-->
<DD><B>5.</B> Use the <TT>ls</TT> command, along with the <TT>–la</TT> (long-format and all) options, to verify the contents of the new disk:
<!-- CODE SNIP //-->
<PRE>
<B># ls -la /mnt/floppy</B>
total 14
drwxr-xr-x 3 root root 1024 Aug 1
19:49 .
drwxr-xr-x 7 root root 1024 Jul 3
21:47 ..
drwxr-xr-x 2 root root 12288 Aug 1 19:49
lost+found
</PRE>
<!-- END CODE SNIP //-->
<DD><B>6.</B> Finally, you can unmount the disk with the <TT>umount</TT> command, followed by the mount point of the disk:
<!-- CODE SNIP //-->
<PRE>
<B># umount /mnt/floppy</B>
</PRE>
<!-- END CODE SNIP //-->
</DL>
<P>The structure and creation of an <TT>ext2</TT> filesystem on a floppy shows that there is no volume label, and there are 4,096 bytes (4KB) per inode (360 × 4 = 1,440). The block size is 1KB and 5% of the disk is reserved for root. These are the defaults (which are explained in the <TT>mke2fs</TT> manual page).</P>
<P>The first three columns in the floppy disk’s <TT>/etc/fstab</TT> entry are the Device, Mount Point, and Filesystem type. The Options column is more complex than previous ones. The <TT>user</TT> option indicates that users are allowed to mount this filesystem. The <TT>sync</TT> option indicates that programs writing to this filesystem wait while each write finishes, and only then continue.</P>
<P>This might seem obvious, but it is not the normal state of affairs. The kernel normally manages filesystem writes in such a way as to provide high performance (data still gets written to the device, of course, but it doesn’t necessarily happen immediately). This is perfect for fixed devices such as hard disks, but for low-capacity removable devices such as floppy disks, it’s less beneficial. Normally, you write a few files to a floppy, then unmount it and take it away. The unmount operation must wait until all data has been written to the device before it can finish (and the disk can then be removed).</P>
<P>Having to wait like this is off-putting, and there is always the risk that someone might copy a file to the floppy, wait for the disk light to go out, and remove it. With asynchronous writes, some buffered data might not have yet been written to disk. Hence, synchronous writes are safer for removable media.</P>
<P>The <TT>ext2</TT> filesystem has a configurable strategy for errors. If an <TT>ext2</TT> filesystem encounters an error (for example, a bad disk block), there are three possible responses to the error:</P>
<DL>
<DD><B>•</B> Remount the device read-only—For filesystems that contain mostly nonessential data (for example, <TT>/tmp</TT>, <TT>/var/tmp</TT>, or news spools), remounting the filesystem read-only so that it can be fixed with <TT>fsck</TT> is often the best choice.
<DD><B>•</B> Panic—Continuing in the face of potentially corrupted system configuration files is unwise, so a kernel <I>panic</I> (that is, a controlled crash—or emergency landing, if you prefer) can sometimes be appropriate.
<DD><B>•</B> Ignore it—Causing a system shutdown if a floppy disk has a bad sector is a little excessive, so the <TT>continue</TT> option tells the kernel to “carry on regardless” in this situation. If this actually does happen, the best thing to do is to use the <TT>-c</TT> option of <TT>e2fsck</TT>, for example, with <TT>fsck -t ext2 -c /dev/fd1</TT>. This runs <TT>e2fsck</TT>, giving it the <TT>-c</TT> option, which invokes the <TT>badblocks</TT> command to test the device for bad disk blocks. After this is done, <TT>e2fsck</TT> does its best to recover from the situation.
</DL>
<P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="503-505.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="508-510.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -