Linux administrator Manual (3)-Use of disks and other storage media
Source: Internet
Author: User
Article Title: Linux administrator Manual (3)-Use of disks and other storage media. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
When installing and upgrading the system, you need to do a lot of work on the hard disk. You must create a file system on the hard disk so that the file can exist on it and reserve space for different parts of the system.
This chapter describes all these initialization tasks. Generally, once you build a system, you do not have to do this (except for using a floppy disk ). If you want to add a new hard disk or better adjust the use of your hard disk, you may return to this chapter.
Basic disk management tasks include:
Format the disk. This makes some work for the disk to enter and use, such as checking Bad Sectors. (Currently, most hard disks do not need to be formatted .)
To partition a hard disk, if you want to use it for a few things that do not interfere with each other. One reason for partitioning is to store different operating systems on a hard disk. Another reason is to separate user files from system files to simplify backups and help protect system files when the system crashes.
Create a proper type of file system on each disk or partition, and then the file can be generated and accessed on it. Before you create a file system, the disk has no significance for Linux.
Install different file systems to form a separate tree structure, which can be completed automatically or manually as needed. (Manually installed file systems usually need to be manually unmounted)
Chapter 5 includes information about the virtual memory and disk cache.
This chapter describes what to know about hard disks, floppy disks, CDROM, and tape drives.
Two devices
UNIX and Linux: identifies two types of devices: Random Block devices (such as disks) and character devices (such as tapes and serial lines). Some are serial and some are random. Each file system supports a device file. When reading and writing device files, the data is connected to the device. In this way, there is no need to develop a special program for the access device (the program does not directly obtain the interrupt or read the serial port). For example, to send a file to the printer, you only need:
$ Cat filename>/dev/lp1
$
The file content is printed (of course, the file must be a format that the printer can understand ). Of course, because multiple people should not be allowed to cat files to the same printer at the same time, generally use a specific program to send files to print (usually lpr ). This program can ensure that only one file is printed at the same time, and automatically sends the next one after completion. Most devices have similar requirements. In fact, there is little need to care about device files.
Because the device is regarded as a file in the file system (in the/dev directory), it is easy to see which device files exist, use ls or other appropriate commands. In the ls-l output, the first column contains the file type and permissions. For example, to view a serial device on my system:
The first character in the first column, that is, c in crw-rw-tells the user the file type, which is a character device. Generally, the first character of a file is "-", the directory is "d", and the block device is "B". For more information, see the ls man page.
Note that even if the device is not installed, all the device files usually exist. Therefore, having a/dev/sda file does not mean you have a SCSI hard disk. Some device files make the installer simpler and easier to add new hardware (no need to find the correct parameters for the device files that generate the new device ).
Hard Disk
This section describes the terms related to hard disks. If you already know the projects and content, skip this section.
The hard disk consists of one to several platters, one or two of which are surfaces coated with magnetic materials for recording data. Each side has a read-write head for reading and writing data. The disk has a common axis. The typical rotation speed is 3600 rpm, and the high-performance hard drive speed may be higher. The head can move along the disk radius. The head movement and disk rotation allow the word header to access any position on the disk surface.
The processor (CPU) communicates with the actual disk through the disk controller. This makes it unnecessary for other parts of the computer to know how to use the drive, because controllers on different disks can make the same interface for other parts of the computer. In this way, the computer only needs to say "Hi, disk, give me what I want", instead of moving the head to the right position with a long and complex electrical signal, and wait until the correct position is under the head to do the unpleasant work. (In fact, the interface to the Controller is still very complicated, but not much better .) The controller can also do other things, such as buffering or automatic replacement of Bad Sectors. Electrical signal control and operation of mechanical components,
The above is only required to understand the hardware. There are many other tasks, such as rotating a motor disk and moving a head, but they are irrelevant to understanding how the hard disk works.
The disk surface is usually divided into concentric rings, called track tracks, and the track is divided into sector sectors. This Shard is used to locate the disk space for the file. To find the specified location on the hard disk, is it possible? Quot; 3-sided, 5-way, 7-Sector ". Generally, all magnetic channels have the same number of sectors, but there are also sectors where the hard disk is placed in the outer ring magnetic channels (all sectors use the same size of physical space, in this way, more data can be accommodated in the long outer ring track ). Generally, one slice can hold 512 bytes of data. A disk cannot process data volumes smaller than a single slice.
Each plane is divided into a magnetic channel and a sector in the same way. This means that when a head is in a channel, other heads are also in the corresponding position, and all tracks in the same position form cylinder. It takes time for the head to move from one track (cylindrical) to another, so it takes time to put data (such as a file) that is frequently accessed together in one cylindrical. This improves performance. Of course it cannot be done completely. The file is put in several separated locations called fragmented.
The disk surface (or header, which is actually the same), the number of cylinders, and the number of sectors are different. The number of hard disks is called the hard disk parameter geometry. Hard Disk Parameters usually exist in a specific battery-powered storage zone, called cmos ram, from which the operating system can obtain hard disk parameters during boot or drive initialization.
Unfortunately, the BIOS has a design limit, that is, the number of tracks cannot be defined in cmos ram greater than 1024, which is too small for a large hard disk. To overcome this problem, the hard disk controller spoofs the disk parameters and uses address translation to translates the addresses for computer acceptance. For example, a hard disk may have 8 heads, 2048 tracks, and 35 sectors per track. Its controller can lie to the computer that it has 16 Heads, 1024 tracks, 35 sectors per track, so that it does not exceed the number of tracks limit, address conversion will halved the number of magnetic heads, repeat the number of tracks and send them to the hard disk. The actual algorithm may be more complex, because the number may not be as good as we suppose here (but this does not affect our understanding of the principle ). This conversion creates an illusion in the operating system and may affect the operating system's attempt to put all data in the same cylinder.
Conversion is only a problem with the IDE hard disk. The SCSI hard disk uses a continuous fan ID (that is, the Controller changes the continuous sector into a three-parameter group of the head, cylinder, and sector) to communicate with the controller using a completely different method, therefore, this problem does not occur. Note that the computer may not know the actual parameters of a SCSI hard disk.
Since Linux often does not know the real parameters of a hard disk, its file system does not try to store the file in a cylindrical. Instead, we strive to allocate continuous numbers to a file in a mountainous area to achieve similar performance. For hard disks with cashe or automatically prefetch on the controller, the situation is more complicated.
Each hard disk is represented as a separate device file. Generally, there can be only 2-4 IDE hard disks. This is/dev/hda,/dev/hdb,/dev/hdc, And/dev/hdd. SCSI is/dev/sda,/dev/sdb, and so on. For more information, see [Anv]. Note that the device file on the hard disk provides access to the entire hard disk, instead of partitioning (as discussed below). Therefore, you may accidentally mess up partitions or data. The device files on the hard disk are used only when you access the primary boot fan (which will be discussed below.
Floppy Disk
One or both sides of a floppy disk are coated with magnetic media similar to a hard disk. The floppy disk does not have a read/write header, and the read/write header is on the drive. A floppy disk is equivalent to a disk of a hard disk, but can be moved. A drive can access different floppy disks, while a hard disk is an independent unit.
Like a hard disk, a floppy disk can be divided into a disk and a sector (a disk with the same track on the two sides of the floppy disk), but the number of disks is much smaller than that of the hard disk.
A floppy disk can usually use several different disks. For example, a 3.5 'floppy disk can use kb or MB. Because the disk drive operation is somewhat different, and the operating system must know the disk capacity, the disk drive has many device files, each of which is related to the disk drive and the disk type. Therefore,/dev/fd0H1440 is the first floppy disk (fd0) and must be a 3.5 'floppy disk. Use a 3.5 'high-density floppy disk (H) with a capacity of 1440KB (1440 ), that is, a general 3.5 'hd floppy disk. For the naming conventions of a floppy disk device, see [Anv].
The name of a floppy disk is complex. Therefore, Linux has a specific type of floppy disk, which can be used to automatically detect the floppy disk category in a floppy disk. It uses different floppy disk types to try to read the first sector of the newly inserted floppy disk until the correct one is found. This naturally requires that the floppy disk has been formatted. Automatic devices include/dev/fd0 and/dev/fd1.
The parameter settings of the automatic device that accesses the floppy disk can be set by the setfdprm program. This allows you to use a floppy disk that is not the usual capacity, such as a floppy disk with a number of non-standard sectors, or automatically detect failure or proper Device File loss for some reason.
In addition to all the standard, Linux can also handle many non-standard floppy disk formats. This sometimes requires a special formatting program. We will skip these floppy disk formats, and you can view the/etc/fdprm file. It defines the setfdprm recognition settings.
The operating system must know when the floppy disk has been replaced, for example, to avoid using the cache data of the previous floppy disk. Unfortunately, this is not always effective when the signal line used for this function is disconnected or bad, and used in MSDOS. This may be the reason if you have encountered such a weird problem. The only way to solve this problem is to repair the soft drive.
CD-ROM
The CD-ROM driver uses an Optical Readable plastic coated disc. Information is recorded on a small spiral pit at the edge of the slave center on the disc surface. The drive emits a laser to read the disk. When the laser emits on a small pitfall, the laser is reflected in one way; when it emits on a smooth surface, it is reflected in another way. This can easily be encoded into bits to form information. Others are easy, but mechanical.
CD-ROM drives are slower than hard drives. The average seek time of a typical hard disk is less than 15 ms, and the fast CD-ROM drive takes a few seconds. The actual data transmission rate is quite fast, in several hundred KB/s. Slow speed makes the CDROM Drive unable to replace the hard disk (some Linux distributions provide the "live" CD-ROM file system so that it does not have to copy files to the hard disk, so that the installation is simple and saves a lot of hard disk space ), although it is possible. The CD-ROM is good to install new software, because the speed is not the most important during installation.
There are multiple ways to arrange data on CDROM. Streaming
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service