我在逻辑卷下有一个磁盘。
$ lvdisplay
--- Logical volume ---
LV Path /dev/vg_prod/lv_prod
LV Name lv_prod
VG Name vg_prod
LV UUID mXj3Qv-t0GK-4idW-mRBA-17Nb-PSPK-Roulf3
LV Write Access read/write
LV Status available
# open 1
LV Size <3.64 TiB
Current LE 953797
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
现在,我想添加一个新磁盘来扩展卷。该磁盘通过 USB 接口连接。
$ fdisk -l /dev/sdg
Disk /dev/sdg: 3.65 TiB, 4000752599040 bytes, 7813969920 sectors
Disk model: Game Drive
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
当我尝试添加它来扩展卷时,出现错误。
$ vgextend vg_prod /dev/sdg
Devices have inconsistent logical block sizes (4096 and 512).
因此我开始将逻辑扇区大小更改为/dev/sdg
4096。
$ fdisk -b 4096 /dev/sdg
当我在 fdisk 中打印分区表时,我确实看到逻辑扇区大小为 4096。
Welcome to fdisk (util-linux 2.34).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xf4a7867a.
Command (m for help): p
Disk /dev/sdg: 3.65 TiB, 4000752599040 bytes, 976746240 sectors
Disk model: Game Drive
Units: sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0xf4a7867a
当我创建分区、写入更改并列出时。它又显示 512 作为逻辑扇区大小。
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (256-976746239, default 256):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (256-976746239, default 976746239):
Created a new partition 1 of type 'Linux' and of size 3.7 TiB.
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
$ sudo fdisk -l /dev/sdg
Disk /dev/sdg: 3.65 TiB, 4000752599040 bytes, 7813969920 sectors
Disk model: Game Drive
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0xf4a7867a
Device Boot Start End Sectors Size Id Type
/dev/sdg1 256 976746239 976745984 465.8G 83 Linux
有没有办法将我的磁盘更改为具有 4096 逻辑扇区大小,以便我可以将其添加到已有的存储中?
答案1
看来您可以allow_mixed_block_sizes = 1
在 lvm.conf ( /etc/lvm/lvm.conf
) 中设置。
我想,如果您最初设置的 VG(PV)为 4K 扇区,并且想要添加 512b 扇区的 PV,那么该解决方案可能会很好地发挥作用。
如果情况相反,我会小心。