📄 devices.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content= "application/xhtml+xml; charset=iso-8859-1" /> <title> 8.9. Populating /dev </title> <link rel="stylesheet" href="../stylesheets/lfs.css" type="text/css" /> <meta name="generator" content="DocBook XSL Stylesheets V1.69.1" /> <link rel="stylesheet" href="../stylesheets/lfs-print.css" type= "text/css" media="print" /> </head> <body id="lfs" class="CLFS-SVN-20060417-x86_64-Pure64"> <div class="navheader"> <div class="headertitles"> <h4> Cross-Compiled Linux From Scratch - Version CLFS-SVN-20060417-x86_64-Pure64 </h4> <h3> Chapter 8. If You Are Going to Chroot </h3> </div> <ul class="headerlinks"> <li class="prev"> <a accesskey="p" href="pwdgroup.html" title= "Creating the passwd, group, and log Files">Prev</a> <p> Creating the passwd, group, and log Files </p> </li> <li class="next"> <a accesskey="n" href="../part5.html" title= "Building the LFS System">Next</a> <p> Building the LFS System </p> </li> <li class="up"> <a accesskey="u" href="chapter.html" title= "Chapter 8. If You Are Going to Chroot">Up</a>. </li> <li class="home"> <a accesskey="h" href="../index.html" title= "Cross-Compiled Linux From Scratch - Version CLFS-SVN-20060417-x86_64-Pure64"> Home</a> </li> </ul> </div> <div class="sect1" lang="en" xml:lang="en"> <div class="titlepage"> <h1 class="sect1"> 8.9. Populating /dev </h1> </div> <div class="sect2" lang="en" xml:lang="en"> <div class="titlepage"> <h2 class="sect2"> 8.9.1. Creating Initial Device Nodes </h2> </div> <p> When the kernel boots the system, it requires the presence of a few device nodes, in particular the <tt class="filename">console</tt> and <tt class="filename">null</tt> devices. The device nodes will be created on the hard disk so that they are available before <span><strong class="command">udev</strong></span> has been started, and additionally when Linux is started in single user mode (hence the restrictive permissions on <tt class= "filename">console</tt>). Create these by running the following commands: </p> <pre class="userinput"><kbd class="command">mknod -m 600 /dev/console c 5 1mknod -m 666 /dev/null c 1 3</kbd></pre> </div> <div class="sect2" lang="en" xml:lang="en"> <div class="titlepage"> <h2 class="sect2"> 8.9.2. Mounting tmpfs and Populating /dev </h2> </div> <p> The recommended method of populating the <tt class= "filename">/dev</tt> directory with devices is to mount a virtual filesystem (such as <tt class="systemitem">tmpfs</tt>) on the <tt class="filename">/dev</tt> directory, and allow the devices to be created dynamically on that virtual filesystem as they are detected or accessed. This is generally done during the boot process. Since this new system has not been booted, it is necessary to do what the LFS-Bootscripts package would otherwise do by mounting <tt class="filename">/dev</tt>: </p> <pre class="userinput"><kbd class="command">mount -n -vt tmpfs none /dev</kbd></pre> <p> The Udev package is what actually creates the devices in the <tt class="filename">/dev</tt> directory. Since it will not be installed until later on in the process, manually create the minimal set of device nodes needed to complete the building of this system: </p> <pre class="userinput"><kbd class="command">mknod -m 622 /dev/console c 5 1mknod -m 666 /dev/null c 1 3mknod -m 666 /dev/zero c 1 5mknod -m 666 /dev/ptmx c 5 2mknod -m 666 /dev/tty c 5 0mknod -m 444 /dev/random c 1 8mknod -m 444 /dev/urandom c 1 9chown -v root:tty /dev/{console,ptmx,tty}</kbd></pre> <p> There are some symlinks and directories required by LFS that are created during system startup by the LFS-Bootscripts package. Since this is a chroot environment and not a booted environment, those symlinks and directories need to be created here: </p> <pre class="userinput"><kbd class="command">ln -sv /proc/self/fd /dev/fdln -sv /proc/self/fd/0 /dev/stdinln -sv /proc/self/fd/1 /dev/stdoutln -sv /proc/self/fd/2 /dev/stderrln -sv /proc/kcore /dev/coremkdir -v /dev/ptsmkdir -v /dev/shm</kbd></pre> <p> Finally, mount the proper virtual (kernel) file systems on the newly-created directories: </p> <pre class="userinput"><kbd class="command">mount -vt devpts -o gid=4,mode=620 none /dev/ptsmount -vt tmpfs none /dev/shm</kbd></pre> <p> The <span><strong class="command">mount</strong></span> commands executed above may result in the following warning message: </p> <pre class="screen"><tt class="computeroutput">can't open /etc/fstab: No such file or directory.</tt></pre> <p> This file—<tt class="filename">/etc/fstab</tt>—has not been created yet but is also not required for the file systems to be properly mounted. As such, the warning can be safely ignored. </p> </div> </div> <div class="navfooter"> <ul> <li class="prev"> <a accesskey="p" href="pwdgroup.html" title= "Creating the passwd, group, and log Files">Prev</a> <p> Creating the passwd, group, and log Files </p> </li> <li class="next"> <a accesskey="n" href="../part5.html" title= "Building the LFS System">Next</a> <p> Building the LFS System </p> </li> <li class="up"> <a accesskey="u" href="chapter.html" title= "Chapter 8. If You Are Going to Chroot">Up</a>. </li> <li class="home"> <a accesskey="h" href="../index.html" title= "Cross-Compiled Linux From Scratch - Version CLFS-SVN-20060417-x86_64-Pure64"> Home</a>. </li> </ul> </div> </body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -