Two Representation Methods for storing devices in Linux

Source: Internet
Author: User
Author: North South

From: linuxsir. org

Abstract: both hard disk and hard disk partitions are represented as devices in Linux. In our general saying, how to express or describe hard disk and hard disk partitions is scientific and specific; for example, the IDE Hard Disk can be expressed as/dev/hda,/dev/HDB in Linux ...; the hard disks of the SCSI interface and the hard disks of the SATA interface are/dev/SDA and/dev/SDB ......; the Hard Disk/dev/hda of the IDE interface can also be expressed as hd0, while the SCSI interface can be/dev/SDA, and the other method is sd0; what are the meanings of the two Representation Methods? At least GRUB boot Manager uses this knowledge. In addition, we also use this knowledge to mount (Mount) file systems (partitions; directory Index 1. Two Representation Methods for the hard disk of the IDE interface;

      1. Ide interface hard disk, Two Representation Methods for the entire hard disk;
      2. Two Representation Methods of Hard Disk Partitions of the IDE interface;

        1) the first hard disk partition representation method/dev/HD [A-Z] X;
        2) The second representation of Hard Disk Partitions (HD [0-n], y );

2. Two Hard Drive Representation Methods for SATA and SCSI interfaces; 3. storage devices and soft drive devices for USB and 1394 interfaces; 4. Application of different representation methods of storage devices;

      1./dev/HD [A-Z] indicates the application of the method;

        1) used to mount a file system (partition;
        2) specify the location of the Linux Root partition in grub;

      2. HD [0-n] indicates the application of the method.

5. About this article.
6. References.
6. Related Documents;

++ +++ ++

body

++ +++ ++


1. Two hard disks of the IDE Interface;


1. Ide interface hard disk,

the entire hard disk in the IDE interface is expressed as/dev/HD [A-Z] in Linux, such as/dev/hda, /dev/HDB ...... similarly, sometimes/dev/HDC may indicate CDROM, or take the specific fdisk-L output as the standard. Another representation is HD [0-n], where N is a positive integer, such as hd0, hd1, hd2 ...... HDN; if there is only one hard disk in the machine, no matter whether/dev/hda or/dev/HDB is listed through fdisk-L, hd0 is used; if two or more hard disks exist in the machine, the first hard disk/dev/hda, the other method is hd0, and the second Hard Disk/dev/HDB, another table method is hd1. I feel that the hd0 and hd1 methods are not generated. Now, a new machine, in the bios, sets the hard disk with hd0 on the boot disk, hd1 and so on. This is one of the hard disk representation methods. For the representation methods similar to/dev/hda, It is not born; in Linux, we can use fdisk-L to check whether the hard disk is/dev/hda or/dev/HDB.

[Root @ localhost ~] # Fdisk-l


Disk/dev/hda: 80.0 GB, 80026361856 bytes

255 heads, 63 sectors/track, 9729 Cylinders

Units = cylinders of 16065*512 = 8225280 bytes


Device boot start end blocks ID system

/Dev/hda1*1 970 7791493 + 7 HPFs/NTFS

/Dev/hda2 971 9729 70356667 + 5 extended

/Dev/hda5 971 2915 15623181 B w95 FAT32

/Dev/hda6 2916 4131 9767488 + 83 Linux

/Dev/hda7 4132 5590 11719386 83 Linux

/Dev/hda8 5591 6806 9767488 + 83 Linux

/Dev/hda9 6807 9657 22900626 83 Linux

/Dev/hda10 9658 9729 578308 + 82 Linux swap/Solaris

Note that the first line, disk/dev/hda: 80.0 GB, 80026361856 bytes, indicates that the machine has only one hard disk device/dev/hda, And the size is 80.0 GB; the following is the partition of the hard disk. Each partition has detailed information, which is not detailed here;

2. Two Representation Methods of Hard Disk Partitions of the IDE interface;


1) the first hard disk partition representation method/dev/HD [A-Z] X;

