Geekly Articles each Day

One of the sudden problems when using GPT is (if we want to see a decent recording speed) having to adjust the position of the partition on WD discs with Advanced format. The essence of Advanced Format is simple: inside the disk has 4k sectors, outside they are emulated as 512-bytes. If we record two sectors within one 4k block, it is recorded once. If we record two sectors so that we touch two 4k sectors, the disk has to read two sectors, update the information and write them back. Bad and slow. Modern operating systems use 4k blocks for writing, so if we get right, each write operation will be just a record, without reading. If we get unevenly (for example, 2kb from the first sector and 2kb from the second), then we will get huge brakes (see the link below to the IBM website with statistics of "braking" with errors in the markup).

WD, when thinking about 512 VS 4k, did not take into account that besides the MBR there is also GPT. In the case of 2TB disks, the MBR still suffers, however, 3Tb disks ahead, and in them the MBR simply cannot mathematically provide partitions and the transition to GPT is inevitable.

So the problem of GPT and WD must be considered today. The main tool for GPT manipulation is currently parted and its graphical version is gparted. Unfortunately, gparted does not know what we need, so everything that follows describes the use of parted.

')

Main idea: All values â€‹â€‹(beginning, end of section) should be multiples of 4kB, or, which is slightly simpler, 8 sectors. This is a requirement of the WD advanced format.

GPT itself occupies a certain amount (33 sectors: 32 GPT sectors, 1 sector is a fake MBR gag), so the first multiple of 8 numbers with which we can work is 40 sectors. The final number depends on the capacity of the disk, but also, preferably, a multiple of 8. In addition, the GPT is duplicated at the end of the disk, so the place at the end of the disk will also be â€śbittenâ€ť.

For best performance, you need to take into account the size of PE for LVM - 4Mb (8192 sectors) and set the volume size to a multiple of the number of PE. As a result of all these manipulations, we will lose a bit of space (less than 8Mb), but we will get a fast volume that will not have â€śunusedâ€ť kilobytes in the description in LVM.

In addition, there is another opinion of gparted itself, that the best position of a volume is multiple to megabytes. Thus, the final requirements are as follows: the volume must begin and end at multiples of 4Mb.

So, creating LVM volumes on WD'shish disk with Advanced Format:

creating a gpt partition table

# count space in sectors.

> Disk / dev / sdx: 3907029168s

display information about the screw.

In this conclusion, we are interested in the number of sectors, pay attention, since we have a WD disk, the number of sectors simply must be a multiple of 8. If it is not a multiple of 8, either this is not Advanced Format, or someone plays with jumpers, or something else terrible happened (for example, you made a mistake with a screw and just with the command of mklabel gpt you demolished the contents of the disk with the most valuable one).

We consider our values: the oldest, multiple to 8192 sectors - 3907026944. By the way, here is a small swindle, we lose a place not two times, but one, since the total size of our volume will be 3907029168-8192 sector.

If appears

> Warning: You requested a partition from 39s to 3907029167s.

> The closest location we can manage is 39s to 3907029134s.

> Is this still acceptable to you?

> Yes / No?

This means that you are mistaken with math and need to be recounted.

After creating the section, you can exit parted and perform the usual LVM rituals: pvcreate, vgexpand, etc.

**Literature** :

WD, when thinking about 512 VS 4k, did not take into account that besides the MBR there is also GPT. In the case of 2TB disks, the MBR still suffers, however, 3Tb disks ahead, and in them the MBR simply cannot mathematically provide partitions and the transition to GPT is inevitable.

So the problem of GPT and WD must be considered today. The main tool for GPT manipulation is currently parted and its graphical version is gparted. Unfortunately, gparted does not know what we need, so everything that follows describes the use of parted.

')

Main idea: All values â€‹â€‹(beginning, end of section) should be multiples of 4kB, or, which is slightly simpler, 8 sectors. This is a requirement of the WD advanced format.

GPT itself occupies a certain amount (33 sectors: 32 GPT sectors, 1 sector is a fake MBR gag), so the first multiple of 8 numbers with which we can work is 40 sectors. The final number depends on the capacity of the disk, but also, preferably, a multiple of 8. In addition, the GPT is duplicated at the end of the disk, so the place at the end of the disk will also be â€śbittenâ€ť.

For best performance, you need to take into account the size of PE for LVM - 4Mb (8192 sectors) and set the volume size to a multiple of the number of PE. As a result of all these manipulations, we will lose a bit of space (less than 8Mb), but we will get a fast volume that will not have â€śunusedâ€ť kilobytes in the description in LVM.

In addition, there is another opinion of gparted itself, that the best position of a volume is multiple to megabytes. Thus, the final requirements are as follows: the volume must begin and end at multiples of 4Mb.

So, creating LVM volumes on WD'shish disk with Advanced Format:

`# parted /dev/sdx`

`mklabel gpt`

creating a gpt partition table

`unit s`

# count space in sectors.

`print`

> Disk / dev / sdx: 3907029168s

display information about the screw.

In this conclusion, we are interested in the number of sectors, pay attention, since we have a WD disk, the number of sectors simply must be a multiple of 8. If it is not a multiple of 8, either this is not Advanced Format, or someone plays with jumpers, or something else terrible happened (for example, you made a mistake with a screw and just with the command of mklabel gpt you demolished the contents of the disk with the most valuable one).

We consider our values: the oldest, multiple to 8192 sectors - 3907026944. By the way, here is a small swindle, we lose a place not two times, but one, since the total size of our volume will be 3907029168-8192 sector.

`mkpart primary 8192 3907026944`

If appears

> Warning: You requested a partition from 39s to 3907029167s.

> The closest location we can manage is 39s to 3907029134s.

> Is this still acceptable to you?

> Yes / No?

This means that you are mistaken with math and need to be recounted.

After creating the section, you can exit parted and perform the usual LVM rituals: pvcreate, vgexpand, etc.

Source: https://habr.com/ru/post/102007/