What is Lun in Linux and the difference between it and storage volume

Today I saw a Lun alert on the company’s system. I checked the information on the Internet. This blog feels good, share it

I usually have a lot of friends consulting on the concept of LUNs and storage volumes. Today, I just had a little time to check the information of LUNs and volumes on the Internet, and then I will sort them out for everyone to learn and communicate together.
1. The concept of LUN

  The full name of LUN is Logical Unit Number, which is the logical unit number. We know that the number of devices that can be attached to the SCSI bus is limited, usually 6 or 15, we can use Target ID (also called SCSI ID) to describe these devices, as long as the device is added to the system, there will be one Code, when we are distinguishing equipment, we only need to say which number and which number is ok.

  In fact, the objects we need to describe are far more than this number, so we introduced the concept of LUNs, which means that the role of LUN ID is to expand Target ID. There can be multiple LUN Devices under each Target. We usually refer to LUN Device as LUN for short. In this way, it can be said that the description of each device has the original Target x changed to Target x LUN y, so it is obvious that we describe the device The ability is enhanced.

Just as there is a physical hard disk in our computer, we have to partition it into logical disks: such as C drive, D drive, E drive..  
So we can summarize, LUN is for us to use and describe more A method introduced for equipment and objects is nothing special at all.
The LUN ID is not equal to a certain device, it is just a number, and does not represent any physical attributes. In our actual environment, the LUN we encounter may be disk space, tape drives, media changers, and so on.

2. What exactly is a LUN?

  The mystery of LUN (compared to some novices) is that it is often not a visible entity, but a virtual object. For example, in an array cabinet, the host side is regarded as a Target Device. For some special needs, we have to divide the disk space of the disk array cabinet into several small units for the host to use, so some logic is generated In terms of drives, they are logical objects lower than Target Device. We are accustomed to calling these smaller disk resources LUN0, LUN1, LUN2... or something. The mechanism of the operating system dictates that the smallest storage object level recognized by the operating system is LUN Device, which is a logical object, so it is often called Logical Device.

  Some people say that I only recognize a disk in Windows, but I don’t see a word for LUN. Is it LUN=Physical Disk? The answer is no, as long as you pay attention, you can see the value of a LUN in the properties of the disk, just because your Disk is not divided into multiple storage resource objects, and the entire disk is used as a LUN, LUN The ID is zero by default, and that's it.

  We have encountered such a problem. For example, someone asked, we have a disk array connected to two hosts, we divided a LUN for the two hosts to recognize, and then we thought, first divide the disk into the operating system Two partitions, let two hosts use two partitions separately, and then after a host goes down, use the cluster software to switch the partition to another host. Is this feasible? The answer is also no. The disk unit operated by the cluster software is LUN, not partition, so this operation is not feasible. Of course, in some environments, generally those with relatively low requirements, different disk partitions can be mounted on multiple hosts. However, in this case, disk switching is not actually involved, so in some high requirements In this environment, this situation is not allowed at all.

  It should be noted that in the concept of some manufacturers and products, the LUN ID is bound to a specific Device, such as some IBM tape libraries. The entire tape library has only one Target ID, and then the changer and tape drive are separated. The allocation is LUN0, LUN1, LUN2..., but we should note that this is only a special design of the product, and it is also a rare case.

3. What is the difference between LUN and storage volume?

  It is common for people to talk about the difference between storage volumes and LUNs, and then argue endlessly. From the above, we can know what a LUN is. LUN is the abbreviation of English Logical unit number, that is, the logical unit number. It is actually defined in SCSI-3 and is not only used for storage. It can also refer to all peripheral devices that use the SCSI protocol, such as tape drives and SCSI. Printers and so on. From the SCSI-3 SAM model, we know that the protocol layer of SCSI-3 (or later versions) stipulates that for a 16-bit wide SCSI bus, its addressing range is only 16, that is, only 16 peripheral devices can be mounted , Each device is called a target. In order to improve the addressing ability of the bus, another layer was introduced. It stipulates that on each target, multiple devices can be virtualized (or actually connected). For example, a target may be connected to a tape drive and one Printers, they share a target address, but in order to distinguish them, LUNs are used to distinguish them. The tape drive is assumed to be LUN0, and the printer is assumed to be LUN2. This solves the addressing problem of multiple devices.

  This is an example of actual device connection. Storage arrays (such as HP leftHand P4000 SAN) are the best examples of virtual devices. A storage disk array is a Target from the SCSI bus, occupying a SCSI Target address, but the storage space of the storage array is too large, we need to divide it into different parts for different applications to achieve centralized storage and centralized management the goal of. Therefore, in each segmented storage part (or area), we use LUN to distinguish it. For example, LUN1 represents address block 0-1023, LUN2 represents address block 1024-65535 and so on. It can be seen from the above that when the computer uses the SCSI standard (note that the word standard I used here represents the 4 layers in the SAM model, and does not use words such as interface, protocol or command), use It is the BUS-Target-LUN ternary addressing scheme. The bus refers to how many SCSI buses and SCSI cards are there on your computer? The target refers to the target address of the device on the bus, which is the SCSI address that is often said? LUN refers to the logical address and logical unit number allocated by the device on a target. This kind of addressing scheme and device connection method is similar to a network topology with a physical star connection and a logical bus connection.
  So what is a storage volume? This starts with the storage volume manager. The storage volume manager is an object in the operating system, and it is mainly responsible for the online management of storage block devices. When one of our storage LUNs is connected to the computer, and the computer discovers the existence of this device, it needs to be registered on the volume manager. The volume manager provides a registered virtual interface for the storage volume to obtain the basic information of the storage LUN, such as space size. Ternary address, block size, start and end address, health status, etc., and then create a corresponding data structure abstraction for it, so that the computer can dynamically capture the real-time information of the registered storage LUN through the volume manager to achieve dynamics management. After a storage LUN is registered and abstracted by the volume manager, it is regarded as a direct subordinate by the volume manager. It can be divided into smaller areas again, of course, it can also be undivided, and then divided or undivided. The latter storage space performs data abstraction and establishes related data structures for the file system layer to call. Therefore, storage LUNs and volumes may be the same thing physically, but they are viewed and understood from different angles and levels. Of course, for computers, these differences are necessary for the data processing process, and it is also necessary to clarify.

Guess you like

Origin blog.csdn.net/l_liangkk/article/details/114992626