Linux根文件系统(“/”文件系统)下的目录介绍

Linux下的文件存储与Windows完全不同,Windows将系统文件存储在系统盘(比如说C:\下)
Linux根本没有盘符到概念只有一个根文件系/,各个磁盘分区挂载在/media/下(或者/mnt/下)
/下到如/etc,/proc,/bin,/dev,lib等很是让用惯了Windows的用户
不解,下面是从Linux.org中找到到比较权威的说明。

4.3.1. /dev
A /dev directory containing a special file for all devices to be used by the system is mandatory for any Linux system. The directory itself is a normal directory, and can be created with mkdir in the normal way. The device special files, however, must be created in a special way, using the mknod command.

There is a shortcut, though — copy devices files from your existing hard disk /dev directory. The only requirement is that you copy the device special files using -R option. This will copy the directory without attempting to copy the contents of the files. Be sure to use an upper case R. For example:         cp -dpR /dev/fd[01]* /mnt/dev
        cp -dpR /dev/tty[0-6] /mnt/dev
 
assuming that the diskette is mounted at /mnt. The dp switches ensure that symbolic links are copied as links, rather than using the target file, and that the original file attributes are preserved, thus preserving ownership information.

If you want to do it the hard way, use ls -l to display the major and minor device numbers for the devices you want, and create them on the diskette using mknod.

However the devices files are created, check that any special devices you need have been placed on the rescue diskette. For example, ftape uses tape devices, so you will need to copy all of these if you intend to access your floppy tape drive from the bootdisk.

Note that one inode is required for each device special file, and inodes can at times be a scarce resource, especially on diskette filesystems. You'll need to be selective about the device files you include. For example, if you do not have SCSI disks you can safely ignore /dev/sd*; if you don't intend to use serial ports you can ignore /dev/ttyS*.

If, in building your root filesystem, you get the error No space left on device but a df command shows space still available, you have probably run out of inodes. A df -i will display inode usage.


 Be sure to include the following files from this directory: console, kmem, mem, null, ram0 and tty1.
 
4.3.2. /etc
The /etc directory contains configuration files. What it should contain depends on what programs you intend to run. On most systems, these can be divided into three groups:


Required at all times, e.g. rc, fstab, passwd.

May be required, but no one is too sure.

Junk that crept in.

Files which are not essential can usually be identified with the command:         ls -ltru
 
This lists files in reverse order of date last accessed, so if any files are not being accessed, they can be omitted from a root diskette.

On my root diskettes, I have the number of config files down to 15. This reduces my work to dealing with three sets of files:


The ones I must configure for a boot/root system:


rc.d/* -- system startup and run level change scripts

fstab -- list of file systems to be mounted

inittab -- parameters for the init process, the first process started at boot time.

gettydefs -- parameters for the init process, the first process started at boot time.


The ones I should tidy up for a boot/root system:


passwd -- Critical list of users, home directories, etc.

group -- user groups.

shadow -- passwords of users. You may not have this.

termcap -- the terminal capability database.


If security is important, passwd and shadow should be pruned to avoid copying user passwords off the system, and so that unwanted logins are rejected when you boot from diskette.

Be sure that passwd contains at least root. If you intend other users to login, be sure their home directories and shells exist.

termcap, the terminal database, is typically several hundred kilobytes. The version on your boot/root diskette should be pruned down to contain only the terminal(s) you use, which is usually just the Linux or Linux-console entry.

The rest. They work at the moment, so I leave them alone.


Out of this, I only really have to configure two files, and what they should contain is surprisingly small.


rc should contain:         #!/bin/sh      
        /bin/mount -av
        /bin/hostname Kangaroo
 
Be sure it is executable, be sure it has a "#!" line at the top, and be sure any absolute filenames are correct. You don't really need to run hostname — it just looks nicer if you do.

fstab should contain at least:         /dev/ram0       /               ext2    defaults
        /dev/fd0        /               ext2    defaults
        /proc           /proc           proc    defaults
 
You can copy entries from your existing fstab, but you should not automatically mount any of your hard disk partitions; use the noauto keyword with them. Your hard disk may be damaged or dead when the bootdisk is used.

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/25994.html