The hard disk partition can also be expressed in two ways, one is/dev/HD [A-Z] X, and the-Z represents a, B, c ...... Z and X are positive integers starting from 1. For example,/dev/hda1,/dev/hda2 .... /dev/hda6,/dev/hda7 ...... it is worth noting that/dev/HD [A-Z] X. If the value of X is between 1 and 4, it indicates the primary partition of the hard disk (including the extended partition ); logical partitions start from 5. For example,/dev/hda5 must be logical partitions. I can use fdisk-L to list partition tables of a hard disk, for example:

[Root @ localhost ~] # Fdisk-l


Disk/dev/hda: 80.0 GB, 80026361856 bytes

255 heads, 63 sectors/track, 9729 Cylinders

Units = cylinders of 16065*512 = 8225280 bytes


Device boot start end blocks ID system

/Dev/hda1*1 970 7791493 + 7 HPFs/NTFS

/Dev/hda2 971 9729 70356667 + 5 extended

/Dev/hda5 971 2915 15623181 B w95 FAT32

/Dev/hda6 2916 4131 9767488 + 83 Linux

/Dev/hda7 4132 5590 11719386 83 Linux

/Dev/hda8 5591 6806 9767488 + 83 Linux

/Dev/hda9 6807 9657 22900626 83 Linux

/Dev/hda10 9658 9729 578308 + 82 Linux swap/Solaris



2) The second representation of Hard Disk Partitions (HD [0-n], y );


We have already mentioned that the entire hard disk has two Representation Methods:/dev/HD [A-Z] and HD [0-n]. for a hard disk partition, you must first confirm the hard disk where it is located, and then confirm its location. To make a metaphor, for example, if I live in room YYY of XXX Hotel, I only want to tell others that I am not enough at XXX hotel, and I want to tell them room YYY so that people who come to me can find me. So we need to know a hard disk partition, in addition to knowing the location of/dev/HD [A-Z], you also need to know where it is, that is, the previous/dev/HD [A-Z] x statement, after confirming that the partition is in/dev/HD [A-Z], you must use X to confirm the specific location. This title describes another representation method (HD [0-n], y), HD [0-n] We know this is one of the hard disk Representation Methods. If you don't understand it, please check the previous items. What does y mean here? The value of Y is the X-1 in/dev/HD [A-Z] X. Use an instance to understand it;

[Root @ localhost ~] # Fdisk-l


Disk/dev/hda: 80.0 GB, 80026361856 bytes

255 heads, 63 sectors/track, 9729 Cylinders

Units = cylinders of 16065*512 = 8225280 bytes


Device boot start end blocks ID system

/Dev/hda1*1 970 7791493 + 7 HPFs/NTFS

/Dev/hda2 971 9729 70356667 + 5 extended

/Dev/hda5 971 2915 15623181 B w95 FAT32

/Dev/hda6 2916 4131 9767488 + 83 Linux

/Dev/hda7 4132 5590 11719386 83 Linux

/Dev/hda8 5591 6806 9767488 + 83 Linux

/Dev/hda9 6807 9657 22900626 83 Linux

/Dev/hda10 9658 9729 578308 + 82 Linux swap/Solaris

/Dev/hda1 equals (hd0, 0)

/Dev/hda2 is equivalent to (hd0, 1) Note: Well, this is an extended partition. It cannot be mounted in Linux or windows;

/Dev/hda5 equals (hd0, 4)

/Dev/hda6 equals (hd0, 5)

/Dev/hda7 equivalent (hd0, 6)

/Dev/hda8 equals (hd0, 7)

......

/Dev/hda10 is the same as (hd0, 9). If there is only one hard disk on the machine, either/dev/hda or/dev/HDB is used in Linux, HD [0-N] is used to represent the hard disk, all are hd0; therefore, if the hard disk is listed as follows;

[Root @ localhost ~] # Fdisk-l


Disk/dev/HDB: 80.0 GB, 80026361856 bytes

255 heads, 63 sectors/track, 9729 Cylinders

Units = cylinders of 16065*512 = 8225280 bytes


Device boot start end blocks ID system

/Dev/hdb1*1 970 7791493 + 7 HPFs/NTFS

/Dev/hdb2 971 9729 70356667 + 5 extended

/Dev/hdb5 971 2915 15623181 B w95 FAT32

/Dev/hdb6 2916 4131 9767488 + 83 Linux

