『楼 主』:
转贴:LINUX磁盘结构简介
使用 LLM 解释/回答一下
ci硬盘功能极为简单,用来可靠的存储及检索数据。写入数据之前,我们需要格式化驱动器。
格式化,又称“制作文件系统”,是一个将信息写入驱动器,在未经格式化的驱动器内的空
白空间建立秩序的过程。
文件系统建立的秩序牵涉到一些利弊得失:
1。驱动器上很小的一部分可用空间被用来存储与文件系统有关的数据,可被视做管理费用。
2。文件系统将剩余空间分割成小块的,大小统一的段。在LINUX中,被称为块(BLOCK)。
由于文件系统带来创建目录和文件的可能性,以上做出的牺牲可以被当作需要付出的极小的
一个代价。
单一通用的文件系统并不存在。一个磁盘驱动器上可以有许多不同类型的文件系统,不同文
件系统通常是不兼容的。将文件系统写入磁盘只是一个开端。这个过程的目标实际上是存储并检索数据。
将磁盘划分为分区后,每一个分区都可以象一个独立的磁盘一样被访问,这是通过添加分区表(PATITION TABLE)作到的。分区表保存在磁盘的最起首,在任何文件系统或用户数据之前。分区表被分为若干个部分(最多四个),每个部分都装有定义单个分区所必须的信息,意味着分区表定义的分区不能超过四个。
每个分区表项目都包含着该分区的几项重要的特征:
1。再磁盘上分区开始和结束的地点(定义了分区的大小和再磁盘上的位置)。
2。分区是否“活跃”(被某些操作系统的引导装载程序所用,即:标有“活跃”的分区上的操作系统将会被引导。
3。分区的类型(类型是表示分区预备用途的数字,某些操作系统用分区类型来表示一种指定的系统类型,或将分区标志为与某个操作系统相联系的分区,或用来指明该分区包含着可引导的操作系统,或是三者的结合。
许多情况下,整个磁盘只有一个分区,基本上是重复分区前使用的方法。分区表内只有一个项目,指向分区的起点。
经过一段时间后,四个分区显然不够用。随着磁盘驱动器的不断增大,配置了四个相当大的分区后仍有剩余空间的可能性会越来越大。因此需要有一些创建更多分区的方法:扩展分区。
当一个分区被建立,其类型被设为”扩展“时,扩展分区也被创建。简而言之,扩展分区就象一个独立的磁盘驱动器-他有自己的分区表指向一个或多个分区(现称为逻辑分区,与四个主分区相对),分区表完全包括在扩展分区之内。主分区与逻辑分区之间有些区别-主分区只能有四个,但是可以存在的逻辑分区数量却无限制(现实情况下,不多于12个)
当你试图为硬盘重新分区时,有三种可能的情况:
1。有可用的未使用的空闲空间
2。有可用的未使用过的分区
3。被活跃使用的分区内有可用的空闲空间。
第一种情况下,已定义的分区没有扩展到整个硬盘,没有包括那些不属于任何定义分区的未分配的空间。
分区命名方案:
LINUX使用字母和数字的组合来代指磁盘分区。在DOS/WINDOWS的世界里,分区用下列方法命名:
1,每个分区都被检查过,以便判定他是否可被DOS/WINDOWS读取。
2,如果分区类型是兼容的,他会被指派给一个”驱动器字母“,从‘C’ 开始,然后依据要标签的分区数量而按字母顺序推移。
3,驱动器字母可以用来指代那个分区,也可以指代分区所含的文件系统。
RED HAT LINUX使用一种更灵活的命名方案。他所传达的信息比其他操作系统采用的命名方案要多。该命名方案基于文件,文件名的格式为:/DEV/XXYN
/DEV/ 是所有设备文件驻留的目录名.因为分区驻留在硬盘上,而硬盘是设备,所以这些文件代表了驻留在/DEV/上所有可能的分区.
XX 是分区名起首的两个字母,表明分区驻留设备的类型.如:HD(用于IDE磁盘)或SD(用于SCSI磁盘).
Y 是表明分区所在的设备.如,/DEV/HDA(第一个IDE磁盘)或/DEV/SDB(第二个SCSI磁盘)
N 最后的数字代表分区.前四个分区(主分区或扩展分区)用字母从一排到四.逻辑分区从5开始。例如:/DEV/HADA3是在第一个IDE硬盘上的第三个主分区或扩展分区;/DEV/SDB6是第二个SCSI硬盘上的第二个逻辑分区。在常规命名中,没有一个是基于分区类型的,与DOS/WINDOWS不同,所有分区可在RED HAT LINUX下识别。
磁盘分区和挂载点:
DOS/WINDOWS中,每一个分区有一个“驱动器字母”,用正确的驱动器字母来指代相应分区上的文件和目录。与LINUX如何处理分区及磁盘存储问题截然不同。主要的区别在于,每一个分区都用来构成支持一组文件和目录所必须的存储区的一部分。通过挂载的(MOUNT)的过程将分区关联到某一目录来实现。挂载分区使其起始于这个指定目录(统称为挂载点)的存贮区变的可用。
如:如果分区/DEV/HDA5被挂载在/USR,意味着所有在/USR下的文件和目录在物理意义上驻留在/DEV/HDA5上。因此,文件/USR/SHARE/DOC/FAQ/TXT是被储存在/DEV/HDA5上,而文件/ETC/X11/GDM/SESSIN/GNOME却不是。还有可能/USR下的一个或多个目录是其他分区的挂载点。例如:某个分区/DEV/HDA7不能被挂载到/USR/LOCAL中,意味着/USR/LOCAL/MAN/WHATIS将驻留在/DEV/HDA7上而不是/DEV/HDA5上。
除非另有原因,推荐至少创建以下分区:
1,一个交换分区-用来支持虚拟内存。换句话说,当没有足够的内存来容纳你的系统正在处理的数据是,这些数据就被写入交换区。必须建立一个交换分区才能正确使用RED HAT LINUX。你的交换分区的最小数值应是计算机内存的两倍。
2,一个/BOOT分区-挂载在/BOOT上的分区包含有操作系统的内核(允许你的系统被引导入RED HAT LINUX),以及其他几个在引导过程中使用的文件。32M足够。
3,一个跟分区(/)-是跟目录驻留的地方。在分区布局中,所有文件(除了那些驻留在/BOOT上的以外)都驻留在跟分区。应尽可能的扩大跟分区的大小。例如,一个1.2GB的跟分区可能会允许相当于一个工作站大小的安装,与此同时,一个3.4GB的跟分区可能会让你安装每一个软件包.
GRUB和LILO是最常见的基于INTEL的系统上引导RED HAT LINUX的方法.作为操作系统装载程序,他们操作于任何操作系统之外,仅使用在计算机硬件中内建的基本I/O系统(BIOS).在多数基于INTEL的计算机中,GRUB和LILO要接受由BIOS所强加的限制.特别是,多数BIOS无法进入两个以上的硬盘,而且他们无法访问任意驱动器上在超越柱面1023以上所存储的数据.所有GRUB和LILO需要在引导期访问的数据位于/BOOT目录中.如果要是使用GRUB或LILO引导RED HAT LINUX系统,/BOOT所驻留的分区一定要遵守以下条例:
在前两个IDE驱动器上,如果有两个IDE或(EIDE)驱动器,/BOOT必须位于其中之一.注意,两个驱动器的限制也包括任何在你的主IDE控制器上的IDE光盘驱动器.因此,如果在你的主控制器上你有一个IDE硬盘,和一个光盘驱动器,/BOOT必须仅能位于第一个硬盘,即便在你的次IDE控制器上另有硬盘.
在第一个IDE或第一个SCSI驱动器上,如果有一个IDE驱动器和一个或更多SCSI驱动器,/BOOT必须位于IDE驱动器上或ID为0的SCSI驱动器上.其他的SCSI ID都不行.
在前两个SCSI驱动器上:如果只有SCSI硬盘,/BOOT必须位于ID为0或1的驱动器上.
分区完全在驻面1023以下,如果容有/BOOT的分区位于1023的两侧,GRUB和LILO最初可能会起作用,以为所有必须的信息都位于1023之下,如果一个新内核被装入后驻留在1023之上,就会失败.
要从你的系统中删除LINUX只须从你的主引导记录(MBR)中删除有关GRUB或LILO的信息.
FDISK /MBR.
如果需要从一个硬盘驱动器中删除LINUX,并且默认的DOS FDISK 来这么做,将会经历到"分区存在但又不存在"的问题,要删除非DOS分区的最好的办法是使用一个理解分区而不单是DOS的工具.可以用安装介质达到这一点,只须在BOOT:提示下键入LINUX EXPERT:
选择安装,并在你应该给驱动器分区的地方选择FDISK,在FDISK中,键入来打印出分区号码,然后用命令来删除LINUX分区,对改变满意后,用退出,存储改变,如删除太多,用命令,将不会做任何改变.删除后,重起,无须继续安装.
创建引导盘:SHELL后键入:MAN MKBOOTDISK.
MBR是推荐安装装载程序的地方,除非MBR已经在启动另一个操作系统的引导装载程序,如:SYSTEM COMMANDER.MBR是硬盘驱动器上的一个特殊地区,他会被你的计算机的BIOS自动载入,并且是引导装载程序控制引导进程的最早地点.如果你在MBR上安装引导装载程序,当你的机器引导时,GRUB或LILO会呈现一个引导提示.然后便可以引导RED HAT LINUX或其他任何你配置引导装载程序来引导的操作系统.
要变成跟用户,键入:SU
安装后改变键盘类型:/USR/SBIN/KDBCONFIG或SETUP
改变鼠标类型:/USR/SBIN/MOUSECONFIG
用多个键创建特殊字符通过使用"死键'"(又称组合键序列)来达到.死键默认被起用.要重新起用死键,必须在/ETC/X11下XF86CONFIG-4文件或XF86CONFIG文件中把禁用死键INPUTDEVICE的句行变为注释.默认起用,除非有"NODEADKEYS"选项.
模拟三键鼠标,用同时按鼠标的两键来模拟第三个中间键.
CI hard drives have extremely simple functions, used to reliably store and retrieve data. Before writing data, we need to format the drive.
Formatting, also known as "creating a file system", is a process of writing information to the drive and establishing order in the blank space in an unformatted drive.
The order established by the file system involves some advantages and disadvantages:
1. A very small part of the available space on the drive is used to store data related to the file system, which can be regarded as management costs.
2. The file system divides the remaining space into small, uniformly sized segments. In LINUX, it is called a block (BLOCK).
Due to the possibility of creating directories and files brought about by the file system, the sacrifices made above can be regarded as a very small price to pay.
There is no single universal file system. There can be many different types of file systems on a disk drive, and different file systems are usually incompatible. Writing the file system to the disk is just the beginning. The goal of this process is actually to store and retrieve data.
After dividing the disk into partitions, each partition can be accessed like an independent disk, which is done by adding a partition table (PATITION TABLE). The partition table is saved at the very beginning of the disk, before any file system or user data. The partition table is divided into several parts (up to four), each part contains the information necessary to define a single partition, which means that the partitions defined by the partition table cannot exceed four.
Each partition table entry contains several important characteristics of the partition:
1. The start and end locations of the partition on the disk (defines the size of the partition and its position on the disk).
2. Whether the partition is "active" (used by the boot loader of some operating systems, that is, the operating system on the partition marked "active" will be booted.
3. The type of the partition (the type is a number indicating the intended use of the partition. Some operating systems use the partition type to indicate a specified system type, or mark the partition as a partition associated with an operating system, or to indicate that the partition contains a bootable operating system, or a combination of the three.
In many cases, there is only one partition on the entire disk, basically repeating the method used before partitioning. There is only one entry in the partition table pointing to the start of the partition.
After a period of time, four partitions are obviously not enough. As disk drives continue to increase in size, the possibility of having remaining space after configuring four rather large partitions will become greater and greater. Therefore, there is a need for some methods to create more partitions: extended partitions.
When a partition is created and its type is set to "extended", an extended partition is also created. In short, an extended partition is like an independent disk drive - it has its own partition table pointing to one or more partitions (now called logical partitions, in contrast to four primary partitions). The partition table is completely included within the extended partition. There are some differences between primary partitions and logical partitions - there can be only four primary partitions, but the number of logical partitions that can exist is unlimited (in reality, no more than 12).
When you try to repartition the hard disk, there are three possible situations:
1. There is available unused free space
2. There is an available unused partition
3. There is available free space in the actively used partition.
In the first case, the defined partitions do not extend to the entire hard disk, and do not include the unallocated space that does not belong to any defined partition.
Partition naming scheme:
LINUX uses a combination of letters and numbers to refer to disk partitions. In the DOS/WINDOWS world, partitions are named in the following way:
1. Each partition is checked to determine whether it can be read by DOS/WINDOWS.
2. If the partition type is compatible, it will be assigned a "drive letter", starting from 'C', and then pushed in alphabetical order according to the number of partitions to be labeled.
3. The drive letter can be used to refer to that partition or the file system contained in the partition.
RED HAT LINUX uses a more flexible naming scheme. The information it conveys is more than the naming schemes used by other operating systems. This naming scheme is based on files, and the format of the file name is: /DEV/XXYN
/DEV/ is the directory name where all device files reside. Because partitions reside on the hard disk, and the hard disk is a device, these files represent all possible partitions residing on /DEV/.
XX is the first two letters of the partition name, indicating the type of the device where the partition resides. For example: HD (for IDE disks) or SD (for SCSI disks).
Y is the device where the partition is located. For example, /DEV/HDA (the first IDE disk) or /DEV/SDB (the second SCSI disk)
N The last number represents the partition. The first four partitions (primary partitions or extended partitions) are numbered from one to four. Logical partitions start from 5. For example: /DEV/HADA3 is the third primary partition or extended partition on the first IDE hard disk; /DEV/SDB6 is the second logical partition on the second SCSI hard disk. In the conventional naming, none are based on the partition type. Unlike DOS/WINDOWS, all partitions can be recognized under RED HAT LINUX.
Disk partitions and mount points:
In DOS/WINDOWS, each partition has a "drive letter", and the correct drive letter is used to refer to the files and directories on the corresponding partition. It is very different from how LINUX handles partitions and disk storage. The main difference is that each partition is used to form a part of the storage area necessary to support a group of files and directories. It is achieved by associating the partition with a directory through the mounting (MOUNT) process. Mounting the partition makes the storage area starting from this specified directory (collectively called the mount point) available.
For example: If the partition /DEV/HDA5 is mounted on /USR, it means that all files and directories under /USR physically reside on /DEV/HDA5. Therefore, the file /USR/SHARE/DOC/FAQ/TXT is stored on /DEV/HDA5, while the file /ETC/X11/GDM/SESSIN/GNOME is not. It is also possible that one or more directories under /USR are mount points of other partitions. For example, a partition /DEV/HDA7 cannot be mounted to /USR/LOCAL, which means that /USR/LOCAL/MAN/WHATIS will reside on /DEV/HDA7 instead of /DEV/HDA5.
Unless there is another reason, it is recommended to create at least the following partitions:
1. A swap partition - used to support virtual memory. In other words, when there is not enough memory to hold the data that your system is processing, this data is written to the swap area. A swap partition must be established to use RED HAT LINUX correctly. The minimum value of your swap partition should be twice the memory of the computer.
2. A /BOOT partition - the partition mounted on /BOOT contains the kernel of the operating system (allowing your system to be booted into RED HAT LINUX), and several other files used during the boot process. 32M is enough.
3. A root partition (/) - is where the root directory resides. In the partition layout, all files (except those residing on /BOOT) reside on the root partition. The size of the root partition should be expanded as much as possible. For example, a 1.2GB root partition may allow an installation of a workstation size, while a 3.4GB root partition may allow you to install every software package.
GRUB and LILO are the most common methods to boot RED HAT LINUX on Intel-based systems. As operating system loaders, they operate outside any operating system and only use the basic I/O system (BIOS) built into the computer hardware. In most Intel-based computers, GRUB and LILO have to accept the restrictions imposed by the BIOS. In particular, most BIOS cannot access more than two hard disks, and they cannot access data stored above cylinder 1023 on any drive. All the data that GRUB and LILO need to access during the boot period is located in the /BOOT directory. If you want to use GRUB or LILO to boot the RED HAT LINUX system, the partition where /BOOT resides must comply with the following regulations:
On the first two IDE drives, if there are two IDE or (EIDE) drives, /BOOT must be located on one of them. Note that the limit of two drives also includes any IDE CD-ROM drives on your primary IDE controller. Therefore, if you have an IDE hard disk and a CD-ROM drive on your primary controller, /BOOT must only be located on the first hard disk, even if there is another hard disk on your secondary IDE controller.
On the first IDE or first SCSI drive, if there is an IDE drive and one or more SCSI drives, /BOOT must be located on the IDE drive or the SCSI drive with ID 0. No other SCSI IDs are allowed.
On the first two SCSI drives: If there are only SCSI hard disks, /BOOT must be located on the drive with ID 0 or 1.
The partition is completely below cylinder 1023. If the partition containing /BOOT is located on both sides of 1023, GRUB and LILO may work initially because all necessary information is below 1023. If a new kernel is loaded and resides above 1023, it will fail.
To delete LINUX from your system, you just need to delete the information about GRUB or LILO from your master boot record (MBR).
FDISK /MBR.
If you need to delete LINUX from a hard disk drive and use the default DOS FDISK to do so, you will encounter the problem of "partitions exist but do not exist". The best way to delete non-DOS partitions is to use a tool that understands partitions, not just DOS. You can achieve this with the installation media. Just type LINUX EXPERT at the BOOT: prompt:
Select installation, and select FDISK where you should partition the drive. In FDISK, type to print the partition number, then use the command to delete the LINUX partition. After being satisfied with the changes, use to exit and save the changes. If you delete too much, use the command, which will not make any changes. After deletion, restart and no need to continue the installation.
Create a boot disk: Type MAN MKBOOTDISK after SHELL.
The MBR is the recommended place to install the loader, unless the MBR is already booting the boot loader of another operating system, such as: SYSTEM COMMANDER. The MBR is a special area on the hard disk drive that will be automatically loaded by the BIOS of your computer, and it is the earliest place where the boot loader controls the boot process. If you install the boot loader on the MBR, when your machine boots, GRUB or LILO will present a boot prompt. Then you can boot RED HAT LINUX or any other operating system that you have configured the boot loader to boot.
To become a root user, type: SU
Change the keyboard type after installation: /USR/SBIN/KDBCONFIG or SETUP
Change the mouse type: /USR/SBIN/MOUSECONFIG
To create special characters with multiple keys, use "dead keys" (also known as key combination sequences). Dead keys are enabled by default. To re-enable dead keys, you must comment out the line disabling dead keys INPUTDEVICE in the XF86CONFIG-4 file or XF86CONFIG file under /ETC/X11. It is enabled by default unless there is a "NODEADKEYS" option.
To simulate a three-button mouse, press the two buttons of the mouse simultaneously to simulate the third middle button.
|