2

I have a disk under a Logical Volume.

$ 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

Now, I want to add a new disk to extend the volume. The disk is attached through the USB interface.

$ 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

When I try to add it to extend the volume, I get the error.

$ vgextend vg_prod /dev/sdg
Devices have inconsistent logical block sizes (4096 and 512).

So I started to change the logical sector size for /dev/sdg to 4096.

$ fdisk -b 4096 /dev/sdg

When I print the partition table in fdisk, I do see the logical sector size as 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

When I create a partition, write changes, and list. It goes back to showing 512 as logical sector size.

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

Is there a way to change my disk to have logical sector size 4096 so I could add it to the existing storage that I already have?

1 Answers1

1

It seems you can set allow_mixed_block_sizes = 1 in lvm.conf (/etc/lvm/lvm.conf).

I guess that solution is likely to work well if you have a VG originally set up with (PVs with) 4K sectors and want to add PVs with 512b sectors.

I'd be careful if it is the the other way around.

Zrin
  • 156