/Dev/hdb7 4132 5590 11719386 83 Linux

/Dev/hdb8 5591 6806 9767488 + 83 Linux

/Dev/hdb9 6807 9657 22900626 83 Linux

/Dev/hdb10 9658 9729 578308 + 82 Linux swap/Solaris

For a machine with only one hard disk, if fdisk-L is used to list the/dev/HDB partition table, the correspondence is the same as that of the partition table listed in/dev/hda; /dev/hdb1 equals (hd0, 0)

/Dev/hdb2 equivalent (hd0, 1) Note: As you can see, this is an extended partition, which cannot be mounted in Linux or windows;

/Dev/hdb5 equivalent (hd0, 4)

/Dev/hdb6 equals (hd0, 5)

/Dev/hdb7 equivalent (hd0, 6)

/Dev/hdb8 equivalent (hd0, 7)

......

/Dev/hdb10 is equivalent to (hd0, 9) Note: if there are two hard disks on the machine, the/dev/hda method is hd0, another representation of/dev/HDB is hd1. In this way, we can understand (HD [0-n], Y). In this way, the machine only has one or more hard disks, we all know how to write it, right? Maybe not. correct it;

2. Two Representation Methods of hard disks on SATA and SCSI interfaces;

The method of understanding is the same as that of the IDE interface, except that HD is replaced with SD. If one hard disk is/dev/hda or another hard disk is/dev/SDA, then, the hard disk of/dev/SDA should be sd0. For each partition, use the representation (SD [0-n], Y) and Algorithm Same, for example,/dev/sda1 is (sd0, 0 );

3. USB and 1394 Interface storage devices and soft drive devices;

USB storage devices are also currently in the kernel in two driving methods, one is to simulate the SCSI hard disk, through fdisk-L is/dev/SD [0-N]; to simulate a SCSI device. Another representation of the USB storage device in Linux is the same as that of the SCSI and SATA mentioned earlier. However, in the latest kernel version, we want to discard the simulated SCSI, the/dev/UBA is similar when we use the storage settings of the fdisk column system. However, this driver is not mature, for example, the performance of large data volumes is unstable. In fact, the storage devices of the USB interface, the performance in Linux is still relatively poor; 1394 Interface storage for backup is also simulated SCSI in Linux. After fdisk-L is used,/dev/SD [0-n] appears. for more information about the other representation method (SD [A-Z], Y), see the previous description. The storage devices with the 1394 Interface have excellent performance in Linux, if the USB storage performance is relative to the storage performance of the 1394 Interface, it should not be worth mentioning. We recommend that you purchase a 1394 Interface storage device. in Linux, It is a/dev/fd0 device, the other is fd0, CDROM, dvdrom, and combo. Generally, it is/dev/HDC. See the example below, whether it is/dev/CDROM or/dev/DVD, it finally points to/dev/HDC;

[Root @ localhost ~] # Ls-La/dev/CDROM

Lrwxrwxrwx 1 Root 3 2005-12-14/dev/CDROM-> HDC

[Root @ localhost ~] # Ls-La/dev/DVD

Lrwxrwxrwx 1 Root 3 2005-12-14/dev/DVD-> HDC



4. Application of different representation methods of storage devices;


1./dev/HD [A-Z] indicates the application of the method.



