Reasons why Devices have inconsistent logical block sizes appear
The problem is that the logical block size of the disk newly added to Vgextend is different from the logical block size of the original disk in VG. For example, if the original VG is built on a disk device with a logical block size of 512, but the newly added device during Vgextend is a logical block size of 4K, this problem will occur.
Solution 1: Enable allow_mixed_block_sizes=1 in lvm.conf
Open the /etc/lvm/lvm.conf file and modify allow_mixed_block_sizes=1
But this way, is it safe to mix block sizes on the same LV? https://serverfault.com/questions/1150643/is-it-safe-to-use-allow-mixed-block-sizes-1-in-lvm-when-using-ext4-with-4k-blo
Solution 2: Modify the logical block sizes of some hard drives to make all hard drives consistent
Check the logical block sizes of the hard disk
lsblk
|
|
PHY-SEC shows the physical sector size and LOG-SEC shows the logical sector size.
sysfs
|
|
sda is the device name
fdisk
|
|
Sector size physical shows the physical sector size and Sector size logical shows the logical sector size.
smartctl
|
|
View Supported LBA Sizes, supported LBA, + section is the currently selected LBA Size
Modify Modify sector LBA size
Warning: Changing the sector size of a hard disk will irrecoverably erase all data.
Some NVMe and “enterprise” SATA drives support modifying their reported sector sizes via standard NVMe (Format NVM for NVMe Command Set Standard 1.0 or above) or ATA (SET SECTOR CONFIGURATION EXT for ATA Command Set Standard 1.0 or above) respectively. For mechanical hard disks, this operation optimizes hard disk performance by modifying their logical sector size to be consistent with the physical sector size. For NVMe SSDs, both logical and physical sector sizes are changed.
SATA SSDs generally do not support modifying the sector size. Some Intel SATA SSDs can only modify the reported physical sector size, but not the logical sector size. Modifying the sector size involves a series of complex operations, including low-level formatting. As an alternative, you can optimize performance by manually specifying the sector size when creating the file system on the hard drive.
Modify mechanical hard drive
Use the hdparm tool to determine whether the hard drive’s sector size can be changed:
Hard drives that do not support modifying the logical sector size will only report the current sector size.
|
|
Supports hard disk modification of logical sector size
|
|
Use the hdparm tool to modify the sector size of the mechanical hard disk
If your SATA mechanical hard drive supports multiple logical sector sizes and the optional SET SECTOR CONFIGURATION EXT ATA command (for example, Seagate promotes hard drives with FastFormat functionality), you can use hdparm to switch between the different supported logical sector sizes. This can be set to 4096 bytes (i.e. 4Kn) using the following command:
|
|
After the modification hdparm should report a logical sector size of 4096 bytes:
|
|
Modify NVMe SSD
Although solid-state drives (SSDs) often use larger physical blocks (usually 4 KiB, 8 KiB, and sometimes larger), they typically report their logical block size as 512 bytes. You can use the Identify Namespace command through the nvme-cli package to view the formatted logical block address size (FLBAS) of the NVMe hard drive:
|
|
Metadata Size is the size of additional metadata bytes per logical block address (Logical Block Address, LBA). This feature is not yet fully supported on Linux, so it is best to use a format with a value of 0. Relative Performance represents the performance level provided by various formats (including degraded, good, better and best).
smartctl can also display the logical block address size supported by the device
|
|
The logical block address size can be modified by passing a target value to the nvme format command using the –lbaf parameter:
|
|
lbaf corresponds to the id value, and the modification takes a few seconds to complete.