Chinaunix首页 | 论坛 | 博客
  • 博客访问: 278654
  • 博文数量: 101
  • 博客积分: 4245
  • 博客等级: 上校
  • 技术积分: 1085
  • 用 户 组: 普通用户
  • 注册时间: 2009-04-24 00:28
文章分类

全部博文(101)

文章存档

2012年(1)

2011年(16)

2010年(34)

2009年(50)

我的朋友

分类: LINUX

2011-03-21 14:52:58

  1. 不开主机箱了解内部设备信息:cat /proc/cpuinfo 和 lspci,其中lspci的man解释是:lspci is a utility for displaying information about all PCI buses in the system and all devices connected to them.
  2. 关于硬盘的管理:每个硬盘的第一个扇区是一个特别重要的扇区,它分为三个部分:(1)开始的446bytes叫mbr(main boot record),用于存放系统引导程序;(2)紧接着的64bytes记录该磁盘的分区表信息;(3)魔数,其实是前面那446bytes的checksum。磁柱是文件系统的最小单位,也就是分区的最小单位。由于历史的原因,存放磁盘分区信息的部分只有64bytes大小,所以只能存储4条分区信息,每条信息记录了该块磁盘的各个分区的起始磁柱号和结束磁柱号。因此任何一块硬盘都只能被分区成为:主分区数 + 扩展分区数最大为4。扩展分区可以进一步划分为多个逻辑分区,这样有效地解决了一块磁盘只能分成四个区的问题。但是必须要注意的是,无论主分区和扩展分区的个数是什么组合形式,第一个逻辑分区总是当做第5个分区。这里扩展分区只是“虚拟的”,并不会进行磁盘格式化,而所有的磁盘格式化都是针对主分区或者是逻辑分区的。
  3. 整个开机流程到操作系统启动的动作:(1)post后,bios程序会去读CMOS里面关于系统启动设备的信息,以决定从那个设备来启动系统;(2)读取启动设备的mbr,运行mbr里面的boot loader;(3)由boot loader把硬盘中的操作系统内核映像文件调入内存;(4)系统控制权交给操作系统,从此由操作系统来管理整个硬件软件环境。
  4. tmpfs什么玩意儿?tmpfs应该称为临时文件系统,它实质上是一个虚拟内存文件系统,它的存储空间在virtual memory里,Linux下面的虚拟内存大小由CPU的寻址范围决定,通常系统的real memory都达不到CPU寻址范围大小,所以,虚拟内存通常等于real memory和swap组成。而Swap的大小是由用户自己决定。Swap是通过硬盘虚拟出来的内存空间,因此它的读写速度相对RM(Real Memory)要慢许多。那为什么需要Swap呢?当一个进程申请一定数量的内存时,如内核的vm子系统发现没有足够的RM时,就会把RM里面的一些不常用的数据交换到Swap里面,如果需要重新使用这些数据再把它们从Swap交换到RM里面。 如果你有足够大的物理内存,当然就可以不需要划分Swap分区。因此tmpfs最大的存储空间可达(The size of RM + The size of Swap)。 但是对于tmpfs本身而言,它并不知道自己使用的空间是RM还是Swap,这一切都是由内核的vm子系统管理的。(进一步阅读:http://lxr.linux.no/linux+v2.6.38/Documentation/filesystems/tmpfs.txt 和http://www.ibm.com/developerworks/cn/linux/filesystem/l-fs3/#1 )
  5. mbr的备份:dd if=DEVICE of=/dev/fd0 bs=512 count=1
  6. mbr的还原:dd if=/dev/fd0 of=DEVICE bs=512 count=1
  7. 磁盘分区时,可以考虑分区为/,/var,/usr,/home,swap
  8. 由于老式的主板上BIOS的历史原因,就主板可能会无法识别大硬盘,所以最好将系统启动文件的目录(/boot)放在1024磁柱以内,也就是说挂载点/boot对应的设备应该是硬盘的第一个分区。
  9. swap分区是不需要指定挂载点的
  10. vfat文件系统可以同时被linux和windows支持,所以如果一台主机的硬盘同时存在windows和linux操作系统,为了数据的交换,就可以建一个vfat文件系统。
  11. 在文本方式登录时,显示的提示信息是由/etc/issue这个文件设定的。
  12. 指令太长时,可以用\来跳脱enter键,使指令连续到下一行(enter必须马上跟在\后面)。
  13. 关于字符系统的问题
  14. 显示当前语系: echo $LANG
  15. Ctrl+c:中断正在运行的程序
  16. Ctrl+d:代表EOF,就是代表输入结束
  17. man命令显示的那些文件一般存放位置在/usr/share/man目录下
  18. man的配置文件在/etc/man.config,不同系统可能有区别
  19. Inode Definition


    An inode is a data structure on a filesystem on Linux and other Unix-like operating systems that stores all the information about a file except its name and its actual data.

    A data structure is a way of storing data so that it can be used efficiently. Different types of data structures are suited to different types of applications, and some are highly specialized for specific types of tasks.

    A filesystem is the hierarchy of directories (also referred to as the directory tree) that is used to organize files on a computer. On Unix-like operating systems, the directories start with the root directory (designated by a forward slash), which contains a series of subdirectories, each of which, in turn, may contain further subdirectories, etc. A variant of this definition is the part of the entire hierarchy of directories or of the directory tree that is located on a single hard disk drive (HDD) or other storage device or on a single partition (i.e., a logically independent section of a HDD).


    A file is a named collection of related information that appears to the user as a single, contiguous block of data and that is retained in storage. It does not automatically contain information about itself (e.g., its size, when it was created or where it is located on the system), unless some human purposely adds in such data. Such information about a file, in contrast to the data contained in a file, is its metadata (i.e., data about data).

    Storage refers to computer devices or media that can hold data for relatively long periods of time (e.g., years or decades), such as disk drives and magnetic tape. A directory (referred to as a folder on some operating systems) in Unix-like operating systems is merely a special type of file that associates file names with a collection of inodes.

    When a file is created, it is assigned both a name and an inode number, which is an integer that is unique within the filesystem. Both the file names and their corresponding inode numbers are stored as entries in the directory that appears to the user to contain the files. That is, the directory associates file names with inodes.

    Whenever a user or a program refers to a file by name, the operating system uses that name to look up the corresponding inode, which then enables the system to obtain the information it needs about the file to perform further operations. That is, a file name in a Unix-like operating system is merely an entry in a table with inode numbers, rather than being associated directly with a file (in contrast to other operating systems such as the Microsoft Windows systems). The inode numbers and their corresponding inodes are held in inode tables, which are stored in strategic locations in a filesystem, including near its beginning.

    This detaching of a file's name from its other metadata is what allows the system to implement hard links and thus have multiple names for any file. A hard link is an entry in a directory that contains a pointer directly to the inode bearing the file's metadata. When a new hard link to a file is created, both links share the same inode number because the link is only a pointer, not a copy of the file.

    The concept of inodes is particularly important to the recovery of damaged filesystems. When parts of the inode are lost, they appear in the lost+found directory within the partition in which they once existed.

    Whereas a file contains only its own content and a directory holds only the names of the files that appear to the user to be contained in it and their inode numbers, an inode contains all the other information describing a file. This metadata includes (1) the size of the file (in bytes) and its physical location (i.e., the addresses of the blocks of storage containing the file's data on a HDD), (2) the file's owner and group, (3) the file's access permissions (i.e., which users are permitted to read, write and/or execute the file), (4) timestamps telling when the inode was created, last modified and last accessed and (5) a reference count telling how many hard links point to the inode.

    The operating system obtains a file's inode number and information in the inode through the use of the system call named stat. A system call is a request in a Unix-like operating system by an active process for a service performed by the kernel (i.e., the core of the operating system), such as input/output (I/O) or process creation. System calls can also be viewed as clearly-defined, direct entry points into the kernel through which programs request services from it. A process is an instance of a program in execution, and an active process process is one which is currently progressing in the CPU (central processing unit).

    Space for inodes must be set aside when an operating system (or a new filesystem) is installed and that system does its initial structuring of the filesystem. Within any filesystem, the maximum number of inodes, and hence the maximum number of files, is set when the filesystem is created.

    There are two ways in which a filesystem can run out of space: it can consume all the space for adding new data (i.e., to existing files or to new files), or it can use up all the inodes. The latter can bring computer use to a sudden stop just as easily as can the former, because exhaustion of the inodes will prohibit the creation of additional files even if sufficient HDD space exists. It is particularly easy to run out of inodes if a filesystem contains a very large number of very small files. A typical system, however, runs out of file space first, because the average file size on most system is larger than two kilobytes.

    The decision as to how many inodes to create is made on Linux using an algorithm (i.e., a set of precise and unambiguous rules that specify how to solve some problem or perform some task) that considers the size of the partition and the average file size. The default setting creates an inode for every 2K bytes contained in the filesystem, but the number can be adjusted by the user when creating the filesystem. For example, it can be wise to create fewer inodes when setting up a filesystem that will contain just a few large files. Similarly, for a filesystem intended for mostly small files, it is advisable to allocate more space to inodes and less to file contents.

    A file's inode number can easily be found by using the ls command, which by default lists the objects (i.e., files, links and directories) in the current directory (i.e., the directory in which the user is currently working), with its -i option. Thus, for example, the following will show the name of each object in the current directory together with its inode number:

    ls -i

    Additional information can be obtained about the inodes on a system by using the df command. This command by default shows the names and sizes of each mounted (i.e., logically connected to the main filesystem) filesystem as well as how much of each is used and unused. One of df's most useful options is -h, which formats the information in human readable form (i.e., in terms of kilobytes, megabytes and gigabytes). Thus the following provides a nice display of both the currently available space and the used space for each filesystem or partition:

    df -h

    df's -i option instructs it to supply information about inodes on each filesystem rather than about available space. Specifically, it tells df to return for each mounted filesystem the total number of inodes, the number of free inodes, the number of used inodes and the percentage of inodes used. This option can be used together with the -h option as follows to make the output easier to read:

    df -hi

    The exact story behind the creation of the term inode has been lost, but it is very likely that the i originally stood for index and/or information.
  20. /etc/sysconfig/i18n修该系统默认的语系
  21. 190页开始FHS
阅读(1175) | 评论(0) | 转发(0) |
0

上一篇:51单片机寄存器

下一篇:《Linux操作系统》

给主人留下些什么吧!~~