optimal_io_size is large causing LVM LV alignment inconsistency












2















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









share|improve this question

























  • --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
    14 hours ago













  • also really weird OPT-IO value... stick to MiB alignment no matter what it says

    – frostschutz
    14 hours ago













  • oh, you already asked the same question here? unix.stackexchange.com/q/340484/30851

    – frostschutz
    14 hours ago











  • Thanks for you pointers @frostschutz. The final answer was a little surprising, but I got there :)

    – Tom Hale
    5 mins ago
















2















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









share|improve this question

























  • --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
    14 hours ago













  • also really weird OPT-IO value... stick to MiB alignment no matter what it says

    – frostschutz
    14 hours ago













  • oh, you already asked the same question here? unix.stackexchange.com/q/340484/30851

    – frostschutz
    14 hours ago











  • Thanks for you pointers @frostschutz. The final answer was a little surprising, but I got there :)

    – Tom Hale
    5 mins ago














2












2








2


1






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









share|improve this question
















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






linux lvm






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 6 mins ago







Tom Hale

















asked 16 hours ago









Tom HaleTom Hale

6,72333594




6,72333594













  • --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
    14 hours ago













  • also really weird OPT-IO value... stick to MiB alignment no matter what it says

    – frostschutz
    14 hours ago













  • oh, you already asked the same question here? unix.stackexchange.com/q/340484/30851

    – frostschutz
    14 hours ago











  • Thanks for you pointers @frostschutz. The final answer was a little surprising, but I got there :)

    – Tom Hale
    5 mins ago



















  • --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
    14 hours ago













  • also really weird OPT-IO value... stick to MiB alignment no matter what it says

    – frostschutz
    14 hours ago













  • oh, you already asked the same question here? unix.stackexchange.com/q/340484/30851

    – frostschutz
    14 hours ago











  • Thanks for you pointers @frostschutz. The final answer was a little surprising, but I got there :)

    – Tom Hale
    5 mins ago

















--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
14 hours ago







--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
14 hours ago















also really weird OPT-IO value... stick to MiB alignment no matter what it says

– frostschutz
14 hours ago







also really weird OPT-IO value... stick to MiB alignment no matter what it says

– frostschutz
14 hours ago















oh, you already asked the same question here? unix.stackexchange.com/q/340484/30851

– frostschutz
14 hours ago





oh, you already asked the same question here? unix.stackexchange.com/q/340484/30851

– frostschutz
14 hours ago













Thanks for you pointers @frostschutz. The final answer was a little surprising, but I got there :)

– Tom Hale
5 mins ago





Thanks for you pointers @frostschutz. The final answer was a little surprising, but I got there :)

– Tom Hale
5 mins ago










1 Answer
1






active

oldest

votes


















0














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.



Resolution



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.






share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "106"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f496447%2foptimal-io-size-is-large-causing-lvm-lv-alignment-inconsistency%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    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.



    Resolution



    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.






    share|improve this answer




























      0














      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.



      Resolution



      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.






      share|improve this answer


























        0












        0








        0







        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.



        Resolution



        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.






        share|improve this answer













        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.



        Resolution



        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.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 14 mins ago









        Tom HaleTom Hale

        6,72333594




        6,72333594






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f496447%2foptimal-io-size-is-large-causing-lvm-lv-alignment-inconsistency%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Loup dans la culture

            How to solve the problem of ntp “Unable to contact time server” from KDE?

            Connection limited (no internet access)