1) used to mount a file system (partition;

As we mentioned earlier, the hard disk partition/dev/HD [A-Z] x representation method is generally used to mount and read file systems;

[Root @ localhost ~] # Fdisk-l


Disk/dev/hda: 80.0 GB, 80026361856 bytes

255 heads, 63 sectors/track, 9729 Cylinders

Units = cylinders of 16065*512 = 8225280 bytes


Device boot start end blocks ID system

/Dev/hda1*1 970 7791493 + 7 HPFs/NTFS

/Dev/hda2 971 9729 70356667 + 5 extended

/Dev/hda5 971 2915 15623181 B w95 FAT32

/Dev/hda6 2916 4131 9767488 + 83 Linux

/Dev/hda7 4132 5590 11719386 83 Linux

/Dev/hda8 5591 6806 9767488 + 83 Linux

/Dev/hda9 6807 9657 22900626 83 Linux

/Dev/hda10 9658 9729 578308 + 82 Linux swap/Solaris

For example, if I want to mount/dev/hda9 to the system, the process should be like this;
[Root @ localhost ~] # Mkdir/opt/data/Note: Create a mount point directory;

[Root @ localhost ~] # Mount/dev/hda9/opt/data/Note: Mount;

Is it mounted? Check the following information and check that the file has been mounted. Therefore, we can write to the/opt/data directory, and all the written content is recorded on/dev/hda9;

[root @ localhost ~] # DF-lH

filesystem capacity in use available % mount point

/dev/hda7 11g 9.2g 1.1G 90%/

/dev/SHM 236 M 0 236 m 0%/dev/SHM

/dev/hda9 22g 3.9g 18g 18%/opt/Data

Note: Kernel support is required for mounting, and file systems must be created for partitions. For more information, see related documents;

2) It is used to specify the location of the Linux Root partition in grub;

In the grub System Boot manager, you must specify the Linux Root/hard disk partition/dev/HD [A-Z] X when starting an operating system using the command line; for example, root =/dev/hda7;

2. HD [0-n] indicates the application of the method;

This is generally applied to the specified hard disk partition where grub/boot is located; In the grub command line and the grub configuration file menu. for example, if you want to write grub to the MBR of the hard disk, you must specify it through root (HD [0-n], y) In grub command line mode; here, root (HD [0-n], Y) is the partition where/boot is located in grub. Do not make a mistake, sometimes, the root/of/boot and Linux are not in the same partition. It depends on how you install Linux; the preceding root =/dev/HD [A-Z] x specifies the partition where the Linux Root/is located. Although sometimes/boot and/are in the same partition, however, the two methods have their own purposes in grub. You can understand. For example, if/boot is located in the same hard disk partition, you can use a similar method to write grub to the hard disk MBR; for example;

[Root @ localhost ~] # Grub Note: Run grub;


Grub> root (hd0, 6) Note: for example, if/boot is located in the (hd0, 6) partition, it should be as follows:

Filesystem type is ext2fs, partition type 0x83


Grub> setup (hd0)

Checking if "/boot/GRUB/stage1" exists... yes

Checking if "/boot/GRUB/stage2" exists... yes

Checking if "/boot/GRUB/e2fs_stage1_5" exists... yes

Running "embed/boot/GRUB/e2fs_stage00005 (hd0)"... 15 sectors are embedded.

Succeeded

Running "Install/boot/GRUB/stage1 (hd0) (hd0) 1 + 15 p (hd0, 6)/boot/GRUB/stage2

/Boot/GRUB/grub. conf "... succeeded

Done.


Grub> quit Note: exit the grub command line mode;



If you don't understand it, it will take a while. I am only writing for the application. If you want to understand why Linux storage devices express this or that, we recommend that you check the kernel document. Chinese documents may not meet your needs. It is best to look at foreign documents;

5. About this article;

This article describes two different expressions of storage devices in Linux, which may be a bit complicated. In the words of pandonny, "it was originally a theoretical concept, new users who write things that are too theoretical can't understand them, but are still descriptive and often more easily understood by new users ". This document mainly refers to the concrete concept of abstraction. I don't know whether new beginners can understand it. At least I have done my best. For me, it is already "North South Technical poor ". The documents in the theoretical text are extremely difficult to translate, let alone simply describe them. New Linux beginners are coming to practice. practice is the only criterion for testing truth, believe this truth is absolutely true !! Never put the truth that I have said in your hands ...... Because you are a practitioner, you have written the grub entry-level document, and it turns out that it is not a good way to write the representation of a storage device, so you are forced to write this article. Article , Though barely, it is still written;

Vi. references;

GNU grub manual and FAQ

VII. related documents;
Rational Planning of your hard disk partition
System guiding process and hard disk partition structure
Introduction to Linux commands for viewing disk partitions, file systems, usage, and related tools
How to Use fdisk for instance explanation
Loading NTFs and FAT32 partitions in Fedora Core 4.0
Fedora Core 4.0 Hal configuration plug-and-play mobile storage (USB and 1394) practices

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.