📄 508-510.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=508-510//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="505-508.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="510-513.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<H4 ALIGN="LEFT"><A NAME="Heading11"></A><FONT COLOR="#000077">How to Organize Your File System Tree</FONT></H4>
<P>It is often useful to have major parts of the Linux file system on separate partitions; this can make upgrades and reinstalls easier, and it can also facilitate backup and network administration.
</P>
<P><FONT SIZE="+1"><B>Good Candidates for Separate Filesystems</B></FONT></P>
<P>The best candidate for being on a separate filesystem is the <TT>/home</TT> tree. A separate <TT>/home</TT> file system means that your own data will survive unscathed even if you have to reinstall everything from scratch. If you have more than one machine, it is often useful to mount <TT>/home</TT> over the network so that your files can be shared between all the machines.</P>
<P>Other filesystems are made separate for different reasons—for example, so that they can be mounted over the network, or so that they can have different mount options.</P>
<P>Because the <TT>/usr</TT> file system is large, it is often on a separate filesystem, sometimes mounted from another machine. A separate <TT>/usr</TT> also allows you to have a much smaller root (/) partition. Having a small root partition is beneficial because this tends to reduce the chances of it becoming corrupted when the power fails. Having a separate <TT>/var</TT> partition can help for the same reason.</P>
<P>Some of the machines that I administer are security-critical. On these machines I make <TT>/var/log</TT> a separate, huge filesystem. There are two reasons for this. First, it means that filling up <TT>/tmp</TT> or <TT>/var</TT> will not mean that the system cannot continue to log activity. Second, making <TT>/var/log</TT> large means that an attacker (or “cracker”) can’t fill up the partition in order to prevent the logging of future activities.</P>
<P><FONT SIZE="+1"><B>Bad Candidates for Separate Filesystems</B></FONT></P>
<P>There are some directories that absolutely must be part of the root filesystem. These are listed in Table 29.3.
</P>
<TABLE WIDTH="100%"><CAPTION ALIGN=LEFT><B>Table 29.3</B> Essential Linux directories of the root filesystem
<TR>
<TD COLSPAN="2"><HR>
<TR>
<TH WIDTH="30%" ALIGN="LEFT">Directory Name
<TH WIDTH="70%" ALIGN="LEFT">Description
<TR>
<TD COLSPAN="2"><HR>
<TR>
<TD VALIGN="TOP"><TT>/bin</TT>
<TD>The mount command lives in /bin and if it is not available on the root file system, there is no way to mount any other filesystem.
<TR>
<TD VALIGN="TOP"><TT>/sbin</TT>
<TD>Contains programs essential to booting, such as <TT>/sbin/init</TT>, the very first program to be started (the kernel starts it in order to get the system going).
<TR>
<TD VALIGN="TOP"><TT>/etc</TT>
<TD>Contains many configuration files that must be present at boot time, such as /etc/inittab, and /etc/fstab.
<TR>
<TD VALIGN="TOP"><TT>/dev</TT>
<TD>Contains device files for all the other filesystems in <TT>/dev</TT>. The mount command needs these in order to work.
<TR>
<TD VALIGN="TOP"><TT>/lib</TT>
<TD>Contains libraries to which many programs needed at boot time are dynamically linked.
<TR>
<TD VALIGN="TOP"><TT>/root</TT>
<TD>It’s a good idea to have root’s home directory available even when some filesystems cannot be mounted; useful backup files may be kept there.
<TR>
<TD COLSPAN="2"><HR>
</TABLE>
<P>Almost any other directories can be on separate filesystems. Insightful users will note that the <TT>/boot</TT> directory is not in this list. That is because the files in <TT>/boot</TT> are not needed at boot time; they are needed only when you run the program <TT>/sbin/lilo</TT>. As long as the BIOS can read these files by sector-by-sector BIOS calls, the kernel can be loaded by the boot loader. After the kernel is loaded and the root file system is mounted, these files have done their job. Having a separate <TT>/boot</TT> file system allows you to ensure that it resides near the start of a large hard disk. This can be vital for some older PC-compatible machines.</P>
<H3><A NAME="Heading12"></A><FONT COLOR="#000077">Repairing Filesystems</FONT></H3>
<P>Some disk data is kept in memory temporarily before being written to disk, for performance reasons (see the previous discussion of the <TT>sync</TT> mount option). If the kernel does not have an opportunity to actually write this data, the filesystem can become corrupted. This can happen in several ways:</P>
<DL>
<DD><B>•</B> The storage device (for example, a floppy disk) can be manually removed before the kernel has finished with it.
<DD><B>•</B> The system might suffer a power loss.
<DD><B>•</B> The user might mistakenly turn off the power or accidentally press the reset button.
</DL>
<P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="505-508.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="510-513.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 + -