3

I'm trying to create a LVM VG and LV, but the LV is not aligned.

Here's my starting position:

% lsblk -t /dev/sdd
NAME   ALIGNMENT MIN-IO   OPT-IO PHY-SEC LOG-SEC ROTA SCHED       RQ-SIZE  RA WSAME
sdd            0   4096 33553920    4096     512    1 mq-deadline      60 128   32M
├─sdd1         0   4096 33553920    4096     512    1 mq-deadline      60 128   32M
├─sdd2         0   4096 33553920    4096     512    1 mq-deadline      60 128   32M
└─sdd3         0   4096 33553920    4096     512    1 mq-deadline      60 128   32M

Note the ALIGNMENTs are all 0 (correct).

On sdd2, I create a VG test and then a LV align-me:

% sudo vgcreate --pvmetadatacopies 2 --vgmetadatacopies 2 test /dev/6TBd1p2
  Physical volume "/dev/6TBd1p2" successfully created.
  Volume group "test" successfully created
% sudo lvcreate -L 64g -n align-me test
  Logical volume "align-me" created.

However, ALIGNMENT for test-align--me is wrong:

% lsblk -t /dev/sdd
NAME               ALIGNMENT MIN-IO   OPT-IO PHY-SEC LOG-SEC ROTA SCHED       RQ-SIZE  RA WSAME
sdd                        0   4096 33553920    4096     512    1 mq-deadline      60 128   32M
├─sdd1                     0   4096 33553920    4096     512    1 mq-deadline      60 128   32M
├─sdd2                     0   4096 33553920    4096     512    1 mq-deadline      60 128   32M
│ └─test-align--me        -1   4096        0    4096     512    1                 128 128   32M
└─sdd3                     0   4096 33553920    4096     512    1 mq-deadline      60 128   32M

I also see the following log message (repeated 4 times):

kernel: device-mapper: table: 254:6: adding target device sdd2 caused an alignment inconsistency: physical_block_size=4096, logical_block_size=512, alignment_offset=0, start=33553920

I've calling vgcreate with --dataalignmentoffset 4k and also --dataalignment with 1m and 4m but the results are the same.

I'm running:

LVM version:     2.02.182(2) (2018-10-30)
Library version: 1.02.152 (2018-10-30)
Driver version:  4.39.0
  • --dataalignmentoffset 4k why though? You could try using --dataalignment same as PE size (and set PE size to something larger, e.g. 64M). Mind showing a vgcfgbackup (created w/o the offset) and parted unit s print? – frostschutz Jan 24 at 14:53
  • also really weird OPT-IO value... stick to MiB alignment no matter what it says – frostschutz Jan 24 at 14:57
  • oh, you already asked the same question here? unix.stackexchange.com/q/340484/30851 – frostschutz Jan 24 at 14:59
  • Thanks for you pointers @frostschutz. The final answer was a little surprising, but I got there :) – Tom Hale Jan 25 at 5:18
2

Symptoms

  1. The lsblk -t OPT-IO value was really high (pointed out by frostschutz)

  2. When running smartctl on the disk, I was seeing:

    Read Device Identity failed: scsi error unsupported field in scsi command
    

Cause

It seems that -1 is returned if an optimal IO value can't be read.

As pointed out by Steve Dee:

  • 33553920 / 512 (logical sector size) = 65535
  • -1 represented as a 16 bit value = 65535. (216 = 65536)

This 33553920 value is then used by pvcreate/vgcreate to align the first PE (pe_start) as shown by:

sudo pvs -o +pe_start --units b

Work-around

Passing --dataalignment 1m to vgcreate will have pe_start = 1048576B = 1MiB.

This will ensure that pe_start is aligned with a disk sector, but the (incorrect) misalignment message will still be printed.

Root cause fix

Disabling UAS on the drive had the OPT-IO value return to 0 (consistent with my other disk drives). It also allowed smartctl to be run on the drive.

Passing --dataalignment 1m is not needed if this fix is applied.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.