In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
How to understand VHD virtual disks in PVS architecture, many novices are not very clear about this, in order to help you solve this problem, the following small series will explain in detail for everyone, people who have this need can learn, I hope you can gain something.
1. Differential virtual hard disk
The difference virtual hard disk stores the master file locator within the difference virtual hard disk itself, and when the driver attempts to open the difference hard disk, it will open the difference virtual hard disk and the master simultaneously. The master disk may also be a differencing virtual hard disk, in which case there may be a chain of differencing virtual hard disks that eventually terminate in a non-differencing virtual hard disk.
The master locator table is used only by differential virtual hard disks, as described in "Extensible Virtual Hard Disk Header Format" earlier in this article. A differencing virtual hard disk is an extensible VHD that has the same file structure as an extensible VHD, except that the Type field in the footer area is 4, indicating that it is a differencing virtual hard disk. Since the DVD cannot operate independently and must rely on its master disk, the fields such as "master disk UUID,""master disk name" and "master disk locator" in the header store important information: the master disk UUID and master disk name are used to identify the master disk of the DVD; the master disk locator stores the positioning code information of the master disk of the DVD on different platforms (Windows or Mac, etc.) for migration operation on different platforms.
In Windows, there are two types of platform locators: W2ku and W2ru. The former is the absolute pathname of the master disk, and the latter is the pathname of the master disk relative to the differential virtual hard disk.
For example, a master image located in the root drive on a Windows computer would be stored in the following format:
Type
Example
W2ku
c:\directory\parent.vhd
W2ru
.\ directory\parent.vhd
The advantage of relative pathnames is that it allows differential virtual hard disks and master disks to be migrated to different locations. With absolute pathnames, master and daughter disks must be explicitly relinked each time the master is moved.
When creating a differential virtual hard disk, you should initialize the pathnames of both types of platform locators on the corresponding platform, if possible.
Write operations for differential virtual hard disks:
For write operations, all data is written to the differential virtual hard disk image. For all sectors written to a particular block, the block bitmap is marked dirty.
Read operation of differential virtual hard disk:
When the drive reads a sector of the hard disk image, the virtual hard disk subsystem checks the block bitmap in the differencing virtual hard disk. The hard disk subsystem then reads sectors marked dirty from the differential virtual hard disk and sectors marked clean from the master disk.
For example, consider that blocks of sectors 4096 to 8191 are saved in both the master image and the child hard disk image. The first sector of a block holds the bitmap for that block. A single cell represents a bit in the bitmap, and a black dot ××× indicates that a particular sector in the block has been written with data.
Master Data Block:
4096
4097
4098
4099
4100
4101
●
4102
●
4103
●
4104
4105
4106
4107
Clean
Clean
Clean
Clean
Clean
Clean
dirty
dirty
dirty
Clean
Clean
Clean
Clean
Clean
Clean
dirty
dirty
dirty
Clean
Clean
Clean
Clean
Clean
Clean
dirty
dirty
dirty
Differential virtual hard disk sub-blocks:
4096
4097
4098
4099
4100
4101
●
4102
●
4103
●
4104
4105
4106
4107
Clean
Clean
Clean
Clean
Clean
Clean
dirty
dirty
dirty
Clean
Clean
Clean
Clean
Clean
Clean
dirty
dirty
dirty
Clean
Clean
Clean
Clean
Clean
Clean
dirty
dirty
dirty
If the upper layer drive issues a read operation for sectors 4098 through 4104, the hard disk subsystem will read sectors 4098 through 4101 from the master block and will read sectors 4102 through 4104 from the differential virtual hard disk sub-block.
If the drive issues a write operation for sectors 4102 through 4106, the entire data will be written to the differencing virtual hard disk sub-block and the bitmap will be marked dirty for sectors 4105 and 4106 in the differencing virtual hard disk sub-block.
Differential virtual hard disk sub-blocks:
4096
4097
4098
4099
4100
4101
●
4102
●
4103
●
4104
4105
4106
4107
Clean
Clean
Clean
Clean
Clean
Clean
dirty
dirty
dirty
Clean
Clean
Clean
Clean
Clean
Clean
dirty
dirty
dirty
Clean
Clean
Clean
Clean
Clean
Clean
dirty
dirty
dirty
Write operations are issued for sectors 4102 to 4106:
4096
4097
4098
4099
4100
4101
●
4102
●
4103
●
4104
●
4105
●
4106
4107
Clean
Clean
Clean
Clean
Clean
Clean
dirty
dirty
dirty
dirty
dirty
Clean
Clean
Clean
Clean
Clean
Clean
dirty
dirty
dirty
dirty
dirty
Clean
Clean
Clean
Clean
Clean
Clean
dirty
dirty
dirty
dirty
dirty
To sum up, when using the difference virtual hard disk mode, the difference virtual hard disk and its master disk will be opened at the same time. When a difference virtual hard disk is written, the written data is stored on the difference virtual hard disk, and the master disk is not modified; when the difference virtual hard disk is read, if the read data has been modified, the modified data stored on the difference virtual hard disk is read, and if the data has not been modified, the original data of the master disk is read. If the read data includes the original data of the master disk and the modified data on the difference virtual hard disk, the original data of the master disk is read first, and then the modified data on the difference virtual hard disk is read and combined into unified data.
2. VHD virtual hard disk addressing process
For fixed mode VHD files, the sectors of the virtual hard disk correspond to the sector order of the file, and the fixed mode VHD is addressed, and the corresponding sector can be found through the footer area.
For scalable VHD, its data blocks are dynamically allocated by block allocation table, and the addresses of virtual hard disks and VHD files need to pass through hierarchical indexes to achieve the purpose of storing or reading and writing data.
Details are as follows:
(1) Read the footer area of the extensible VHD file and determine whether it is an extensible VHD file and where the header is located by using the fields such as "Type" and "Data Offset" in the footer area.
(2) Read the header, determine the block size, location and number of block allocation tables.
(3) Find the block allocation table, locate the corresponding block allocation entry, and read the entry value.
(4) According to the value of the allocation table entry, determine the data block corresponding to its value (sector bitmap address of the data block), read the sector bitmap, determine the sector usage of the data area, and then read the data; if the value of the allocation table entry is 0xFFFFFF, it means that no data is written in the data block.
(1) Read the footer area of the difference VHD file, and determine whether it is a difference VHD file and where the header is by using the fields such as "Type" and "Data Offset" in the footer area.
(2) Read the header, determine the position of the master disk through fields such as "master disk UUID,""master disk name," and "master disk locator" in the header, and then determine the block size of the differential virtual hard disk itself, and the position and number of the block allocation table.
(3) Find the master disk, repeat the addressing process in the scalable mode, and find the data that needs to be read; at the same time, the difference virtual hard disk itself finds its own block allocation table, locates the corresponding block allocation entry, and reads the value of the entry.
(4) According to the value of the allocation table entry, determine the data block corresponding to its value (sector bitmap address of the data block), read the sector bitmap, determine the sector usage of the data area, and then read the data; if the value of the allocation table entry is 0xFFFFFF, it means that no data is written in the data block.
Did reading the above help you? If you still want to have further understanding of related knowledge or read more related articles, please pay attention to the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.